Client

Utility class for connecting to a REST API

internal
package

NextEvent\PHPSDK\REST

Methods

Client constructor

__construct(\GuzzleHttp\Client $httpClient, \Psr\Log\LoggerInterface $logger = null) 

Wraps HTTP client adding REST-specific headers and handling response or errors.

Arguments

$httpClient

\GuzzleHttp\Client

$logger

\Psr\Log\LoggerInterface

optional logger

Send a DELETE request to $url

delete(string $url, string $authorizationHeader = null) : boolean
Throws
\NextEvent\PHPSDK\Exception\APIResponseException

Arguments

$url

string

$authorizationHeader

string

Response

boolean

success

Send a GET request to $url

get(string $url, string $authorizationHeader = null) : \NextEvent\PHPSDK\Model\HALResponse
Throws
\NextEvent\PHPSDK\Exception\APIResponseException

Arguments

$url

string

$authorizationHeader

string

Response

\NextEvent\PHPSDK\Model\HALResponse

Send a PATCH request to $url

patch(string $url, array $payload, string $authorizationHeader = null) : \NextEvent\PHPSDK\Model\HALResponse
Throws
\NextEvent\PHPSDK\Exception\APIResponseException

Arguments

$url

string

request url

$payload

array

send payload as json

$authorizationHeader

string

optional, authorizationHeader

Response

\NextEvent\PHPSDK\Model\HALResponse

Send a POST request to $url

post(string $url, array $payload = null, string $authorizationHeader = null) : \NextEvent\PHPSDK\Model\HALResponse
Throws
\NextEvent\PHPSDK\Exception\APIResponseException

Arguments

$url

string

request url

$payload

array

optional, send payload as json

$authorizationHeader

string

optional, authorizationHeader

Response

\NextEvent\PHPSDK\Model\HALResponse

Send a PUT request to $url

put(string $url, array $payload, string $authorizationHeader = null) : \NextEvent\PHPSDK\Model\HALResponse
Throws
\NextEvent\PHPSDK\Exception\APIResponseException

Arguments

$url

string

request url

$payload

array

send payload as json

$authorizationHeader

string

optional, authorizationHeader

Response

\NextEvent\PHPSDK\Model\HALResponse

Setter for the Authorization header to be used in HTTP requests

setAuthorizationHeader(string $header) : self

Arguments

$header

string

Response

self