-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckr.go
51 lines (43 loc) · 1.07 KB
/
checkr.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
package checkr
import (
"gopkg.in/resty.v1"
)
const checkrAPIURL = "https://api.checkr.com/v1"
// Client ...
type Client struct {
*resty.Client
}
// ErrorResponse ...
type ErrorResponse struct {
Error string `json:"error"`
}
// NewClient ...
func NewClient(apiKey string, apiURL ...string) *Client {
// Create Resty Client
r := resty.New()
// Basic Auth with API Key as Username and no password
// https://docs.checkr.com/#authentication
r.SetBasicAuth(apiKey, "")
// Use Default URL unless given API URL
if len(apiURL) > 0 {
r.SetHostURL(apiURL[0])
} else {
r.SetHostURL(checkrAPIURL)
}
return &Client{r}
}
// // Status returns error is API status response is not as expected
// func (c *Client) Status() error {
// // Handle Request
// resp, err := c.R().SetError(&ErrorResponse{}).Get("/status")
// if err != nil {
// return err
// }
// // Check for expected response
// if resp.StatusCode() != http.StatusOK {
// errResp := resp.Error().(*ErrorResponse)
// err = fmt.Errorf("Checkr Error: %s", errResp.Error)
// return err
// }
// return nil
// }