class Client extends Client

A Client is used to communicate the Contentful Delivery API.

A Client is only responsible for one Space. When access to multiple spaces is required, create multiple Clients.

This class can be configured to use the Preview API instead of the Delivery API. This grants access to not yet published content.

Constants

VERSION

Methods

__construct($token, string $spaceId, bool $preview = false, LoggerInterface $logger = null)

Client constructor.

array|object
request(string $method, string $path, array $options = [])

No description

from Client
string
getUserAgentAppName()

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

string
getUserAgent()

Returns the value of the User-Agent header for any requests made to Contentful

from Client
object|array
decodeJson(string $json)

No description

from Client
getAsset(string $id)

No description

getAssets(Query $query = null)

No description

getContentType(string $id)

No description

getContentTypes(Query $query = null)

No description

getEntry(string $id)

No description

getEntries(Query $query = null)

No description

getSpace()

No description

resolveLink(Link $link)

Resolve a link to it's resource.

reviveJson(string $json)

Revive JSON previously cached.

mixed
syncRequest(array $queryData)

Internal method for \Contentful\Delivery\Synchronization\Manager

bool
isPreview()

Returns true when using the Preview API

getSynchronizationManager()

Get an instance of the synchronization manager.

Details

at line 52
__construct($token, string $spaceId, bool $preview = false, LoggerInterface $logger = null)

Client constructor.

Parameters

$token
string $spaceId ID of the space used with this Client.
bool $preview True to use the Preview API.
LoggerInterface $logger

in Client at line 69
protected array|object request(string $method, string $path, array $options = [])

Parameters

string $method
string $path
array $options

Return Value

array|object

at line 71
protected string getUserAgentAppName()

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

Return Value

string

in Client at line 141
protected string getUserAgent()

Returns the value of the User-Agent header for any requests made to Contentful

Return Value

string

in Client at line 159
protected object|array decodeJson(string $json)

Parameters

string $json JSON encoded object or array

Return Value

object|array

Exceptions

RuntimeException On invalid JSON

at line 83
Asset getAsset(string $id)

Parameters

string $id

Return Value

Asset

at line 101
ResourceArray getAssets(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 119
ContentType getContentType(string $id)

Parameters

string $id

Return Value

ContentType

at line 135
ResourceArray getContentTypes(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 150
EntryInterface getEntry(string $id)

Parameters

string $id

Return Value

EntryInterface

at line 168
ResourceArray getEntries(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 184
Space getSpace()

Return Value

Space

Resolve a link to it's resource.

Parameters

Link $link

Return Value

Asset|EntryInterface

Exceptions

InvalidArgumentException When encountering an unexpected link type.

at line 230
Asset|ContentType|DynamicEntry|Space|DeletedAsset|DeletedEntry|ResourceArray reviveJson(string $json)

Revive JSON previously cached.

Parameters

string $json

Return Value

Asset|ContentType|DynamicEntry|Space|DeletedAsset|DeletedEntry|ResourceArray

Exceptions

SpaceMismatchException When attemptiting to revive JSON belonging to a different space

at line 247
mixed syncRequest(array $queryData)

Internal method for \Contentful\Delivery\Synchronization\Manager

Parameters

array $queryData

Return Value

mixed

See also

\Contentful\Delivery\Synchronization\Manager

at line 262
bool isPreview()

Returns true when using the Preview API

Return Value

bool

See also

https://www.contentful.com/developers/docs/references/content-preview-api/#/reference Preview API Reference

at line 277
Manager getSynchronizationManager()

Get an instance of the synchronization manager.

Return Value

Manager

Exceptions

RuntimeException If this method is called while using the Preview API.

See also

https://www.contentful.com/developers/docs/concepts/sync/ Sync API