Me is func Client Me tenant string authHeader string string int error

 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
// Me is
func (c *Client) Me(tenant string, authHeader string) (string, int, error) {
request := goreq.Request{
Timeout: 5000 * time.Millisecond,
Method: "GET",
Uri: c.APIURL + "/" + tenant + "/api/v1/me",
Accept: "application/json",
}
request.AddHeader("Authorization", authHeader)
res, err := request.Do()
if err != nil {
return "", 500, err
}
bodyStr, _ := res.Body.ToString()
return bodyStr, res.StatusCode, nil
}
// MeWithKey is
func (c *Client) MeWithKey(tenant string, apiKey string) (string, int, error) {
request := goreq.Request{
Timeout: 5000 * time.Millisecond,
Method: "GET",
Uri: c.APIURL + "/" + tenant + "/api/v1/me",
Accept: "application/json",
}
request.AddHeader("API-Key", apiKey)
res, err := request.Do()
if err != nil {
return "", 500, err
}
bodyStr, _ := res.Body.ToString()
return bodyStr, res.StatusCode, nil
}