mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 07:15:25 +00:00
Public holidays API (#212)
This commit is contained in:
69
clients/go/holidays/holidays.go
Executable file
69
clients/go/holidays/holidays.go
Executable file
@@ -0,0 +1,69 @@
|
||||
package holidays
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewHolidaysService(token string) *HolidaysService {
|
||||
return &HolidaysService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type HolidaysService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
func (t *HolidaysService) Countries(request *CountriesRequest) (*CountriesResponse, error) {
|
||||
rsp := &CountriesResponse{}
|
||||
return rsp, t.client.Call("holidays", "Countries", request, rsp)
|
||||
}
|
||||
|
||||
//
|
||||
func (t *HolidaysService) List(request *ListRequest) (*ListResponse, error) {
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("holidays", "List", request, rsp)
|
||||
}
|
||||
|
||||
type CountriesRequest struct {
|
||||
}
|
||||
|
||||
type CountriesResponse struct {
|
||||
Countries []Country `json:"countries"`
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||
Code string `json:"code"`
|
||||
// The English name of the country
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Holiday struct {
|
||||
// the country this holiday occurs in
|
||||
CountryCode string `json:"countryCode"`
|
||||
// date of the holiday in yyyy-mm-dd format
|
||||
Date string `json:"date"`
|
||||
// the local name of the holiday
|
||||
LocalName string `json:"localName"`
|
||||
// the name of the holiday in English
|
||||
Name string `json:"name"`
|
||||
// the regions within the country that observe this holiday (if not all of them)
|
||||
Regions []string `json:"regions"`
|
||||
// the type of holiday Public, Bank, School, Authorities, Optional, Observance
|
||||
Types []string `json:"types"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||
CountryCode string `json:"countryCode"`
|
||||
// The year to list holidays for
|
||||
Year int64 `json:"year"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Holidays []Holiday `json:"holidays"`
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/micro/services/clients/go/forex"
|
||||
"github.com/micro/services/clients/go/geocoding"
|
||||
"github.com/micro/services/clients/go/helloworld"
|
||||
"github.com/micro/services/clients/go/holidays"
|
||||
"github.com/micro/services/clients/go/id"
|
||||
"github.com/micro/services/clients/go/image"
|
||||
"github.com/micro/services/clients/go/ip"
|
||||
@@ -52,6 +53,7 @@ func NewClient(token string) *Client {
|
||||
ForexService: forex.NewForexService(token),
|
||||
GeocodingService: geocoding.NewGeocodingService(token),
|
||||
HelloworldService: helloworld.NewHelloworldService(token),
|
||||
HolidaysService: holidays.NewHolidaysService(token),
|
||||
IdService: id.NewIdService(token),
|
||||
ImageService: image.NewImageService(token),
|
||||
IpService: ip.NewIpService(token),
|
||||
@@ -91,6 +93,7 @@ type Client struct {
|
||||
ForexService *forex.ForexService
|
||||
GeocodingService *geocoding.GeocodingService
|
||||
HelloworldService *helloworld.HelloworldService
|
||||
HolidaysService *holidays.HolidaysService
|
||||
IdService *id.IdService
|
||||
ImageService *image.ImageService
|
||||
IpService *ip.IpService
|
||||
|
||||
@@ -87,7 +87,7 @@ type Result struct {
|
||||
// The associated arabic text
|
||||
Text string `json:"text"`
|
||||
// The related translations to the text
|
||||
Translations []Translation `json:"translations"`
|
||||
Translations []Interpretation `json:"translations"`
|
||||
// The unique verse id across the Quran
|
||||
VerseId int32 `json:"verseId"`
|
||||
// The verse key e.g 1:1
|
||||
@@ -161,7 +161,7 @@ type Verse struct {
|
||||
// The basic translation of the verse
|
||||
TranslatedText string `json:"translatedText"`
|
||||
// The alternative translations for the verse
|
||||
Translations []Translation `json:"translations"`
|
||||
Translations []Interpretation `json:"translations"`
|
||||
// The phonetic transliteration from arabic
|
||||
Transliteration string `json:"transliteration"`
|
||||
// The individual words within the verse (Ayah)
|
||||
|
||||
64
clients/ts/holidays/index.ts
Executable file
64
clients/ts/holidays/index.ts
Executable 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[];
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user