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[];
}

View File

@@ -10,6 +10,7 @@ import * as file from "./file";
import * as forex from "./forex";
import * as geocoding from "./geocoding";
import * as helloworld from "./helloworld";
import * as holidays from "./holidays";
import * as id from "./id";
import * as image from "./image";
import * as ip from "./ip";
@@ -46,6 +47,7 @@ export class Client {
this.forexService = new forex.ForexService(token);
this.geocodingService = new geocoding.GeocodingService(token);
this.helloworldService = new helloworld.HelloworldService(token);
this.holidaysService = new holidays.HolidaysService(token);
this.idService = new id.IdService(token);
this.imageService = new image.ImageService(token);
this.ipService = new ip.IpService(token);
@@ -81,6 +83,7 @@ export class Client {
forexService: forex.ForexService;
geocodingService: geocoding.GeocodingService;
helloworldService: helloworld.HelloworldService;
holidaysService: holidays.HolidaysService;
idService: id.IdService;
imageService: image.ImageService;
ipService: ip.IpService;

View File

@@ -21,6 +21,7 @@
"./forex": "./dist/forex/index.js",
"./geocoding": "./dist/geocoding/index.js",
"./helloworld": "./dist/helloworld/index.js",
"./holidays": "./dist/holidays/index.js",
"./id": "./dist/id/index.js",
"./image": "./dist/image/index.js",
"./ip": "./dist/ip/index.js",
@@ -59,5 +60,5 @@
},
"type": "module",
"types": "dist/index.d.ts",
"version": "1.0.521"
"version": "1.0.522"
}

View File

@@ -87,7 +87,7 @@ export interface Result {
// The associated arabic text
text?: string;
// The related translations to the text
translations?: Translation[];
translations?: Interpretation[];
// The unique verse id across the Quran
verseId?: number;
// The verse key e.g 1:1
@@ -149,7 +149,7 @@ export interface Verse {
// The unique id of the verse in the whole book
id?: number;
// The interpretations of the verse
interpretations?: Translation[];
interpretations?: Interpretation[];
// The key of this verse (chapter:verse) e.g 1:1
key?: string;
// The verse number in this chapter
@@ -161,7 +161,7 @@ export interface Verse {
// The basic translation of the verse
translatedText?: string;
// The alternative translations for the verse
translations?: Translation[];
translations?: Interpretation[];
// The phonetic transliteration from arabic
transliteration?: string;
// The individual words within the verse (Ayah)