HapiClient
in package
implements
HapiClientInterface
An HAPI Client.
Interfaces, Classes, Traits and Enums
- HapiClientInterface
- The HAPI Client interface.
Table of Contents
- $apiUrl : mixed
- $authenticationMethod : mixed
- $client : mixed
- $entryPointResource : mixed
- $entryPointUrl : mixed
- $profile : mixed
- __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
$apiUrl
private
mixed
$apiUrl
$authenticationMethod
private
mixed
$authenticationMethod
$client
private
mixed
$client
$entryPointResource
private
mixed
$entryPointResource
$entryPointUrl
private
mixed
$entryPointUrl
$profile
private
mixed
$profile
Methods
__construct()
public
__construct([string $apiUrl = null ][, string $entryPointUrl = '/' ][, string $profile = null ][, AuthenticationMethodInterface $authenticationMethod = null ]) : mixed
Parameters
- $apiUrl : string = null
-
The URL pointing to the API server
- $entryPointUrl : string = '/'
-
The URL to the entry point Resource
- $profile : string = 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
-
The authentication method
Return values
mixed —__set()
The magic setter is overridden to insure immutability.
public
final __set( $name, $value) : mixed
Parameters
Return values
mixed —getApiUrl()
public
getApiUrl() : string
Return values
string —the URL pointing to the API server
getAuthenticationMethod()
public
getAuthenticationMethod() : AuthenticationMethodInterface
Return values
AuthenticationMethodInterface —The authentication method
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 $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
-
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
sendRequest()
public
sendRequest(RequestInterface $request) : ResourceInterface
Parameters
- $request : RequestInterface
-
The Request object containing all the parameters necessary for the HTTP request
Return values
ResourceInterface —the Resource object returned by the server
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