3 declare(strict_types=1);
22 use GuzzleHttp\ClientInterface;
23 use GuzzleHttp\Exception\ClientException;
24 use GuzzleHttp\Exception\RequestException;
25 use GuzzleHttp\Exception\ServerException;
26 use GuzzleHttp\Promise\PromiseInterface;
28 use Psr\Http\Message\ResponseInterface;
44 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
46 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/me');
47 parent::__construct($client,
'DELETE', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
55 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
57 if (is_null($response)) {
60 if (is_null($resultType)) {
61 switch ($response->getStatusCode()) {
63 $resultType = CustomerModel::class;
67 $resultType = ErrorResponseModel::class;
71 $resultType = ErrorResponseModel::class;
75 $resultType = ErrorResponseModel::class;
79 $resultType = ErrorResponseModel::class;
83 $resultType = ErrorResponseModel::class;
87 $resultType = ErrorResponseModel::class;
91 $resultType = ErrorResponseModel::class;
95 $resultType = JsonObjectModel::class;
110 public function execute(array $options = [],
string $resultType =
null)
113 $response = $this->
send($options);
114 }
catch (ServerException $e) {
115 $response = $e->getResponse();
118 }
catch (ClientException $e) {
119 $response = $e->getResponse();
133 public function executeAsync(array $options = [],
string $resultType =
null)
136 function (ResponseInterface $response) use ($resultType) {
139 function (RequestException $e) use ($resultType) {
140 $response = $e->getResponse();
141 if ($e instanceof ServerException) {
144 if ($e instanceof ClientException) {