-
Notifications
You must be signed in to change notification settings - Fork 20
/
blocklists.go
58 lines (47 loc) · 1.67 KB
/
blocklists.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
package clerk
import (
"net/http"
)
type BlocklistsService service
type BlocklistIdentifierResponse struct {
Object string `json:"object"`
ID string `json:"id"`
Identifier string `json:"identifier"`
IdentifierType string `json:"identifier_type"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type CreateBlocklistIdentifierParams struct {
Identifier string `json:"identifier"`
}
func (s *BlocklistsService) CreateIdentifier(params CreateBlocklistIdentifierParams) (*BlocklistIdentifierResponse, error) {
req, _ := s.client.NewRequest(http.MethodPost, BlocklistsUrl, ¶ms)
var blocklistIdentifierResponse BlocklistIdentifierResponse
_, err := s.client.Do(req, &blocklistIdentifierResponse)
if err != nil {
return nil, err
}
return &blocklistIdentifierResponse, nil
}
func (s *BlocklistsService) DeleteIdentifier(identifierID string) (*DeleteResponse, error) {
req, _ := s.client.NewRequest(http.MethodDelete, BlocklistsUrl+"/"+identifierID)
var deleteResponse DeleteResponse
_, err := s.client.Do(req, &deleteResponse)
if err != nil {
return nil, err
}
return &deleteResponse, nil
}
type BlocklistIdentifiersResponse struct {
Data []*BlocklistIdentifierResponse `json:"data"`
TotalCount int64 `json:"total_count"`
}
func (s *BlocklistsService) ListAllIdentifiers() (*BlocklistIdentifiersResponse, error) {
req, _ := s.client.NewRequest(http.MethodGet, BlocklistsUrl)
var blocklistIdentifiersResponse *BlocklistIdentifiersResponse
_, err := s.client.Do(req, &blocklistIdentifiersResponse)
if err != nil {
return nil, err
}
return blocklistIdentifiersResponse, nil
}