interface OperatorInterface

An operator is any resource or service that can invoke and send REST operations. In other words, it is any class that can send requests and receive responses with a HTTP client. To do this it needs two things: a {see ClientInterface} for handling HTTP transactions and an {see ApiInterface} for handling how operations are created.

Methods

__construct (ClientInterface $client, ApiInterface $api)

No description

execute (array $definition, array $userValues = array()) : ResponseInterface

A convenience method that assembles an operation and sends it to the remote API

executeAsync (array $definition, array $userValues = array()) : PromiseInterface

A convenience method that assembles an operation and asynchronously sends it to the remote API

getOperation (array $definition) : Operation

Retrieves a populated Operation according to the definition and values provided. A HTTP client is also injected into the object to allow it to communicate with the remote API.

model (string $class, mixed $data = null) : ResourceInterface

No description

Details

__construct(ClientInterface $client, ApiInterface $api)

Parameters

$client ClientInterface The HTTP client responsible for handling HTTP transactions
$api ApiInterface The data API class that dictates how REST operations are structured

Example code

$operatorInterface->__construct($client, $api);

execute(array $definition, array $userValues = array())

A convenience method that assembles an operation and sends it to the remote API

Parameters

$definition array The data that dictates how the operation works
$userValues array The user-defined values that populate the request

Return value

ResponseInterface

Example code

$responseInterface = $operatorInterface->execute($definition, $userValues);

executeAsync(array $definition, array $userValues = array())

A convenience method that assembles an operation and asynchronously sends it to the remote API

Parameters

$definition array The data that dictates how the operation works
$userValues array The user-defined values that populate the request

Return value

PromiseInterface

Example code

$promiseInterface = $operatorInterface->executeAsync($definition, $userValues);

getOperation(array $definition)

Retrieves a populated Operation according to the definition and values provided. A HTTP client is also injected into the object to allow it to communicate with the remote API.

Parameters

$definition array The data that dictates how the operation works

Return value

Operation

Example code

$operation = $operatorInterface->getOperation($definition);

model(string $class, mixed $data = null)

Parameters

$class string The name of the model class.
$data mixed Either a {see ResponseInterface} or data array that will populate the newly created model class.

Return value

ResourceInterface

Example code

$resourceInterface = $operatorInterface->model($class, $data);