Documentation

HapiClient
in package
implements HapiClientInterface

FinalYes

An HAPI Client.

Table of Contents

Interfaces

HapiClientInterface
The HAPI Client interface.

Properties

$apiUrl  : mixed
$authenticationMethod  : mixed
$client  : mixed
$entryPointResource  : mixed
$entryPointUrl  : mixed
$profile  : mixed

Methods

__construct()  : mixed
__set()  : mixed
The magic setter is overridden to insure immutability.
getApiUrl()  : string
getAuthenticationMethod()  : AuthenticationMethodInterface
getClient()  : ClientInterface
The HAPI Client uses a Guzzle client internally to send all the HTTP requests.
getEntryPointResource()  : ResourceInterface
Sends a request to the API entry point URL ("/" by default) and returns its Resource object.
getEntryPointUrl()  : string
getProfile()  : string
refresh()  : ResourceInterface
Attempts to refresh the Resource by sending a GET request to the URL referenced by the "self" relation type.
sendFollow()  : ResourceInterface
sendRequest()  : ResourceInterface
createHttpRequest()  : Request
Instantiates the HttpRequest depending on the configuration from the given Request.

Properties

$authenticationMethod

private mixed $authenticationMethod

$entryPointResource

private mixed $entryPointResource

Methods

__construct()

public __construct([string|null $apiUrl = null ][, string|null $entryPointUrl = '/' ][, string|null $profile = null ][, AuthenticationMethodInterface|null $authenticationMethod = null ]) : mixed
Parameters
$apiUrl : string|null = null

The URL pointing to the API server

$entryPointUrl : string|null = '/'

The URL to the entry point Resource

$profile : string|null = null

The URL pointing to the HAL profile containing the resources and their descriptors. If specified, the client will send an Accept header with application/hal+json and a profile attribute containing the value set here.

$authenticationMethod : AuthenticationMethodInterface|null = null

The authentication method

__set()

The magic setter is overridden to insure immutability.

public final __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed

getApiUrl()

public getApiUrl() : string
Return values
string —

the URL pointing to the API server

getClient()

The HAPI Client uses a Guzzle client internally to send all the HTTP requests.

public & getClient() : ClientInterface
Return values
ClientInterface —

The Guzzle client (passed by reference)

getEntryPointResource()

Sends a request to the API entry point URL ("/" by default) and returns its Resource object.

public getEntryPointResource() : ResourceInterface
Return values
ResourceInterface —

the entry point Resource

getEntryPointUrl()

public getEntryPointUrl() : string
Return values
string —

the URL to the entry point Resource

getProfile()

public getProfile() : string
Return values
string —

the URL pointing to the HAL profile

refresh()

Attempts to refresh the Resource by sending a GET request to the URL referenced by the "self" relation type.

public refresh(mixed $resource) : ResourceInterface
Parameters
$resource : mixed

The Resource to refresh

Return values
ResourceInterface —

The refreshed or the same Resource if failed to refresh it

sendFollow()

public sendFollow(mixed $follow[, ResourceInterface|null $resource = null ]) : ResourceInterface
Parameters
$follow : mixed

The Follow object or an array of Follow objects containing the parameters necessary for the HTTP request(s)

$resource : ResourceInterface|null = null

The resource containing the link you want to follow. If null, the entry point Resource will be used.

Return values
ResourceInterface —

the Resource object contained in the last response

createHttpRequest()

Instantiates the HttpRequest depending on the configuration from the given Request.

private createHttpRequest(RequestInterface $request) : Request
Parameters
$request : RequestInterface

The Request configuration

Return values
Request —

the HTTP request

On this page

Search results