-
Notifications
You must be signed in to change notification settings - Fork 12
/
allowlists.go
61 lines (50 loc) · 1.85 KB
/
allowlists.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
package clerk
import "net/http"
type AllowlistsService service
type AllowlistIdentifierResponse struct {
Object string `json:"object"`
ID string `json:"id"`
InvitationID string `json:"invitation_id,omitempty"`
Identifier string `json:"identifier"`
IdentifierType string `json:"identifier_type"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type CreateAllowlistIdentifierParams struct {
Identifier string `json:"identifier"`
Notify bool `json:"notify"`
}
func (s *AllowlistsService) CreateIdentifier(params CreateAllowlistIdentifierParams) (*AllowlistIdentifierResponse, error) {
req, _ := s.client.NewRequest(http.MethodPost, AllowlistsUrl, ¶ms)
var allowlistIdentifierResponse AllowlistIdentifierResponse
_, err := s.client.Do(req, &allowlistIdentifierResponse)
if err != nil {
return nil, err
}
return &allowlistIdentifierResponse, nil
}
func (s *AllowlistsService) DeleteIdentifier(identifierID string) (*DeleteResponse, error) {
req, _ := s.client.NewRequest(http.MethodDelete, AllowlistsUrl+"/"+identifierID)
var deleteResponse DeleteResponse
_, err := s.client.Do(req, &deleteResponse)
if err != nil {
return nil, err
}
return &deleteResponse, nil
}
type AllowlistIdentifiersResponse struct {
Data []*AllowlistIdentifierResponse `json:"data"`
TotalCount int64 `json:"total_count"`
}
func (s *AllowlistsService) ListAllIdentifiers() (*AllowlistIdentifiersResponse, error) {
req, _ := s.client.NewRequest(http.MethodGet, AllowlistsUrl)
var allowlistIdentifiersResponse []*AllowlistIdentifierResponse
_, err := s.client.Do(req, &allowlistIdentifiersResponse)
if err != nil {
return nil, err
}
return &AllowlistIdentifiersResponse{
Data: allowlistIdentifiersResponse,
TotalCount: int64(len(allowlistIdentifiersResponse)),
}, nil
}