refactor: streamline response handling by introducing readResponseBody utility
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 22s

This commit is contained in:
2025-06-25 12:43:11 -04:00
parent f68538e66f
commit 51e03632ed
4 changed files with 32 additions and 25 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"gitea.siteworxpro.com/golang-packages/email-api-client/redis"
"io"
"net/http"
"time"
)
@@ -53,16 +52,7 @@ func getToken(configuration *Configuration) (*Token, error) {
return nil, errors.New("Failed to retrieve access token: " + resp.Status)
}
defer func(Body io.ReadCloser) {
_ = Body.Close()
}(resp.Body)
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(responseBody, token)
token, err = readResponseBody[Token](resp)
if err != nil {
return nil, err
}