From 3bdb51693f2fc77a1a793980d06d2632d4f26e50 Mon Sep 17 00:00:00 2001 From: nscuro Date: Thu, 9 Jun 2022 16:42:46 +0200 Subject: [PATCH] refactor: minor adjustments Signed-off-by: nscuro --- client.go | 10 +++++----- error.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 7e8bfbb..b45eabb 100644 --- a/client.go +++ b/client.go @@ -66,8 +66,8 @@ func NewClient(baseURL string, options ...ClientOption) (*Client, error) { } for _, option := range options { - if err := option(&client); err != nil { - return nil, err + if optionErr := option(&client); optionErr != nil { + return nil, optionErr } } @@ -174,8 +174,8 @@ func withBody(body interface{}) requestOption { } type Page[T any] struct { - Items []T - TotalCount int + Items []T // Items on this page + TotalCount int // Total number of items } type PageOptions struct { @@ -221,7 +221,7 @@ func (c Client) doRequest(req *http.Request, v interface{}) (a apiResponse, err log.Printf("received response:\n<<<<<<\n%s\n<<<<<<\n", string(resDump)) } - err = checkResponse(res) + err = checkResponseForError(res) if err != nil { return } diff --git a/error.go b/error.go index 59baa17..88ca6da 100644 --- a/error.go +++ b/error.go @@ -18,7 +18,7 @@ func (e APIError) Error() string { return fmt.Sprintf("%s (status: %d)", e.Message, e.StatusCode) } -func checkResponse(res *http.Response) error { +func checkResponseForError(res *http.Response) error { if res.StatusCode >= 200 && res.StatusCode < 300 { return nil }