mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 23:35:26 +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)
|
||||
|
||||
Reference in New Issue
Block a user