\CommuniqueCommunique

Communique Pluggable REST Client

Summary

Methods
Properties
Constants
__construct()
get()
put()
post()
delete()
No public properties found
No constants found
_call()
No protected properties found
N/A
No private methods found
$_BASE_URL
$_interceptors
$_http
N/A

Properties

$_BASE_URL

$_BASE_URL : String

The base path of the API. All other API paths will be used relative to this

Type

String

$_interceptors

$_interceptors : Array

An array of interceptors used for processing the requests

Type

Array

$_http

$_http : \Communique\HTTPClient

An implementation of \Communique\HTTPClient

Type

\Communique\HTTPClient

Methods

__construct()

__construct(String  $base_url = '', array  $interceptors = array(), \Communique\HTTPClient  $http_client = null) 

Constructs Communique REST library.

Parameters

String $base_url

The base URL of the API you wish to make requests to. All other paths referenced will be treated as relative to this.

array $interceptors

An array of any interceptors you wish to use to modify the request. An interceptor could do anything from JSON parsing to OAuth request signing.

\Communique\HTTPClient $http_client

The HTTP client you wish to make the request with

Throws

\Communique\CommuniqueException

get()

get(String  $url, mixed  $payload = array(), array  $headers = array(), callable  $debug = null) : \Communique\RESTClientResponse

Make an HTTP GET request

Parameters

String $url

The API to make the request to

mixed $payload

The request payload (this will be url encoded and added as query string parameters)

array $headers

Any headers you want to add to the request(optional)

callable $debug

A function to be used for request debugging. This function should accept two parameters, one for the request object one for the response object.

Returns

\Communique\RESTClientResponse

REST response encapsulation object

put()

put(String  $url, mixed  $payload, array  $headers = array(), callable  $debug = null) : \Communique\RESTClientResponse

Make an HTTP PUT request

Parameters

String $url

The API to make the request to

mixed $payload

The payload of the request(any data you wish to send across)

array $headers

Any headers you want to add to the request(optional)

callable $debug

A function to be used for request debugging. This function should accept two parameters, one for the request object one for the response object.

Returns

\Communique\RESTClientResponse

REST response encapsulation object

post()

post(String  $url, mixed  $payload, array  $headers = array(), callable  $debug = null) : \Communique\RESTClientResponse

Make an HTTP POST request

Parameters

String $url

The API to make the request to

mixed $payload

The payload of the request(any data you wish to send across)

array $headers

Any headers you want to add to the request(optional)

callable $debug

A function to be used for request debugging. This function should accept two parameters, one for the request object one for the response object.

Returns

\Communique\RESTClientResponse

REST response encapsulation object

delete()

delete(String  $url, mixed  $payload = array(), array  $headers = array(), callable  $debug = null) : \Communique\RESTClientResponse

Make an HTTP DELETE request

Parameters

String $url

The API to make the request to

mixed $payload

The payload of the request(any data you wish to send across)

array $headers

Any headers you want to add to the request(optional)

callable $debug

A function to be used for request debugging. This function should accept two parameters, one for the request object one for the response object.

Returns

\Communique\RESTClientResponse

REST response encapsulation object

_call()

_call(\Communique\RESTClientRequest  $request, callable  $debug = null) : \Communique\RESTClientResponse

Makes the HTTP request using the chosen HTTP client.

Parameters

\Communique\RESTClientRequest $request

A RESTClientRequest object encapsulating the request

callable $debug

A debugging callback to be run after the request has finished. This function is expected to accept two parameters, \Communique\RESTClientRequest and \Communique\RESTClientResponse

Returns

\Communique\RESTClientResponse

A RESTClientResponse object encapsulating the response