|
9 | 9 | "net/http" |
10 | 10 | "time" |
11 | 11 |
|
12 | | - "github.com/deploymenttheory/go-api-http-client/errors" |
13 | 12 | "github.com/deploymenttheory/go-api-http-client/logger" |
14 | 13 | "go.uber.org/zap" |
15 | 14 | ) |
@@ -40,21 +39,21 @@ func (c *Client) ObtainToken(log logger.Logger) error { |
40 | 39 |
|
41 | 40 | req, err := http.NewRequest("POST", authenticationEndpoint, nil) |
42 | 41 | if err != nil { |
43 | | - log.Error("Failed to create new request for token", zap.Error(err)) |
| 42 | + log.LogError("POST", authenticationEndpoint, 0, err, "Failed to create new request for token") |
44 | 43 | return err |
45 | 44 | } |
46 | 45 | req.SetBasicAuth(c.BearerTokenAuthCredentials.Username, c.BearerTokenAuthCredentials.Password) |
47 | 46 |
|
48 | 47 | resp, err := c.httpClient.Do(req) |
49 | 48 | if err != nil { |
50 | | - log.Error("Failed to make request for token", zap.Error(err)) |
| 49 | + log.LogError("POST", authenticationEndpoint, 0, err, "Failed to make request for token") |
51 | 50 | return err |
52 | 51 | } |
53 | 52 | defer resp.Body.Close() |
54 | 53 |
|
55 | 54 | if resp.StatusCode != http.StatusOK { |
56 | | - log.Warn("Received non-OK response while obtaining token", zap.Int("StatusCode", resp.StatusCode)) |
57 | | - return errors.HandleAPIError(resp, log) |
| 55 | + log.Error("Received non-OK response while obtaining token", zap.Int("StatusCode", resp.StatusCode)) |
| 56 | + return err |
58 | 57 | } |
59 | 58 |
|
60 | 59 | tokenResp := &TokenResponse{} |
@@ -101,7 +100,7 @@ func (c *Client) RefreshToken(log logger.Logger) error { |
101 | 100 |
|
102 | 101 | if resp.StatusCode != http.StatusOK { |
103 | 102 | log.Warn("Token refresh response status is not OK", zap.Int("StatusCode", resp.StatusCode)) |
104 | | - return errors.HandleAPIError(resp, log) |
| 103 | + return err |
105 | 104 | } |
106 | 105 |
|
107 | 106 | tokenResp := &TokenResponse{} |
|
0 commit comments