Helper method to build the request to the server.

@param path the path.
@param method the method.
@param params the parameters.
@return the request.
769724
protected HttpUriRequest setupRequest(final String path, final String method, final Map<String, Object> params) {
        final HttpUriRequest request = buildMethod(method, path, params);
        request.addHeader(new BasicHeader("Accept", "application/json"));
        request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));
        request.setHeader(new BasicHeader("Authorization", "Basic " + new String(Base64.encodeBase64((this.token + ":" + this.secret).getBytes()))));
        return request;
    }
43645
public function build(string $method, string $path, array $options): RequestInterface
    {
        $body = $options['body'] ?? null;

        $uri = $this->getUri(
            $path,
            $options['host'] ?? null,
            $options['query'] ?? []
        );

        $headers = $this->getHeaders(
            $options['headers'] ?? [],
            $body
        );

        return new Request($method, $uri, $headers, $body);
    }
177615
public function request($method, $path, $paramData)
    {
        if($method == 'get' && count($paramData) > 0) {
            $path = $path . '?' . http_build_query($paramData);
            $paramData=array();
        }
        $this->setSignature($path, $paramData);
        $req = $this->client->createRequest($method, $path, array());
        if($method == 'post' || $method == 'delete') {
            foreach ($paramData as $k => $v) {
                $req->setPostField($k, $v);
            }
        }
        try {
            $res = $req->send();
            return $res->json();
        } catch (\Guzzle\Common\Exception\RuntimeException $e) {
            echo $e->getResponse()->getBody();
        }
    }
1074648
public static Message create(final BandwidthClient client, final Map<String, Object> params) throws Exception {
        final String messageUri = client.getUserResourceUri(BandwidthConstants.MESSAGES_URI_PATH);
        final RestResponse response = client.post(messageUri, params);
    	final String messageId = response.getLocation().substring(client.getPath(messageUri).length() + 1);

        return get(client, messageId);
    }
175007
protected function newAPIRequest($method, $path, $parameters = [], $options = [])
    {
        $api_path = '/api/v1/' . $path;
        return $this->call($method, $api_path, $parameters, $options);
    }
1001962
@Deprecated
	public static String buildCall(final Method method, final Object[] parameters) {
		if (method == null) {
			throw new IllegalArgumentException("Parameter method can't be null");
		}

		return buildCall(method.getDeclaringClass().getSimpleName(), method.getName(), parameters, null).toString();
	}
818728
public ApiResponse apiRequest(HttpMethod method,
            Map<String, Object> params, Object data, String... segments) {
        ApiResponse response = null;
        try {
            response = httpRequest(method, ApiResponse.class, params, data,
                    segments);
            log.info("Client.apiRequest(): Response: " + response);
        } catch (HttpClientErrorException e) {
            log.error("Client.apiRequest(): HTTP error: "
                    + e.getLocalizedMessage());
            response = parse(e.getResponseBodyAsString(), ApiResponse.class);
            if ((response != null) && !isEmpty(response.getError())) {
                log.error("Client.apiRequest(): Response error: "
                        + response.getError());
                if (!isEmpty(response.getException())) {
                    log.error("Client.apiRequest(): Response exception: "
                            + response.getException());
                }
            }
        }
        return response;
    }
3730
private function _call($method, $path, $param, $header = false) {
    // Clear connection; Set timeout, and json header.
    $this->curl->resetConnection();

    // Set additional headers.
    if ($header) {
      foreach ($header as $name => $value) {
        $this->curl->setHeader($name, $value);
      }
    }

    // Make an API request to the GDAX server.
    if ($param) {
      // If the method is not GET, pass JSON in the request body.
      $payload = false;
      if ($method != 'GET') {
        $param = json_encode($param);
        $payload = true;
      }
      $this->curl->{strtolower($method)}("$this->api/$path", $param, $payload);
    } else {
      $this->curl->{strtolower($method)}("$this->api/$path");
    }

    // TODO: Move error logs out of class. ~: Monolog
    // Error Logging
    if ($this->curl->error) {
      $this->_error[] = "$path: {$this->curl->error_message}";
      if ($this->_debug) {
        $this->_error[] = $this->_dump($path, $param);
      }
    }

    if (is_null($ret = json_decode($this->curl->response))) {
      throw new \Exception(__METHOD__ ." - Invalid JSON or null returned."); 
    }

    // Throw an exception on any returned messages from GDAX.
    if ($ret && isset($ret->message)) {
      throw new \Exception("API: $path-> ". $ret->message);
    }

    return $ret;
  }
200734
private Function<HttpRequestContext, String> createPathSubstitution(final String param, final AbstractMethod am) {
        int from = 0;
        int segment = -1;

        // Get the path from resource then from the method
        Path[] annotations = new Path[] { am.getResource().getAnnotation(Path.class), am.getAnnotation(Path.class) };

        for (Path annotation : annotations) {
            if (annotation == null)  {
                continue;
            }

            int index = getSubstitutionIndex(param, annotation.value());
            if (index >= 0) {
                segment = from + index;
            } else {
                from += -index;
            }
        }

        if (segment == -1) {
            throw new IllegalArgumentException("Param not found in path: " + param);
        }

        final int validatedSegment = segment;

        return new Function<HttpRequestContext, String>() {
            @Override
            public String apply(HttpRequestContext request) {
                return request.getPathSegments().get(validatedSegment).getPath();
            }
        };
    }
1105365
public Response get(String path, Map<String, String> params) throws IOException, RESTException {
        return get(path, params, null);
    }
803388
public static String doRequestWithUrl(String url, String method, Map<String, String> header, Map<String, String> params, String charset) throws IOException {
    HttpURLConnection conn = null;
    String rsp = null;

    try {
      String ctype = "application/json";
      String query = buildQuery(params, charset);
      try {
        conn = getConnection(buildGetUrl(url, query), method, header, ctype);
      } catch (IOException e) {
        throw e;
      }

      try {
        rsp = getResponseAsString(conn);
      } catch (IOException e) {
        throw e;
      }

    } finally {
      if (conn != null) {
        conn.disconnect();
      }
    }

    return rsp;
  }
1122005
public static RequestBuilder newRequest(String method, String url) {
        return new RequestBuilder().method(method).url(url);
    }
358923
public HttpPost createPostMethod(final String path, final Map<String, List<String>> params) {
        return new HttpPost(repositoryURL + path + queryString(params));
    }
1164680
public RequestBuilder request(HttpMethod method, String url) {
        return request(method.asString(), url);
    }
807490
def request(method, path, params={})
      headers = @default_headers.merge({'Authorization' => "Bearer #{@access_token}"})
      result = http_client.send_request(method, path, {
        :params  => params,
        :headers => headers
      })
      result
    end
605478
def request(method, path, options, &block)
      response = connection(options).send(method) do |request|
        block.call(request) if block_given?
        request.url(path)
      end
      response.body
    end
1206359
def request(method, path, options = {})
      options = options.dup

      raw = raw? || options.delete(:raw)
      params(options)
      response = connection.send method, path, (@raw_body || @params), @headers
      raw ? response : @scopeable.parse(response)
    end