@param string $uri
@param array $data

@return \GuzzleHttp\Message\Response
359167
public function putRequest($uri, array $data = null)
    {
        return $this->getClient()->put($uri, [
            'json' => $this->createBody($data)
        ]);
    }
326851
private function restCall($uri, $data)
    {
        try {
            $client = new Client(['base_uri' => $this->baseUrl]);
            $response = $client->request('POST', $uri, ['json' => $data]);

            $rawBody = $response->getBody()->getContents();
            $body = json_decode($rawBody, true);
        } catch (RequestException $e) {
            $response = $e->getResponse();
            $rawBody = is_null($response) ? '{"Status":-98,"message":"http connection error"}' : $response->getBody()->getContents();
            $body = json_decode($rawBody, true);
        }

        if (!isset($result['Status'])) {
            $result['Status'] = -99;
        }

        return $body;
    }
27475
public function post($uri, $parameters = array())
    {
        return $this->request(self::METHOD_POST, $this->getUrl($uri), $parameters);
    }
1307643
public function getUri($data = null)
    {
        if (isset($data['uriData'])) {
            $this->uri = str_replace('{params}', implode('/', $data['uriData']), $this->uri);
        }

        return $this->uri;
    }
1113370
public function post($uri, array $data = [], array $headers = [])
    {
        $server = $this->transformHeadersToServerVars($headers);

        return $this->call('POST', $uri, $data, [], [], $server);
    }
1281929
public function redirect(string $url, $data = null)
    {
        return $this->response([
            'success' => true,
            'redirect' => $url,
            'data' => $data,
        ]);
    }
290633
public function post( $uri, array $params = array() )
    {
        $this->_client->setMethod('POST');
        return $this->_request($uri, $params);
    }
1353273
protected static function uri(string $name, array $data = [], $warnData = true) : Uri
    {
        return self::router()->getUri($name, $data, $warnData);
    }
29670
public function post($url, array $data, array $headers = null)
    {
        $headers = is_null($headers) ? ['Content-Type: application/json; charset=utf-8'] : $headers;
        return $this->sendRequest('POST', $url, $headers, $data);
    }
981783
protected function exec($method, $uri, $data, $content_type)
    {
        $connect = $this->getConnect($uri, $method, $content_type);
        if ($data) {
            $this->setData($connect, $data, $content_type);
        }

        $api_result = curl_exec($connect);
        $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
        $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME);

        $response = array(
            "status" => $api_http_code,
            "total_time" => $api_http_time,
        );

        if ($content_type == "application/json") {
            $response["response"] = json_decode($api_result, true);
        } elseif ($content_type == "text/html") {
            $response["response"] = $api_result;
        }

        if ($response['status'] >= 400) {
            throw new Exception($response['response'], $response['status']);
        }

        curl_close($connect);

        return $response;
    }
864789
public static function createFromArray($uri, array $data = [], ApiDefinition $apiDefinition = null)
    {
        $resource = new static($uri, $apiDefinition);

        if (isset($data['displayName'])) {
            $resource->setDisplayName($data['displayName']);
        } else {
            $resource->setDisplayName($uri);
        }

        if (isset($data['description'])) {
            $resource->setDescription($data['description']);
        }

        if (isset($data['baseUriParameters'])) {
            foreach ($data['baseUriParameters'] as $key => $baseUriParameter) {
                $resource->addBaseUriParameter(
                    BaseUriParameter::createFromArray($key, $baseUriParameter)
                );
            }
        }

        if (isset($data['uriParameters'])) {
            foreach ($data['uriParameters'] as $key => $uriParameter) {
                $resource->addUriParameter(
                    NamedParameter::createFromArray($key, $uriParameter ?: [])
                );
            }
        }

        if (isset($data['securedBy'])) {
            foreach ($data['securedBy'] as $key => $securedBy) {
                if ($securedBy) {
                    if (\is_array($securedBy)) {
                        $key = \array_keys($securedBy)[0];
                        $securityScheme = clone $apiDefinition->getSecurityScheme($key);
                        $securityScheme->mergeSettings($securedBy[$key]);
                        $resource->addSecurityScheme($securityScheme);
                    } else {
                        $resource->addSecurityScheme($apiDefinition->getSecurityScheme($securedBy));
                    }
                } else {
                    $resource->addSecurityScheme(SecurityScheme::createFromArray('null', [], $apiDefinition));
                }
            }
        }

        if (isset($data['is'])) {
            foreach ((array) $data['is'] as $traitName) {
                $resource->addTrait(TraitCollection::getInstance()->getTraitByName($traitName));
            }
        }

        foreach ($data as $key => $value) {
            if (\strpos($key, '/') === 0) {
                $value = $value ?: [];
                if (isset($data['uriParameters'])) {
                    $currentParameters = isset($value['uriParameters']) ? $value['uriParameters'] : [];
                    $value['uriParameters'] = \array_merge($currentParameters, $data['uriParameters']);
                }
                $resource->addResource(
                    self::createFromArray(
                        $uri . $key,
                        $value,
                        $apiDefinition
                    )
                );
            } elseif (\in_array(\strtoupper($key), Method::$validMethods, true)) {
                $resource->addMethod(
                    Method::createFromArray(
                        $key,
                        $value,
                        $apiDefinition
                    )
                );
            }
        }

        foreach ($resource->getMethods() as $method) {
            foreach ($resource->getTraits() as $trait) {
                $method->addTrait($trait);
            }
        }

        return $resource;
    }
