class BaseClient implements ClientInterface

Abstract client for common code for the different clients.

Methods

__construct(string $accessToken, string $host, LoggerInterface $logger = null, Client $httpClient = null, bool $storeMessages = true)

Client constructor.

callApi(string $method, string $uri, array $options = [])

Make a call to the API and returns the parsed JSON.

string|null
getExceptionNamespace()

Override this method for registering a custom namespace where the Client will look for an exception. If no exception is found in the custom namespace, the default namespace will be used.

getLogger()

No description

getMessages()

Returns an array of Message objects.

clearMesssages()

Clears the store of Message objects.

getHost()

No description

useApplication(ApplicationInterface $application)

Sets the current application.

setApplication(string $name, string $version = '')

Set the application name and version.

useIntegration(IntegrationInterface $integration)

Sets the current integration.

setIntegration(string $name, string $version = '')

Set the integration name and version.

static 
getVersion()

No description

static 
getVersionForPackage(string $package)

No description

static 
getPackageName()

Returns the packagist name of the current package.

static 
getSdkName()

The name of the library to be used in the User-Agent header.

static 
getApiContentType()

Returns the Content-Type (MIME-Type) to be used when communication with the API.

Details

at line 63
__construct(string $accessToken, string $host, LoggerInterface $logger = null, Client $httpClient = null, bool $storeMessages = true)

Client constructor.

Parameters

string $accessToken
string $host
LoggerInterface $logger
Client $httpClient
bool $storeMessages

at line 105
protected callApi(string $method, string $uri, array $options = [])

Make a call to the API and returns the parsed JSON.

Parameters

string $method The HTTP method
string $uri The URI path
array $options An array of optional parameters. The following keys are accepted: * query An array of query parameters that will be appended to the URI * headers An array of headers that will be added to the request * body The request body * host A string that can be used to override the default client base URI

Exceptions

Exception

at line 167
protected string|null getExceptionNamespace()

Override this method for registering a custom namespace where the Client will look for an exception. If no exception is found in the custom namespace, the default namespace will be used.

Return Value

string|null

at line 172
getLogger()

at line 183
Message[] getMessages()

Returns an array of Message objects.

This can be used to inspect all API calls that have been made by the current client.

Return Value

Message[]

at line 191
clearMesssages()

Clears the store of Message objects.

at line 196
getHost()

at line 204
useApplication(ApplicationInterface $application)

Sets the current application.

The values are used as part of the X-Contentful-User-Agent header.

Parameters

ApplicationInterface $application

at line 219
setApplication(string $name, string $version = '')

Set the application name and version.

The values are used as part of the X-Contentful-User-Agent header.

Parameters

string $name
string $version

at line 229
useIntegration(IntegrationInterface $integration)

Sets the current integration.

The values are used as part of the X-Contentful-User-Agent header.

Parameters

IntegrationInterface $integration

at line 240
setIntegration(string $name, string $version = '')

Set the integration name and version.

The values are used as part of the X-Contentful-User-Agent header.

Parameters

string $name
string $version

at line 247
static getVersion()

at line 252
static protected getVersionForPackage(string $package)

Parameters

string $package

at line 273
abstract static protected getPackageName()

Returns the packagist name of the current package.

at line 278
abstract static protected getSdkName()

The name of the library to be used in the User-Agent header.

at line 283
abstract static protected getApiContentType()

Returns the Content-Type (MIME-Type) to be used when communication with the API.