-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
prayer.go
executable file
·69 lines (62 loc) · 1.68 KB
/
prayer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
}
// Get the prayer (salah) times for a location on a given date
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"`
}