github.com/clerkinc/clerk-sdk-go@v1.49.1/clerk/blocklists.go (about) 1 package clerk 2 3 import ( 4 "net/http" 5 ) 6 7 type BlocklistsService service 8 9 type BlocklistIdentifierResponse struct { 10 Object string `json:"object"` 11 ID string `json:"id"` 12 Identifier string `json:"identifier"` 13 IdentifierType string `json:"identifier_type"` 14 CreatedAt int64 `json:"created_at"` 15 UpdatedAt int64 `json:"updated_at"` 16 } 17 18 type CreateBlocklistIdentifierParams struct { 19 Identifier string `json:"identifier"` 20 } 21 22 func (s *BlocklistsService) CreateIdentifier(params CreateBlocklistIdentifierParams) (*BlocklistIdentifierResponse, error) { 23 req, _ := s.client.NewRequest(http.MethodPost, BlocklistsUrl, ¶ms) 24 25 var blocklistIdentifierResponse BlocklistIdentifierResponse 26 _, err := s.client.Do(req, &blocklistIdentifierResponse) 27 if err != nil { 28 return nil, err 29 } 30 return &blocklistIdentifierResponse, nil 31 } 32 33 func (s *BlocklistsService) DeleteIdentifier(identifierID string) (*DeleteResponse, error) { 34 req, _ := s.client.NewRequest(http.MethodDelete, BlocklistsUrl+"/"+identifierID) 35 36 var deleteResponse DeleteResponse 37 _, err := s.client.Do(req, &deleteResponse) 38 if err != nil { 39 return nil, err 40 } 41 return &deleteResponse, nil 42 } 43 44 type BlocklistIdentifiersResponse struct { 45 Data []*BlocklistIdentifierResponse `json:"data"` 46 TotalCount int64 `json:"total_count"` 47 } 48 49 func (s *BlocklistsService) ListAllIdentifiers() (*BlocklistIdentifiersResponse, error) { 50 req, _ := s.client.NewRequest(http.MethodGet, BlocklistsUrl) 51 52 var blocklistIdentifiersResponse *BlocklistIdentifiersResponse 53 _, err := s.client.Do(req, &blocklistIdentifiersResponse) 54 if err != nil { 55 return nil, err 56 } 57 return blocklistIdentifiersResponse, nil 58 }