src/idOS/Endpoint/AbstractEndpoint.php
private function sendRequest(string $method, string $uri, array $query = [], array $body = []) : array {
        $uri = sprintf('%s%s', $this->baseUrl, ltrim($uri, '/'));

        $options = [
            'headers' => [
                'Authorization' => (string) $this->authentication
            ],
            'http_errors' => false
        ];

        if (! empty($query)) {
            $options['query'] = $query;
        }

        if (! empty($body)) {
            $options['json'] = $body;
        }

        $response = $this->client->request(
            $method,
            $uri,
            $options
        );

        $json = json_decode((string) $response->getBody(), true);
        if ($json === null) {
            if ($this->throwsExceptions) {
                throw new SDKError();
            }

            return [(string) $response->getBody()];
        }

        if (($json['status'] === false) && ($this->throwsExceptions)) {
            throw new SDKException(
                $json['error']['message'],
                $json['error']['type'],
                $json['error']['link']
            );
        }

        return $json;
    }
private function sendRequest(string $method, string $uri, array $query = [], array $body = []) : array {
        $uri = sprintf('%s%s', $this->baseUrl, ltrim($uri, '/'));

        $options = [
            'headers' => [
                'Authorization' => (string) $this->authentication
            ],
            'http_errors' => false
        ];

        if (! empty($query)) {
            $options['query'] = $query;
        }

        if (! empty($body)) {
            $options['json'] = $body;
        }

        $response = $this->client->request(
            $method,
            $uri,
            $options
        );

        $json = json_decode((string) $response->getBody(), true);
        if ($json === null) {
            if ($this->throwsExceptions) {
                throw new SDKError();
            }

            return [(string) $response->getBody()];
        }

        if (($json['status'] === false) && ($this->throwsExceptions)) {
            throw new SDKException(
                $json['error']['message'],
                $json['error']['type'],
                $json['error']['link']
            );
        }

        return $json;
    }
private function sendRequest ( string $ method , string $ uri , array $ query = [ ] , array $ body = [ ] ) : array { $ uri = sprintf ( '%s%s' , $ this -> baseUrl , ltrim ( $ uri , '/' ) ) ; $ options = [ 'headers' => [ 'Authorization' => ( string ) $ this -> authentication ] , 'http_errors' => false ] ; if ( ! empty ( $ query ) ) { $ options [ 'query' ] = $ query ; } if ( ! empty ( $ body ) ) { $ options [ 'json' ] = $ body ; } $ response = $ this -> client -> request ( $ method , $ uri , $ options ) ; $ json = json_decode ( ( string ) $ response -> getBody ( ) , true ) ; if ( $ json === null ) { if ( $ this -> throwsExceptions ) { throw new SDKError ( ) ; } return [ ( string ) $ response -> getBody ( ) ] ; } if ( ( $ json [ 'status' ] === false ) && ( $ this -> throwsExceptions ) ) { throw new SDKException ( $ json [ 'error' ] [ 'message' ] , $ json [ 'error' ] [ 'type' ] , $ json [ 'error' ] [ 'link' ] ) ; } return $ json ; }
Sends the request to the api.

@param string $method
@param array  $query
@param array  $body

@return array response
Sends the request to the api .