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)

Client constructor.

array
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.

LoggerInterface
getLogger()

No description

getMessages()

Returns an array of Message objects.

string
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 string
getVersion()

No description

static string
getVersionForPackage(string $package)

No description

static string
getPackageName()

Returns the packagist name of the current package.

static string
getSdkName()

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

static string
getApiContentType()

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

Details

at line 64
__construct(string $accessToken, string $host, LoggerInterface $logger = \null, Client $httpClient = \null)

Client constructor.

Parameters

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

at line 106
protected array 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

Return Value

array

Exceptions

Exception

at line 172
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 180
LoggerInterface getLogger()

Return Value

LoggerInterface

at line 191
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 199
string getHost()

Return Value

string

at line 207
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 222
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 232
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 243
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 253
static string getVersion()

Return Value

string

at line 263
static protected string getVersionForPackage(string $package)

Parameters

string $package

Return Value

string

at line 286
abstract static protected string getPackageName()

Returns the packagist name of the current package.

Return Value

string

at line 293
abstract static protected string getSdkName()

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

Return Value

string

at line 300
abstract static protected string getApiContentType()

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

Return Value

string