src/Rest/SdkTrait.php
public function makeRequest($url, $method = 'GET', $data = [], $headers = [])
    {
        //we cant send to the API the array with get GET, JSON, form_params parameters
        //the API doesnt get it taht way, guzzle sends it directly
        //so we extract it
        $rawData = count(array_keys($data)) > 0 ?  $data[array_keys($data)[0]] : [];


        $client = (new ClientSecurity($this->apiPublicKey, $this->apiPrivateKey, $rawData, $headers))->getGuzzle();

        $parse = function ($error) {
            if ($error->hasResponse()) {
                return $error->getResponse();
            }

            return json_decode($error->getMessage());
        };

        try {
            return $client->request($method, $url, $data);
        } catch (\GuzzleHttp\Exception\BadResponseException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\ClientException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\ConnectException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\RequestException $error) {
            return $parse($error);
        }
    }
public function makeRequest($url, $method = 'GET', $data = [], $headers = [])
    {
        //we cant send to the API the array with get GET, JSON, form_params parameters
        //the API doesnt get it taht way, guzzle sends it directly
        //so we extract it
        $rawData = count(array_keys($data)) > 0 ?  $data[array_keys($data)[0]] : [];


        $client = (new ClientSecurity($this->apiPublicKey, $this->apiPrivateKey, $rawData, $headers))->getGuzzle();

        $parse = function ($error) {
            if ($error->hasResponse()) {
                return $error->getResponse();
            }

            return json_decode($error->getMessage());
        };

        try {
            return $client->request($method, $url, $data);
        } catch (\GuzzleHttp\Exception\BadResponseException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\ClientException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\ConnectException $error) {
            return $parse($error);
        } catch (\GuzzleHttp\Exception\RequestException $error) {
            return $parse($error);
        }
    }
public function makeRequest ( $ url , $ method = 'GET' , $ data = [ ] , $ headers = [ ] ) { //we cant send to the API the array with get GET, JSON, form_params parameters //the API doesnt get it taht way, guzzle sends it directly //so we extract it $ rawData = count ( array_keys ( $ data ) ) > 0 ? $ data [ array_keys ( $ data ) [ 0 ] ] : [ ] ; $ client = ( new ClientSecurity ( $ this -> apiPublicKey , $ this -> apiPrivateKey , $ rawData , $ headers ) ) -> getGuzzle ( ) ; $ parse = function ( $ error ) { if ( $ error -> hasResponse ( ) ) { return $ error -> getResponse ( ) ; } return json_decode ( $ error -> getMessage ( ) ) ; } ; try { return $ client -> request ( $ method , $ url , $ data ) ; } catch ( \ GuzzleHttp \ Exception \ BadResponseException $ error ) { return $ parse ( $ error ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ error ) { return $ parse ( $ error ) ; } catch ( \ GuzzleHttp \ Exception \ ConnectException $ error ) { return $ parse ( $ error ) ; } catch ( \ GuzzleHttp \ Exception \ RequestException $ error ) { return $ parse ( $ error ) ; } }
Function that executes the request to the configured API

@param string $method - The request method
@param string $url - The request URL
@param array $data - The form data

@return JSON
Function that executes the request to the configured API