PHP code example of paysera / lib-rest-client-common
1. Go to this page and download the library: Download paysera/lib-rest-client-common library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paysera / lib-rest-client-common example snippets
class TestClientFactory extends ClientFactoryAbstract
{
const DEFAULT_BASE_URL = 'http://example.com/test/rest/v1/{locale}/';
private $apiClient;
public function __construct(array $options)
{
$this->apiClient = $this->createApiClient($options);
}
public function getTestClient()
{
return new TestClient($this->apiClient);
}
}
class TestClient
{
private $apiClient;
public function __construct(ApiClient $apiClient)
{
$this->apiClient = $apiClient;
}
public function withOptions(array $options)
{
return new TestClient($this->apiClient->withOptions($options));
}
/**
* @return array
*/
public function getSomething()
{
$request = $this->apiClient->createRequest(
RequestMethodInterface::METHOD_GET,
sprintf('/something'),
null
);
return $this->apiClient->makeRequest($request);
}
}