Client

class DreamCommerce\ShopAppstoreLib\Client

A client library allowing to perform REST-ful requests.

This class implements ClientInterface. .

constants

constant DreamCommerce\ShopAppstoreLib\Client::ADAPTER_OAUTH

a pointer to the Client\OAuth

constant DreamCommerce\ShopAppstoreLib\Client::ADAPTER_BASIC_AUTH

a pointer to the Client\BasicAuth

static methods

static DreamCommerce\ShopAppstoreLib\Client::factory($adapter, $options =[])

Creates client instance.

Parameters:
  • $adapter (string) – adapter name
  • $options (array) – creation options
Return type:

ClientInterface

Returns:

client

Globally, $options accepts following keys:

entrypoint
shop URL
adapterNamespace
a namespace used to find $adapter class
static DreamCommerce\ShopAppstoreLib\Client::getDefaultAdapter

Gets default defined adapter

Return type:ClientInterface|null
Returns:client
static DreamCommerce\ShopAppstoreLib\Client::setDefaultAdapter(ClientInterface $adapter)

Sets default defined adapter

Parameters:
  • $adapter (ClientInterface) – adapter handle
Return type:

void

methods

DreamCommerce\ShopAppstoreLib\Client::__construct($entrypoint, $clientId, $clientSecret)

constructor

Parameters:
  • $exception (string) – in case of webapi/rest is not a part of URL, it will be automatically appended
  • $clientId (string) – string application ID
  • $clientSecret (string) – application secret code (generated upon App Store application registration)

Calling a constructor is adequate to perform this call:

self::factory(self::ADAPTER_OAUTH, array(
    'entrypoint' => $entrypoint,
    'client_id' => $clientId,
    'client_secret' => $clientSecret
)
DreamCommerce\ShopAppstoreLib\Client::getToken($authCode)

Gets token using the AuthCode.

Parameters:
  • $authCode (string) – authorization code, passed during installation
Return type:

array

Returns:

an array with tokens

DreamCommerce\ShopAppstoreLib\Client::refreshToken($refreshToken)

Refreshes token

Parameters:
  • $refreshToken (string) – refresh token, passed during token getting/exchange
Return type:

array

Returns:

an array with new tokens

DreamCommerce\ShopAppstoreLib\Client::setAccessToken($token)

Sets an access token for current script execution. Called automatically upon exchange/refreshing of token.

Parameters:
  • $token (string) – token
DreamCommerce\ShopAppstoreLib\Client::setAdapter(ClientInterface $adapter)

Sets adapter on this client.

Parameters:
  • $adapter (ClientInterface) – adapter
Return type:

Client

Returns:

chain