API Client for binary options platform Solaris.
Install using Composer, doubtless.
$ composer require resnext/solaris-api-client
Your can configure used HTTP client using $options param of ApiClient constructor.
Each method of \Solaris\ApiClient can return response object (instance of \Solaris\Response) or throws two kind of exceptions.
- \Solaris\ServerException Server-side exception assigned with invalid data received of impossible operation is requested.
- \Solaris\ClientException Client-side exception means API Client cannot connect to Solaris servers or receive valid response with any reasons.
Example:
$httpClient = new GuzzleHttp\Client([
GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 2,
]);
$apiClient = new \Solaris\ApiClient(<API_URL>, <API_USERNAME>, <API_PASSWORD>, [
'httpClient' => $httpClient,
]);
For customer adding you need specify countryISO 3166-1 code (ex.: en, us, gb). You can get available for registration countries list as bellow:
/** @var \Solaris\Responses\GetCountriesResponse $response */
$response = $apiClient->getCountries();
/** @var \Solaris\Entities\Country[] $countries */
$countries = $response->getCountries();
Customer's adding is main method of any trade platform...
$request = new \Solaris\Requests\AddCustomerRequest([
'firstName' => 'John',
'lastName' => 'Smith',
'email' => '[email protected]',
'phone' => '123456789',
'country' => 'cz',
'currency' => 'USD',
'password' => 'qwerty',
]);
/** @var \Solaris\Responses\AddCustomerResponse $response */
$response = $apiClient->addCustomer($request);
It is really easy:
$request = new \Solaris\Requests\GetCustomerAuthKeyRequest(['email' => '[email protected]']);
/**
* @var \Solaris\Responses\GetCustomerAuthKeyResponse $response
*/
$response = $apiClient->getCustomerAuthKey($request);
echo $response->getAuthUrl();
/** @var \Solaris\Responses\GetDepositsResponse $response */
$response = $apiClient->getDeposits();
/** @var \Solaris\Entities\Deposit[] $deposits */
$deposits = $response->getDeposits();