-
Notifications
You must be signed in to change notification settings - Fork 19
/
clients.go
50 lines (41 loc) · 1.33 KB
/
clients.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
package clerk
import "fmt"
type ClientsService service
type ClientResponse struct {
Object string `json:"object"`
ID string `json:"id"`
LastActiveSessionID *string `json:"last_active_session_id"`
SessionIDs []string `json:"session_ids"`
Sessions []*Session `json:"sessions"`
SignInAttemptID *string `json:"sign_in_attempt_id"`
SignUpAttemptID *string `json:"sign_up_attempt_id"`
Ended bool `json:"ended"`
}
func (s *ClientsService) ListAll() ([]ClientResponse, error) {
clientsUrl := "clients"
req, _ := s.client.NewRequest("GET", clientsUrl)
var clients []ClientResponse
_, err := s.client.Do(req, &clients)
if err != nil {
return nil, err
}
return clients, nil
}
func (s *ClientsService) Read(clientId string) (*ClientResponse, error) {
clientUrl := fmt.Sprintf("%s/%s", ClientsUrl, clientId)
req, _ := s.client.NewRequest("GET", clientUrl)
var clientResponse ClientResponse
_, err := s.client.Do(req, &clientResponse)
if err != nil {
return nil, err
}
return &clientResponse, nil
}
func (s *ClientsService) Verify(token string) (*ClientResponse, error) {
var clientResponse ClientResponse
err := doVerify(s.client, ClientsVerifyUrl, token, &clientResponse)
if err != nil {
return nil, err
}
return &clientResponse, nil
}