TokenIsValid calls the API to determine whether the token is valid.
()
| 76 | |
| 77 | // TokenIsValid calls the API to determine whether the token is valid. |
| 78 | func (c *Client) TokenIsValid() (bool, error) { |
| 79 | url := fmt.Sprintf("%s/validate_token", c.APIBaseURL) |
| 80 | req, err := c.NewRequest("GET", url, nil) |
| 81 | if err != nil { |
| 82 | return false, err |
| 83 | } |
| 84 | resp, err := c.Do(req) |
| 85 | if err != nil { |
| 86 | return false, err |
| 87 | } |
| 88 | defer resp.Body.Close() |
| 89 | |
| 90 | return resp.StatusCode == http.StatusOK, nil |
| 91 | } |
| 92 | |
| 93 | // IsPingable calls the API /ping to determine whether the API can be reached. |
| 94 | func (c *Client) IsPingable() error { |
no test coverage detected