func (api *API) do(req *http.Request) (body io.ReadCloser, statusCode int, err error) {
	req.Header.Set("Content-Type", "application/json")
	if api.ticket != nil {
		req.Header.Set(ticket.TicketHeader, api.ticket.ID)
	}
	if api.jwt != "" {
		if IsJWTTokenExpired(api.jwt) {
			jwtToken, err := GenerateJWTToken(api.address.Hash(), *api.key)
			if err != nil {
				return nil, 0, err
			}

			api.jwt = jwtToken
		}
		req.Header.Set("Authorization", "Bearer "+api.jwt)
	}

	resp, err := api.client.Do(req)
	if err != nil {
		return nil, 0, err
	}

	// Call the error function if there was an error
	if resp.StatusCode >= 400 && api.errorFunc != nil {
		api.errorFunc(req, resp)
	}

	return resp.Body, resp.StatusCode, nil
}
// do does the actual request and returns body reader, status code and error
do does the actual request and returns body reader, status code and error
// do does the actual request and returns body reader status code and error
func (api *API) do(req *http.Request) (body io.ReadCloser, statusCode int, err error) {
	req.Header.Set("Content-Type", "application/json")
	if api.ticket != nil {
		req.Header.Set(ticket.TicketHeader, api.ticket.ID)
	}
	if api.jwt != "" {
		if IsJWTTokenExpired(api.jwt) {
			jwtToken, err := GenerateJWTToken(api.address.Hash(), *api.key)
			if err != nil {
				return nil, 0, err
			}
			api.jwt = jwtToken
		}
		req.Header.Set("Authorization", "Bearer "+api.jwt)
	}
	resp, err := api.client.Do(req)
	if err != nil {
		return nil, 0, err
	}
	if resp.StatusCode >= 400 && api.errorFunc != nil {
		api.errorFunc(req, resp)
	}
	return resp.Body, resp.StatusCode, nil
}
func ( api * API ) do ( req * http . Request ) ( body io . ReadCloser , statusCode int , err error ) { req . Header . Set ( " " , " " ) if api . ticket != nil { req . Header . Set ( ticket . TicketHeader , api . ticket . ID ) } if api . jwt != " " { if IsJWTTokenExpired ( api . jwt ) { jwtToken , err := GenerateJWTToken ( api . address . Hash ( ) , * api . key ) if err != nil { return nil , 0 , err } api . jwt = jwtToken } req . Header . Set ( " " , " " + api . jwt ) } resp , err := api . client . Do ( req ) if err != nil { return nil , 0 , err } if resp . StatusCode >= 400 && api . errorFunc != nil { api . errorFunc ( req , resp ) } return resp . Body , resp . StatusCode , nil }
do does the actual request and returns body reader, status code and error
do does the actual request and returns body reader status code and error
// Call the error function if there was an error