PHP Класс SparkPost\SparkPost

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$transmissions Instance of Transmission class.

Открытые методы

Метод Описание
__construct ( Http\Client\HttpClient $httpClient, array $options ) Sets up the SparkPost instance.
asyncRequest ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostPromise Sends async request to SparkPost API.
buildRequest ( string $method, string $uri, array $payload, array $headers ) : Psr\Http\Message\RequestInterface Builds request from given params.
getHttpHeaders ( array $headers = [] ) : array Returns an array for the request headers.
getUrl ( string $path, array $params = [] ) : string Builds the request url from the options and given params.
request ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostPromise | SparkPostResponse Sends either sync or async request based on async option.
setHttpClient ( Http\Client\HttpClient | Http\Client\HttpAsyncClient $httpClient ) Sets $httpClient to be used for request.
setMessageFactory ( Http\Message\RequestFactory $messageFactory ) : SparkPost
setOptions ( array $options ) Sets the options from the param and defaults for the SparkPost object.
syncRequest ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostResponse Sends sync request to SparkPost API.

Приватные методы

Метод Описание
getMessageFactory ( ) : Http\Message\RequestFactory
setupEndpoints ( ) Sets up any endpoints to custom classes e.g. $this->transmissions.

Описание методов

__construct() публичный Метод

Sets up the SparkPost instance.
public __construct ( Http\Client\HttpClient $httpClient, array $options )
$httpClient Http\Client\HttpClient - An httplug client or adapter
$options array - An array to overide default options or a string to be used as an API key

asyncRequest() публичный Метод

Sends async request to SparkPost API.
public asyncRequest ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostPromise
$method string
$uri string
$payload array
$headers array
Результат SparkPostPromise

buildRequest() публичный Метод

Builds request from given params.
public buildRequest ( string $method, string $uri, array $payload, array $headers ) : Psr\Http\Message\RequestInterface
$method string
$uri string
$payload array
$headers array
Результат Psr\Http\Message\RequestInterface

getHttpHeaders() публичный Метод

Returns an array for the request headers.
public getHttpHeaders ( array $headers = [] ) : array
$headers array - any custom headers for the request
Результат array $headers - headers for the request

getUrl() публичный Метод

Builds the request url from the options and given params.
public getUrl ( string $path, array $params = [] ) : string
$path string - the path in the url to hit
$params array - query parameters to be encoded into the url
Результат string $url - the url to send the desired request to

request() публичный Метод

Sends either sync or async request based on async option.
public request ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostPromise | SparkPostResponse
$method string
$uri string
$payload array - either used as the request body or url query params
$headers array
Результат SparkPostPromise | SparkPostResponse Promise or Response depending on sync or async request

setHttpClient() публичный Метод

Sets $httpClient to be used for request.
public setHttpClient ( Http\Client\HttpClient | Http\Client\HttpAsyncClient $httpClient )
$httpClient Http\Client\HttpClient | Http\Client\HttpAsyncClient - the client to be used for request

setMessageFactory() публичный Метод

public setMessageFactory ( Http\Message\RequestFactory $messageFactory ) : SparkPost
$messageFactory Http\Message\RequestFactory
Результат SparkPost

setOptions() публичный Метод

Sets the options from the param and defaults for the SparkPost object.
public setOptions ( array $options )
$options array - either an string API key or an array of options

syncRequest() публичный Метод

Sends sync request to SparkPost API.
public syncRequest ( string $method = 'GET', string $uri = '', array $payload = [], array $headers = [] ) : SparkPostResponse
$method string
$uri string
$payload array
$headers array
Результат SparkPostResponse

Описание свойств

$transmissions публичное свойство

Instance of Transmission class.
public $transmissions