diff --git a/clients/go/m3o.go b/clients/go/m3o.go index 6d8f4ae..4cd5c97 100755 --- a/clients/go/m3o.go +++ b/clients/go/m3o.go @@ -20,6 +20,7 @@ import ( "github.com/micro/services/clients/go/location" "github.com/micro/services/clients/go/otp" "github.com/micro/services/clients/go/postcode" + "github.com/micro/services/clients/go/prayer" "github.com/micro/services/clients/go/qr" "github.com/micro/services/clients/go/quran" "github.com/micro/services/clients/go/routing" @@ -60,6 +61,7 @@ func NewClient(token string) *Client { LocationService: location.NewLocationService(token), OtpService: otp.NewOtpService(token), PostcodeService: postcode.NewPostcodeService(token), + PrayerService: prayer.NewPrayerService(token), QrService: qr.NewQrService(token), QuranService: quran.NewQuranService(token), RoutingService: routing.NewRoutingService(token), @@ -100,6 +102,7 @@ type Client struct { LocationService *location.LocationService OtpService *otp.OtpService PostcodeService *postcode.PostcodeService + PrayerService *prayer.PrayerService QrService *qr.QrService QuranService *quran.QuranService RoutingService *routing.RoutingService diff --git a/clients/go/prayer/prayer.go b/clients/go/prayer/prayer.go new file mode 100755 index 0000000..053ed01 --- /dev/null +++ b/clients/go/prayer/prayer.go @@ -0,0 +1,69 @@ +package prayer + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewPrayerService(token string) *PrayerService { + return &PrayerService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type PrayerService struct { + client *client.Client +} + +// +func (t *PrayerService) Times(request *TimesRequest) (*TimesResponse, error) { + rsp := &TimesResponse{} + return rsp, t.client.Call("prayer", "Times", request, rsp) +} + +type PrayerTime struct { + // asr time + Asr string `json:"asr"` + // date for prayer times in YYYY-MM-DD format + Date string `json:"date"` + // fajr time + Fajr string `json:"fajr"` + // isha time + Isha string `json:"isha"` + // maghrib time + Maghrib string `json:"maghrib"` + // time of sunrise + Sunrise string `json:"sunrise"` + // zuhr time + Zuhr string `json:"zuhr"` +} + +type TimesRequest struct { + // optional date in YYYY-MM-DD format, otherwise uses today + Date string `json:"date"` + // number of days to request times for + Days int32 `json:"days"` + // optional latitude used in place of location + Latitude float64 `json:"latitude"` + // location to retrieve prayer times for. + // this can be a specific address, city, etc + Location string `json:"location"` + // optional longitude used in place of location + Longitude float64 `json:"longitude"` +} + +type TimesResponse struct { + // date of request + Date string `json:"date"` + // number of days + Days int32 `json:"days"` + // latitude of location + Latitude float64 `json:"latitude"` + // location for the request + Location string `json:"location"` + // longitude of location + Longitude float64 `json:"longitude"` + // prayer times for the given location + Times []PrayerTime `json:"times"` +} diff --git a/clients/ts/index.ts b/clients/ts/index.ts index 34c8246..3522ec7 100755 --- a/clients/ts/index.ts +++ b/clients/ts/index.ts @@ -17,6 +17,7 @@ import * as ip from "./ip"; import * as location from "./location"; import * as otp from "./otp"; import * as postcode from "./postcode"; +import * as prayer from "./prayer"; import * as qr from "./qr"; import * as quran from "./quran"; import * as routing from "./routing"; @@ -54,6 +55,7 @@ export class Client { this.locationService = new location.LocationService(token); this.otpService = new otp.OtpService(token); this.postcodeService = new postcode.PostcodeService(token); + this.prayerService = new prayer.PrayerService(token); this.qrService = new qr.QrService(token); this.quranService = new quran.QuranService(token); this.routingService = new routing.RoutingService(token); @@ -90,6 +92,7 @@ export class Client { locationService: location.LocationService; otpService: otp.OtpService; postcodeService: postcode.PostcodeService; + prayerService: prayer.PrayerService; qrService: qr.QrService; quranService: quran.QuranService; routingService: routing.RoutingService; diff --git a/clients/ts/package.json b/clients/ts/package.json index 283f361..bf96038 100644 --- a/clients/ts/package.json +++ b/clients/ts/package.json @@ -29,6 +29,7 @@ "./otp": "./dist/otp/index.js", "./pkg": "./dist/pkg/index.js", "./postcode": "./dist/postcode/index.js", + "./prayer": "./dist/prayer/index.js", "./qr": "./dist/qr/index.js", "./quran": "./dist/quran/index.js", "./routing": "./dist/routing/index.js", @@ -60,5 +61,5 @@ }, "type": "module", "types": "dist/index.d.ts", - "version": "1.0.526" + "version": "1.0.527" } \ No newline at end of file diff --git a/clients/ts/prayer/index.ts b/clients/ts/prayer/index.ts new file mode 100755 index 0000000..673a2e2 --- /dev/null +++ b/clients/ts/prayer/index.ts @@ -0,0 +1,63 @@ +import * as m3o from "@m3o/m3o-node"; + +export class PrayerService { + private client: m3o.Client; + + constructor(token: string) { + this.client = new m3o.Client({ token: token }); + } + // + times(request: TimesRequest): Promise { + return this.client.call( + "prayer", + "Times", + request + ) as Promise; + } +} + +export interface PrayerTime { + // asr time + asr?: string; + // date for prayer times in YYYY-MM-DD format + date?: string; + // fajr time + fajr?: string; + // isha time + isha?: string; + // maghrib time + maghrib?: string; + // time of sunrise + sunrise?: string; + // zuhr time + zuhr?: string; +} + +export interface TimesRequest { + // optional date in YYYY-MM-DD format, otherwise uses today + date?: string; + // number of days to request times for + days?: number; + // optional latitude used in place of location + latitude?: number; + // location to retrieve prayer times for. + // this can be a specific address, city, etc + location?: string; + // optional longitude used in place of location + longitude?: number; +} + +export interface TimesResponse { + // date of request + date?: string; + // number of days + days?: number; + // latitude of location + latitude?: number; + // location for the request + location?: string; + // longitude of location + longitude?: number; + // prayer times for the given location + times?: PrayerTime[]; +} diff --git a/examples/prayer/times/curl/prayerTimes.sh b/examples/prayer/times/curl/prayerTimes.sh new file mode 100755 index 0000000..14e72b1 --- /dev/null +++ b/examples/prayer/times/curl/prayerTimes.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/prayer/Times" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "location": "london" +}' \ No newline at end of file diff --git a/examples/prayer/times/go/prayerTimes.go b/examples/prayer/times/go/prayerTimes.go new file mode 100755 index 0000000..4a7d806 --- /dev/null +++ b/examples/prayer/times/go/prayerTimes.go @@ -0,0 +1,16 @@ +package example + +import ( + "fmt" + "github.com/micro/services/clients/go/prayer" + "os" +) + +// +func PrayerTimes() { + prayerService := prayer.NewPrayerService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := prayerService.Times(&prayer.TimesRequest{ + Location: "london", + }) + fmt.Println(rsp, err) +} diff --git a/examples/prayer/times/node/prayerTimes.js b/examples/prayer/times/node/prayerTimes.js new file mode 100755 index 0000000..b1b6b63 --- /dev/null +++ b/examples/prayer/times/node/prayerTimes.js @@ -0,0 +1,12 @@ +import * as prayer from "m3o/prayer"; + +// +async function PrayerTimes() { + let prayerService = new prayer.PrayerService(process.env.MICRO_API_TOKEN); + let rsp = await prayerService.times({ + location: "london", + }); + console.log(rsp); +} + +await PrayerTimes();