-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinvites.go
More file actions
51 lines (44 loc) · 983 Bytes
/
invites.go
File metadata and controls
51 lines (44 loc) · 983 Bytes
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
package doppler
import (
"encoding/json"
"net/http"
"strconv"
)
type Invites struct {
Invites []Invite `json:"invites"`
Success bool `json:"success"`
}
type Invite struct {
Slug string `json:"slug"`
Email string `json:"email"`
CreatedAt string `json:"created_at"`
WorkplaceRole WorkplaceRole `json:"workplace_role"`
}
func (dp *Doppler) ListInvites(page, limit *int) (*Invites, error) {
defaultLimit := 20
defaultPage := 1
if page == nil || *page <= 0 {
page = &defaultPage
}
if limit == nil || *limit <= 0 {
limit = &defaultLimit
}
request, err := http.NewRequest(
http.MethodGet,
"/v3/workplace/invites?page="+strconv.Itoa(*page)+"&per_page="+strconv.Itoa(*limit),
nil,
)
if err != nil {
return nil, err
}
body, err := dp.makeApiRequest(request)
if err != nil {
return nil, err
}
data := &Invites{}
err = json.Unmarshal(body, data)
if err != nil {
return nil, err
}
return data, nil
}