649145
public function get($url, array $data = [], array $headers = [])
    {
        if ($data) {
            $url .= '?' . http_build_query($data);
        }
        return $this->sendRequest('GET', $url, $headers);
    }
1017242
public function respondWithSuccess(array $data = []): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_OK)->respond([
            'status' => [
                'http_code' => $this->getStatusCode(),
            ],
            'data' => $data,
        ]);
    }
218825
private function request($method, $uri, $data = [])
    {
        $uri = $this->getUri($uri);

        $headers = [];

        // Basic Auth
        $credentials = $this->key.':'.$this->password;

        // User Agent
        $agent = sprintf("%s %s", Client::NAME, Client::VERSION);

        $ch = curl_init();

        if (strtoupper($method) === 'GET' && !empty($data)) {
            $queryString = http_build_query($data);
            $uri .= '?'.$queryString;
        }

        $options = [
            CURLOPT_URL => $uri,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => true,
            CURLOPT_USERAGENT => $agent,
            CURLOPT_USERPWD => $credentials,
            CURLOPT_TIMEOUT => 60,
        ];

        if (strtoupper($method) === 'POST') {
            $jsonData = json_encode($data);

            $headers[] = 'Content-Type: application/json';
            $headers[] = 'Content-Length: '.strlen($jsonData);

            $options[CURLOPT_CUSTOMREQUEST] = 'POST';
            $options[CURLOPT_POSTFIELDS] = $jsonData;
        }

        if (isset($this->version) && is_numeric($this->version)) {
            $headers[] = 'X-EWAY-APIVERSION: '.$this->version;
        }

        $options[CURLOPT_HTTPHEADER] = $headers;

        curl_setopt_array($ch, $options);

        $rawResponse = curl_exec($ch);

        $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

        if (curl_errno($ch)) {
            $responseError = curl_error($ch);
            $responseBody = '';
        } else {
            $responseError = '';
            $responseBody = $this->parseResponse($rawResponse, $headerSize);
        }

        $response = new Response($statusCode, $responseBody, $responseError);

        curl_close($ch);

        return $response;
    }
1349582
public function call($api, $method = Request::METHOD_GET, array $data = [])
    {
        return $this->checkException($this->callHttpMethod($this->normalizeUri($api), $method, $data));
    }
278821
public function doRequest($method, $uri, $data = null)
    {
        $method = strtoupper($method);
        if(
            $method != Request::GET &&
            $method != Request::POST &&
            $method != Request::DELETE
        )
        {
            throw new ConnectorException("Invalid method [$method] for connector.");
        }

        $dtime   = time();
        $handle = $this->request->createHandle($method, $this->host . $uri);

        if(null === $data)
        {
            $signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri;
        }
        else
        {
            $payload         = json_encode($data);
            $signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri . '|' . $payload;

            $handle->setPayload($payload);
        }

        $handle->setHeader('X-CORAL-SIGN', hash('sha256', $signatureSource));
        $handle->setHeader('X-CORAL-ACCOUNT', $this->account);
        $handle->setHeader('X-CORAL-DTIME', $dtime);

        return $this->request->doRequestAndParse($handle);
    }
1200598
public function write(string $uri, $data)
    {
        // Create directory recursively if it doesn't exist
        if ( ! file_exists(dirname($uri))) {
            mkdir(dirname($uri), 0755, true);
        }

        // Write file to target directory
        if ( ! file_put_contents($uri, $data)) {
            throw new ErrorException("Failed to write output to file: ".$uri);
        }

        return true;
    }