func (c *Client) Do(ctx context.Context, r *http.Request, v interface{}) (*http.Response, error) {
	ctx, cancelFunc := context.WithTimeout(ctx, 6*time.Second)
	r = r.WithContext(ctx)
	defer cancelFunc()

	resp, err := c.client.Do(r)
	if err != nil {
		if ctx.Err() == context.DeadlineExceeded {
			err = &apitypes.Error{
				StatusCode: http.StatusRequestTimeout,
				Type:       "request_timeout",
				Err:        []string{"Request timed out"},
			}
		}

		return nil, err
	}

	defer resp.Body.Close()

	err = checkResponseCode(resp)
	if err != nil {
		return resp, err
	}

	if v != nil {
		dec := json.NewDecoder(resp.Body)
		err = dec.Decode(v)
		if err != nil {
			return nil, err
		}
	}

	return resp, nil
}
// Do executes an http.Request, populating v with the JSON response
// on success.
//
// If the request errors with a JSON formatted response body, it will be
// unmarshaled into the returned error.
Do executes an http.Request, populating v with the JSON response
on success.

If the request errors with a JSON formatted response body, it will be
unmarshaled into the returned error.
// Do executes an http . Request populating v with the JSON response // on success . // // If the request errors with a JSON formatted response body it will be // unmarshaled into the returned error .
func (c *Client) Do(ctx context.Context, r *http.Request, v interface{}) (*http.Response, error) {
	ctx, cancelFunc := context.WithTimeout(ctx, 6*time.Second)
	r = r.WithContext(ctx)
	defer cancelFunc()
	resp, err := c.client.Do(r)
	if err != nil {
		if ctx.Err() == context.DeadlineExceeded {
			err = &apitypes.Error{
				StatusCode: http.StatusRequestTimeout,
				Type:       "request_timeout",
				Err:        []string{"Request timed out"},
			}
		}
		return nil, err
	}
	defer resp.Body.Close()
	err = checkResponseCode(resp)
	if err != nil {
		return resp, err
	}
	if v != nil {
		dec := json.NewDecoder(resp.Body)
		err = dec.Decode(v)
		if err != nil {
			return nil, err
		}
	}
	return resp, nil
}
func ( c * Client ) Do ( ctx context . Context , r * http . Request , v interface { } ) ( * http . Response , error ) { ctx , cancelFunc := context . WithTimeout ( ctx , 6 * time . Second ) r = r . WithContext ( ctx ) defer cancelFunc ( ) resp , err := c . client . Do ( r ) if err != nil { if ctx . Err ( ) == context . DeadlineExceeded { err = & apitypes . Error { StatusCode : http . StatusRequestTimeout , Type : " " , Err : [ ] string { " " } , } } return nil , err } defer resp . Body . Close ( ) err = checkResponseCode ( resp ) if err != nil { return resp , err } if v != nil { dec := json . NewDecoder ( resp . Body ) err = dec . Decode ( v ) if err != nil { return nil , err } } return resp , nil }
Do executes an http.Request, populating v with the JSON response
on success.
Do executes an http . Request populating v with the JSON response on success .