Skip to content

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 committed Dec 27, 2022
1 parent 44e9651 commit d73d09c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
3 changes: 0 additions & 3 deletions HolidayEventApi.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<title>$title$</title>
<authors>$author$</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<!-- <icon>icon.png</icon> -->
<projectUrl>https://github.com/westy92/holiday-event-api-csharp</projectUrl>
<description>$description$</description>
<tags>$tags$</tags>
</metadata>
Expand Down
27 changes: 27 additions & 0 deletions HolidayEventApi/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class Client
MaxAutomaticRedirections = 3,
});

/// <summary>
/// Creates a HolidayEventApi Client.
/// </summary>
/// <param name="apiKey">Your API Key. Get one at https://apilayer.com/marketplace/checkiday-api#pricing.</param>
/// <exception cref="ArgumentException">Thrown when the provided API Key is blank or missing.</exception>
public Client(string apiKey) {
if (String.IsNullOrWhiteSpace(apiKey))
throw new ArgumentException("Please provide a valid API key. Get one at https://apilayer.com/marketplace/checkiday-api#pricing.");
Expand All @@ -32,6 +37,13 @@ public Client(string apiKey) {
client.DefaultRequestHeaders.Add("X-Platform-Version", System.Environment.Version.ToString());
}

/// <summary>
/// Gets the Events for the provided Date.
/// </summary>
/// <param name="date">Whether or not to include adult events.</param>
/// <param name="adult">The date to get Events for.</param>
/// <param name="timezone">The timezone used to determine events on the given date.</param>
/// <returns>The Events.</returns>
public async Task<GetEventsResponse> GetEvents(string? date = null, bool adult = false, string? timezone = null) {
var queryParams = HttpUtility.ParseQueryString(String.Empty);
queryParams.Add("adult", adult.ToString().ToLower());
Expand All @@ -41,6 +53,14 @@ public async Task<GetEventsResponse> GetEvents(string? date = null, bool adult =
return await request<GetEventsResponse>("events", queryParams);
}

/// <summary>
/// Get additional information for an Event.
/// </summary>
/// <param name="id">The Event id.</param>
/// <param name="start">The starting year for returned occurrences.</param>
/// <param name="end">The ending year for returned occurrences.</param>
/// <returns>The Event information.</returns>
/// <exception cref="ArgumentException">Thrown when the event id is missing or empty.</exception>
public async Task<GetEventInfoResponse> GetEventInfo(string id, int? start = null, int? end = null) {
if (String.IsNullOrEmpty(id))
throw new ArgumentException("Event id is required.");
Expand All @@ -52,6 +72,13 @@ public async Task<GetEventInfoResponse> GetEventInfo(string id, int? start = nul
return await request<GetEventInfoResponse>("event", queryParams);
}

/// <summary>
/// Searches for Events with the given criteria
/// </summary>
/// <param name="query">Your search query</param>
/// <param name="adult">Whether or not adult events should be included.</param>
/// <returns>The search results.</returns>
/// <exception cref="ArgumentException">Thrown when the search query is missing or empty.</exception>
public async Task<SearchResponse> Search(string query, bool adult = false) {
if (String.IsNullOrEmpty(query))
throw new ArgumentException("Search query is required.");
Expand Down
16 changes: 13 additions & 3 deletions HolidayEventApi/HolidayEventApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.0-beta</Version>
<Version>1.0.0</Version>
<LangVersion>8.0</LangVersion>
<RootNamespace>HolidayEventApi</RootNamespace>
<Nullable>enable</Nullable>
Expand All @@ -12,20 +12,30 @@
<PackageTags>dotnet;holiday;holidays;public;federal;official;unofficial;date;month;year;day;calendar;api;holidayapi;list;event;occurrence;celebration;description;details;checkiday;international;national;world;popular;trusted;accurate;free;best</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/westy92/holiday-event-api-csharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/westy92/holiday-event-api-csharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2022 Westy92 LLC</Copyright>

<!-- Include symbol files (*.pdb) in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<!-- Source Link (https://github.com/dotnet/sourcelink) -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
<None Include="../README.md" pack="true" PackagePath="." />
<None Include="../LICENSE" pack="true" PackagePath="." />
<None Include="../icon.png" pack="true" PackagePath="." />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# The Official Holiday and Event API for .NET

[![Nuget](https://img.shields.io/nuget/v/HolidayEventApi)](https://www.nuget.org/packages/HolidayEventApi)
[![Build Status](https://github.com/westy92/holiday-event-api-csharp/actions/workflows/github-actions.yml/badge.svg)](https://github.com/westy92/holiday-event-api-csharp/actions)
[![Code Coverage](https://codecov.io/gh/westy92/holiday-event-api-csharp/branch/main/graph/badge.svg)](https://codecov.io/gh/westy92/holiday-event-api-csharp)
[![Funding Status](https://img.shields.io/github/sponsors/westy92)](https://github.com/sponsors/westy92)
Expand All @@ -16,7 +17,7 @@ Access to the Holiday and Event API requires an API Key. You can get for one for
## Installation

```console
$ TODO
$ dotnet add package HolidayEventApi
```

## Example
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d73d09c

Please sign in to comment.