40 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
42 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/custom-objects');
43 parent::__construct($client,
'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
51 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
53 if (is_null($response)) {
56 if (is_null($resultType)) {
57 switch ($response->getStatusCode()) {
59 $resultType = ErrorResponseModel::class;
63 $resultType = ErrorResponseModel::class;
67 $resultType = ErrorResponseModel::class;
71 $resultType = ErrorResponseModel::class;
75 $resultType = ErrorResponseModel::class;
79 $resultType = ErrorResponseModel::class;
83 $resultType = JsonObjectModel::class;
98 public function execute(array $options = [],
string $resultType =
null)
101 $response = $this->
send($options);
102 }
catch (ServerException $e) {
103 $response = $e->getResponse();
104 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
106 }
catch (ClientException $e) {
107 $response = $e->getResponse();
108 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
121 public function executeAsync(array $options = [],
string $resultType =
null)
124 function (ResponseInterface $response) use ($resultType) {
127 function (RequestException $e) use ($resultType) {
128 $response = $e->getResponse();
129 if ($e instanceof ServerException) {
130 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
132 if ($e instanceof ClientException) {
133 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));