45 public function __construct(
string $projectKey, $body =
null, array $headers = [], ClientInterface $client =
null)
47 $uri = str_replace([
'{projectKey}'], [$projectKey],
'{projectKey}/subscriptions');
48 parent::__construct($client,
'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body);
56 public function mapFromResponse(?ResponseInterface $response,
string $resultType =
null)
58 if (is_null($response)) {
61 if (is_null($resultType)) {
62 switch ($response->getStatusCode()) {
64 $resultType = SubscriptionPagedQueryResponseModel::class;
68 $resultType = ErrorResponseModel::class;
72 $resultType = ErrorResponseModel::class;
76 $resultType = ErrorResponseModel::class;
80 $resultType = ErrorResponseModel::class;
84 $resultType = ErrorResponseModel::class;
88 $resultType = ErrorResponseModel::class;
92 $resultType = JsonObjectModel::class;
107 public function execute(array $options = [],
string $resultType =
null)
110 $response = $this->
send($options);
111 }
catch (ServerException $e) {
112 $response = $e->getResponse();
113 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
115 }
catch (ClientException $e) {
116 $response = $e->getResponse();
117 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
130 public function executeAsync(array $options = [],
string $resultType =
null)
133 function (ResponseInterface $response) use ($resultType) {
136 function (RequestException $e) use ($resultType) {
137 $response = $e->getResponse();
138 if ($e instanceof ServerException) {
139 $e = ExceptionFactory::createServerException($e, $this, $response, $this->
mapFromResponse($response, $resultType));
141 if ($e instanceof ClientException) {
142 $e = ExceptionFactory::createClientException($e, $this, $response, $this->
mapFromResponse($response, $resultType));