Public holidays API (#212)

This commit is contained in:
Dominic Wong
2021-09-21 18:51:19 +01:00
committed by GitHub
parent 09b06bd66f
commit 33653f7698
29 changed files with 1816 additions and 7 deletions

64
clients/ts/holidays/index.ts Executable file
View File

@@ -0,0 +1,64 @@
import * as m3o from "@m3o/m3o-node";
export class HolidaysService {
private client: m3o.Client;
constructor(token: string) {
this.client = new m3o.Client({ token: token });
}
//
countries(request: CountriesRequest): Promise<CountriesResponse> {
return this.client.call(
"holidays",
"Countries",
request
) as Promise<CountriesResponse>;
}
//
list(request: ListRequest): Promise<ListResponse> {
return this.client.call(
"holidays",
"List",
request
) as Promise<ListResponse>;
}
}
export interface CountriesRequest {}
export interface CountriesResponse {
countries?: Country[];
}
export interface Country {
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
code?: string;
// The English name of the country
name?: string;
}
export interface Holiday {
// the country this holiday occurs in
countryCode?: string;
// date of the holiday in yyyy-mm-dd format
date?: string;
// the local name of the holiday
localName?: string;
// the name of the holiday in English
name?: string;
// the regions within the country that observe this holiday (if not all of them)
regions?: string[];
// the type of holiday Public, Bank, School, Authorities, Optional, Observance
types?: string[];
}
export interface ListRequest {
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
countryCode?: string;
// The year to list holidays for
year?: number;
}
export interface ListResponse {
holidays?: Holiday[];
}