func (p *clientRequest) Do(method string, body interface{}) (*http.Response, error) {
	var reader io.Reader
	if !p.authenticated() {
		return nil, errAuthRequired
	}
	if _, ok := body.(io.Reader); !ok && body != nil {
		if r, err := jsonToReader(body); err == nil {
			reader = r
		}
	} else if ok {
		reader = body.(io.Reader)
	}
	for k, v := range p.params {
		p.endpoint = strings.Replace(p.endpoint, "{"+k+"}", v, -1)
	}
	endpoint := p.endpoint
	if len(p.queryParams) > 0 {
		endpoint = p.endpoint + "?" + p.queryParams.Encode()
	}
	req, err := http.NewRequest(method, endpoint, reader)
	if err != nil {
		return nil, err
	}
	if p.ctx != nil {
		req = req.WithContext(p.ctx)
	}
	if body != nil {
		if p.jsonBody {
			req.Header.Set("Content-Type", "application/json")
		} else {
			req.Header.Set("Content-Type", "application/octect-stream")
		}
	}
	req.SetBasicAuth(p.username, p.password)

	resp, err := httpClient.Do(req)
	if resp != nil {
		switch resp.StatusCode {
		case 401, 403:
			err = errAuthFailed
		case 404:
			err = ErrNotFound
		}
	} else if err != nil {
		err = errNetworkError
	}
	return resp, err
}
// Do makes an http request with method and body. If body is not nil and not
// a io.Reader, body is encoded to JSON.
Do makes an http request with method and body. If body is not nil and not
a io.Reader, body is encoded to JSON.
// Do makes an http request with method and body . If body is not nil and not // a io . Reader body is encoded to JSON .
func (p *clientRequest) Do(method string, body interface{}) (*http.Response, error) {
	var reader io.Reader
	if !p.authenticated() {
		return nil, errAuthRequired
	}
	if _, ok := body.(io.Reader); !ok && body != nil {
		if r, err := jsonToReader(body); err == nil {
			reader = r
		}
	} else if ok {
		reader = body.(io.Reader)
	}
	for k, v := range p.params {
		p.endpoint = strings.Replace(p.endpoint, "{"+k+"}", v, -1)
	}
	endpoint := p.endpoint
	if len(p.queryParams) > 0 {
		endpoint = p.endpoint + "?" + p.queryParams.Encode()
	}
	req, err := http.NewRequest(method, endpoint, reader)
	if err != nil {
		return nil, err
	}
	if p.ctx != nil {
		req = req.WithContext(p.ctx)
	}
	if body != nil {
		if p.jsonBody {
			req.Header.Set("Content-Type", "application/json")
		} else {
			req.Header.Set("Content-Type", "application/octect-stream")
		}
	}
	req.SetBasicAuth(p.username, p.password)
	resp, err := httpClient.Do(req)
	if resp != nil {
		switch resp.StatusCode {
		case 401, 403:
			err = errAuthFailed
		case 404:
			err = ErrNotFound
		}
	} else if err != nil {
		err = errNetworkError
	}
	return resp, err
}
func ( p * clientRequest ) Do ( method string , body interface { } ) ( * http . Response , error ) { var reader io . Reader if ! p . authenticated ( ) { return nil , errAuthRequired } if _ , ok := body . ( io . Reader ) ; ! ok && body != nil { if r , err := jsonToReader ( body ) ; err == nil { reader = r } } else if ok { reader = body . ( io . Reader ) } for k , v := range p . params { p . endpoint = strings . Replace ( p . endpoint , " " + k + " " , v , - 1 ) } endpoint := p . endpoint if len ( p . queryParams ) > 0 { endpoint = p . endpoint + " " + p . queryParams . Encode ( ) } req , err := http . NewRequest ( method , endpoint , reader ) if err != nil { return nil , err } if p . ctx != nil { req = req . WithContext ( p . ctx ) } if body != nil { if p . jsonBody { req . Header . Set ( " " , " " ) } else { req . Header . Set ( " " , " " ) } } req . SetBasicAuth ( p . username , p . password ) resp , err := httpClient . Do ( req ) if resp != nil { switch resp . StatusCode { case 401 , 403 : err = errAuthFailed case 404 : err = ErrNotFound } } else if err != nil { err = errNetworkError } return resp , err }
Do makes an http request with method and body.
Do makes an http request with method and body .