Client¶
-
class
DreamCommerce\
Client
¶
A client library allowing to perform REST-ful requests.
static methods¶
-
static
DreamCommerce\Client::
getError
(Exception $exception)¶ Returns an error message of specified exception, layer-independent.
Parameters: - $exception (Exception) – an exception which is a source for error message
Return type: string
Returns: error message
methods¶
-
DreamCommerce\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)
-
DreamCommerce\Client::
__get
($resource)¶ Returns resource object by name
Parameters: - $resource (string) – resource name
Return type: resource
-
DreamCommerce\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\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\Client::
request
($res, $method, $objectPath = null, $data =, []$query =[])¶ Performs a request to the server
Parameters: - $res (Resource) – resource to perform request on
- $method (string) –
GET/POST/PUT/DELETE
- $objectPath (null|string|array) – resource path, eg.
object/1/something
. It can be also an array - then class will automatically glue it with/
. - $data (array) – data to pass with request
- $query (array) – query string
Returns: request response
Return type: mixed
-
DreamCommerce\Client::
setAccessToken
($token)¶ Sets an access token for current script execution. Called automatically upon exchange/refreshing of token.
Parameters: - $token (string) – token