// Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value
// pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface,
// the raw response will be written to v, without attempting to decode it.
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value
pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface,
the raw response will be written to v, without attempting to decode it.
// Do sends an API request and returns the API response . The API response is JSON decoded and stored in the value // pointed to by v or returned as an error if an API error has occurred . If v implements the io . Writer interface // the raw response will be written to v without attempting to decode it .
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error) {
	resp, err := DoRequestWithClient(ctx, c.client, req)
	if err != nil {
		return nil, err
	}
	if c.onRequestCompleted != nil {
		c.onRequestCompleted(req, resp)
	}
	defer func() {
		if rerr := resp.Body.Close(); err == nil {
			err = rerr
		}
	}()
	response := newResponse(resp)
	err = CheckResponse(resp)
	if err != nil {
		return response, err
	}
	if v != nil {
		if w, ok := v.(io.Writer); ok {
			_, err = io.Copy(w, resp.Body)
			if err != nil {
				return nil, err
			}
		} else {
			err = json.NewDecoder(resp.Body).Decode(v)
			if err != nil {
				return nil, err
			}
		}
	}
	return response, err
}
func ( c * Client ) Do ( ctx context . Context , req * http . Request , v interface { } ) ( * Response , error ) { resp , err := DoRequestWithClient ( ctx , c . client , req ) if err != nil { return nil , err } if c . onRequestCompleted != nil { c . onRequestCompleted ( req , resp ) } defer func ( ) { if rerr := resp . Body . Close ( ) ; err == nil { err = rerr } } ( ) response := newResponse ( resp ) err = CheckResponse ( resp ) if err != nil { return response , err } if v != nil { if w , ok := v . ( io . Writer ) ; ok { _ , err = io . Copy ( w , resp . Body ) if err != nil { return nil , err } } else { err = json . NewDecoder ( resp . Body ) . Decode ( v ) if err != nil { return nil , err } } } return response , err }
Do sends an API request and returns the API response.
Do sends an API request and returns the API response .