@@ -9,7 +9,7 @@ package api
99import (
1010 "context"
1111 "fmt"
12- _http "net/http"
12+ "net/http"
1313 "reflect"
1414 "strings"
1515
@@ -24,18 +24,18 @@ import (
2424const requiredFieldError = "no value given for required property"
2525
2626// IsCallSuccessful determines whether an API response is successful or not
27- func IsCallSuccessful (r * _http .Response ) bool {
27+ func IsCallSuccessful (r * http .Response ) bool {
2828 if r == nil {
2929 return false
3030 }
31- return r .StatusCode >= _http .StatusOK && r .StatusCode < _http .StatusMultipleChoices
31+ return r .StatusCode >= http .StatusOK && r .StatusCode < http .StatusMultipleChoices
3232}
3333
3434// CheckAPICallSuccess verifies whether an API response is successful or not and if not, populates an error with all the information needed.
3535// errorContext corresponds to the description of what led to the error if error there is e.g. `Failed adding a user`.
3636// resp corresponds to the HTTP response from a certain endpoint. The body of such response is not closed by this function.
3737// apiErr corresponds to the error which may be returned by the HTTP client when calling the endpoint.
38- func CheckAPICallSuccess (ctx context.Context , errorContext string , resp * _http .Response , apiErr error ) (err error ) {
38+ func CheckAPICallSuccess (ctx context.Context , errorContext string , resp * http .Response , apiErr error ) (err error ) {
3939 err = parallelisation .DetermineContextError (ctx )
4040 if err != nil {
4141 return
@@ -67,7 +67,7 @@ func CheckAPICallSuccess(ctx context.Context, errorContext string, resp *_http.R
6767// CallAndCheckSuccess is a wrapper for making an API call and then checking success with `CheckAPICallSuccess`
6868// errorContext corresponds to the description of what led to the error if error there is e.g. `Failed adding a user`.
6969// apiCallFunc corresponds to a generic function that will be called to make the API call
70- func CallAndCheckSuccess [T any ](ctx context.Context , errorContext string , apiCallFunc func (ctx context.Context ) (* T , * _http .Response , error )) (result * T , err error ) {
70+ func CallAndCheckSuccess [T any ](ctx context.Context , errorContext string , apiCallFunc func (ctx context.Context ) (* T , * http .Response , error )) (result * T , err error ) {
7171 if err = parallelisation .DetermineContextError (ctx ); err != nil {
7272 return
7373 }
@@ -99,7 +99,7 @@ func CallAndCheckSuccess[T any](ctx context.Context, errorContext string, apiCal
9999 return
100100}
101101
102- func checkResponseMarshalling (ctx context.Context , apiErr error , resp * _http .Response , result any ) (err error ) {
102+ func checkResponseMarshalling (ctx context.Context , apiErr error , resp * http .Response , result any ) (err error ) {
103103 if apiErr != nil {
104104 err = commonerrors .WrapError (commonerrors .ErrMarshalling , apiErr , "API call was successful but an error occurred during response marshalling" )
105105 if commonerrors .CorrespondTo (apiErr , requiredFieldError ) {
@@ -128,7 +128,7 @@ func checkResponseMarshalling(ctx context.Context, apiErr error, resp *_http.Res
128128// T must be an interface.
129129// errorContext corresponds to the description of what led to the error if error there is e.g. `Failed adding a user`.
130130// apiCallFunc corresponds to a generic function that will be called to make the API call
131- func GenericCallAndCheckSuccess [T any ](ctx context.Context , errorContext string , apiCallFunc func (ctx context.Context ) (T , * _http .Response , error )) (result T , err error ) {
131+ func GenericCallAndCheckSuccess [T any ](ctx context.Context , errorContext string , apiCallFunc func (ctx context.Context ) (T , * http .Response , error )) (result T , err error ) {
132132 if err = parallelisation .DetermineContextError (ctx ); err != nil {
133133 return
134134 }
0 commit comments