-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtimezone.go
44 lines (35 loc) · 937 Bytes
/
timezone.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
package mailerlite
import (
"context"
"net/http"
)
const timezoneEndpoint = "/timezones"
// TimezoneService defines an interface for timezone-related operations.
type TimezoneService interface {
List(ctx context.Context) (*RootTimezones, *Response, error)
}
type timezoneService struct {
*service
}
type RootTimezones struct {
Data []Timezone `json:"data"`
}
type Timezone struct {
Id string `json:"id"`
Name string `json:"name"`
NameForHumans string `json:"name_for_humans"`
OffsetName string `json:"offset_name"`
Offset int `json:"offset"`
}
func (s *timezoneService) List(ctx context.Context) (*RootTimezones, *Response, error) {
req, err := s.client.newRequest(http.MethodGet, timezoneEndpoint, nil)
if err != nil {
return nil, nil, err
}
root := new(RootTimezones)
res, err := s.client.do(ctx, req, root)
if err != nil {
return nil, res, err
}
return root, res, nil
}