BaseClient Uses RecurlyTraits
Table of Contents
- ALLOWED_OPTIONS = ['params', 'headers']
- API_HOSTS = ['us' => 'https://v3.recurly.com', 'eu' => 'https://v3.eu.recurly.com']
- $baseUrl : mixed
- $http : mixed
- $_api_key : mixed
- $_logger : mixed
- __construct() : mixed
- Constructor
- nextPage() : Page
- Used by the \Recurly\Pager to make requests to the API.
- pagerCount() : Response
- Used by the \Recurly\Pager to obtain total counts from the API.
- apiVersion() : string
- Recurly API version that the client was generated for
- encodeApiKey() : string
- Base64 encodes the API key
- getUserAgent() : string
- Generates User-Agent for API requests
- interpolatePath() : string
- Replaces placeholder values with supplied values
- makeRequest() : RecurlyResource
- Performs API requests and processes the response into a Recurly Resource
- titleize() : string
- Capitalizes all the words in the $input.
- _buildPath() : string
- Build the URL that the API request will be sent to
- _coreHeaders() : array<string|int, mixed>
- Generates core headers to be sent with the HTTP request
- _formatDateTimes() : array<string|int, mixed>
- Converts any DateTime values in $arr to ISO8601 strings
- _getResponse() : Response
- Performs the HTTP request to the Recurly API
- _mapArrayParams() : array<string|int, mixed>
- Maps parameters with array values into csv strings. The API expects these values to be csv strings, but an array is a nicer interface for developers.
- _mapBooleanParams() : array<string|int, mixed>
- Maps parameters with boolean value into strings. The API expects these values to be booleans, but http_build_query transforms actual php booleans into integers. So the workaround is to provide them as strings instead.
- _validateOptions() : void
- Checks that $options keys are valid
- _validatePathParameters() : void
- Checks that path parameters are valid
Constants
ALLOWED_OPTIONS
private
mixed
ALLOWED_OPTIONS
= ['params', 'headers']
API_HOSTS
private
mixed
API_HOSTS
= ['us' => 'https://v3.recurly.com', 'eu' => 'https://v3.eu.recurly.com']
Properties
$baseUrl
protected
mixed
$baseUrl
= RecurlyBaseClient::API_HOSTS['us']
$http
protected
mixed
$http
$_api_key
private
mixed
$_api_key
$_logger
private
mixed
$_logger
Methods
__construct()
Constructor
public
__construct(string $api_key[, LoggerInterface $logger = null ][, string $options = [] ]) : mixed
Parameters
- $api_key : string
-
The API key to use when making requests
- $logger : LoggerInterface = null
- $options : string = []
-
initialize options
In addition to the options managed by BaseClient, it accepts the following options:
- "region" to define the Data Center connection - defaults to "us";
Return values
mixed —nextPage()
Used by the \Recurly\Pager to make requests to the API.
public
nextPage(string $path[, array<string|int, mixed> $options = [] ]) : Page
Parameters
- $path : string
-
The URL to make the pager request to
- $options : array<string|int, mixed> = []
-
An associative array optional parameters
Return values
Page —pagerCount()
Used by the \Recurly\Pager to obtain total counts from the API.
public
pagerCount(string $path[, array<string|int, mixed> $options = [] ]) : Response
Parameters
- $path : string
-
The URL to make the pager request to
- $options : array<string|int, mixed> = []
-
An associative array optional parameters
Return values
Response —apiVersion()
Recurly API version that the client was generated for
protected
abstract apiVersion() : string
Return values
string —Recurly API version that the client was generated for
encodeApiKey()
Base64 encodes the API key
protected
static encodeApiKey(string $key) : string
Parameters
- $key : string
-
The API key to encode
Return values
string —base64 encoded API key
getUserAgent()
Generates User-Agent for API requests
protected
static getUserAgent() : string
Return values
string —Recurly client User-Agent string
interpolatePath()
Replaces placeholder values with supplied values
protected
interpolatePath(string $path[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $path : string
-
Tokenized path to make replacements on
- $options : array<string|int, mixed> = []
-
Associatve array of tokens and their replacement values
Return values
string —The path with it's tokens replaced with the supplied values
makeRequest()
Performs API requests and processes the response into a Recurly Resource
protected
makeRequest(string $method, string $path[, array<string|int, mixed> $body = [] ][, array<string|int, mixed> $options = [] ]) : RecurlyResource
Parameters
- $method : string
-
HTTP method to use
- $path : string
-
Tokenized path to request
- $body : array<string|int, mixed> = []
-
The request body
- $options : array<string|int, mixed> = []
-
Additional request parameters (including query parameters)
Return values
RecurlyResource —A Recurly Resource
titleize()
Capitalizes all the words in the $input.
protected
static titleize(string $input[, string $prefix = '' ]) : string
Parameters
- $input : string
-
The string to titleize
- $prefix : string = ''
-
(optional) Prefix to add to the beginning of the titleized string. The prefix will not be titleized.
Return values
string —The titleized $input wtih the prepended $prefix
_buildPath()
Build the URL that the API request will be sent to
private
_buildPath(string $path, array<string|int, mixed> $options) : string
Parameters
- $path : string
-
The path to be requested
- $options : array<string|int, mixed>
-
Additional request parameters (including query parameters)
Return values
string —The combined URL
_coreHeaders()
Generates core headers to be sent with the HTTP request
private
_coreHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array representation of the core request HTTP headers
_formatDateTimes()
Converts any DateTime values in $arr to ISO8601 strings
private
_formatDateTimes(array<string|int, mixed> $arr) : array<string|int, mixed>
Parameters
- $arr : array<string|int, mixed>
-
The Associative array to format
Return values
array<string|int, mixed> —The formatted array
_getResponse()
Performs the HTTP request to the Recurly API
private
_getResponse(Request $request) : Response
Parameters
- $request : Request
-
The \Recurly\Request object
Return values
Response —A Recurly Response object
_mapArrayParams()
Maps parameters with array values into csv strings. The API expects these values to be csv strings, but an array is a nicer interface for developers.
private
_mapArrayParams([array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Associative array of parameters
Return values
array<string|int, mixed> —_mapBooleanParams()
Maps parameters with boolean value into strings. The API expects these values to be booleans, but http_build_query transforms actual php booleans into integers. So the workaround is to provide them as strings instead.
private
_mapBooleanParams([array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Associative array of parameters
Return values
array<string|int, mixed> —_validateOptions()
Checks that $options keys are valid
private
_validateOptions([array<string|int, mixed> $options = [] ]) : void
Parameters
- $options : array<string|int, mixed> = []
-
An associative array optional parameters
Return values
void —_validatePathParameters()
Checks that path parameters are valid
private
_validatePathParameters([array<string|int, mixed> $options = [] ]) : void
Parameters
- $options : array<string|int, mixed> = []
-
Associatve array of tokens and their replacement values