PHP code example of mapado / rest-client-sdk-bundle
1. Go to this page and download the library: Download mapado/rest-client-sdk-bundle 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/ */
$cartList = $this->get('mapado.rest_client_sdk.foo')
->getRepository('carts')
->findAll(); // `carts` is the `key` defined in the model
$cart = $this->get('mapado.rest_client_sdk.foo')
->getRepository('carts')
->find(1);
namespace App\Rest\Decorator;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class DecoratingClient implements ClientInterface
{
/**
* @var Client
*/
private $decoratedClient;
public function __construct(Client $decoratedClient)
{
$this->decoratedClient = $decoratedClient;
}
/**
* {@inheritdoc}
*/
public function send(RequestInterface $request, array $options = []): ResponseInterface
{
return $this->decoratedClient->send($request, $options);
}
/**
* {@inheritdoc}
*/
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
{
return $this->decoratedClient->sendAsync($request, $options);
}
/**
* {@inheritdoc}
*/
public function request($method, $uri, array $options = []): ResponseInterface
{
if (!isset($options['headers'])) {
$options['headers'] = [];
}
$options['headers'] = array_merge(
$options['headers'],
[
'Authorization' => 'Bearer my-great-token',
'Accept-Language' => 'fr',
]
);
return $this->decoratedClient->request($method, $uri, $options);
}
/**
* {@inheritdoc}
*/
public function requestAsync($method, $uri, array $options = []): PromiseInterface
{
return $this->decoratedClient->requestAsync($method, $uri, $options);
}
public function getConfig($option = null)
{
return $this->decoratedClient->getConfig($option);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.