|
14 | 14 | *
|
15 | 15 | * Welcome to Docplanner Integrations [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) API! This API gives You the ability to build Your own application and integrate it with Docplanner services.
|
16 | 16 | *
|
17 |
| - * OpenAPI spec version: 1.0.13 |
| 17 | + * OpenAPI spec version: 1.0.17 |
18 | 18 | *
|
19 | 19 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
|
20 | 20 | * Swagger Codegen version: 3.0.24
|
@@ -86,6 +86,266 @@ public function getConfig()
|
86 | 86 | return $this->config;
|
87 | 87 | }
|
88 | 88 |
|
| 89 | + /** |
| 90 | + * Operation pullMultipleNotification |
| 91 | + * |
| 92 | + * @param int $limit Maximum number of notifications pulled. Can take value from 1 to 100. If not provided the default value of 1 is applied. (optional) |
| 93 | + * |
| 94 | + * @throws \DocPlanner\Client\ApiException on non-2xx response |
| 95 | + * @throws \InvalidArgumentException |
| 96 | + * @return \DocPlanner\Client\Model\PullMultipleNotificationsResponse |
| 97 | + */ |
| 98 | + public function pullMultipleNotification($limit = null) |
| 99 | + { |
| 100 | + list($response) = $this->pullMultipleNotificationWithHttpInfo($limit); |
| 101 | + return $response; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Operation pullMultipleNotificationWithHttpInfo |
| 106 | + * |
| 107 | + * @param int $limit Maximum number of notifications pulled. Can take value from 1 to 100. If not provided the default value of 1 is applied. (optional) |
| 108 | + * |
| 109 | + * @throws \DocPlanner\Client\ApiException on non-2xx response |
| 110 | + * @throws \InvalidArgumentException |
| 111 | + * @return array of \DocPlanner\Client\Model\PullMultipleNotificationsResponse, HTTP status code, HTTP response headers (array of strings) |
| 112 | + */ |
| 113 | + public function pullMultipleNotificationWithHttpInfo($limit = null) |
| 114 | + { |
| 115 | + $returnType = '\DocPlanner\Client\Model\PullMultipleNotificationsResponse'; |
| 116 | + $request = $this->pullMultipleNotificationRequest($limit); |
| 117 | + |
| 118 | + try { |
| 119 | + $options = $this->createHttpClientOption(); |
| 120 | + try { |
| 121 | + $response = $this->client->send($request, $options); |
| 122 | + } catch (RequestException $e) { |
| 123 | + throw new ApiException( |
| 124 | + "[{$e->getCode()}] {$e->getMessage()}", |
| 125 | + $e->getCode(), |
| 126 | + $e->getResponse() ? $e->getResponse()->getHeaders() : null, |
| 127 | + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null |
| 128 | + ); |
| 129 | + } |
| 130 | + |
| 131 | + $statusCode = $response->getStatusCode(); |
| 132 | + |
| 133 | + if ($statusCode < 200 || $statusCode > 299) { |
| 134 | + throw new ApiException( |
| 135 | + sprintf( |
| 136 | + '[%d] Error connecting to the API (%s)', |
| 137 | + $statusCode, |
| 138 | + $request->getUri() |
| 139 | + ), |
| 140 | + $statusCode, |
| 141 | + $response->getHeaders(), |
| 142 | + $response->getBody() |
| 143 | + ); |
| 144 | + } |
| 145 | + |
| 146 | + $responseBody = $response->getBody(); |
| 147 | + if ($returnType === '\SplFileObject') { |
| 148 | + $content = $responseBody; //stream goes to serializer |
| 149 | + } else { |
| 150 | + $content = $responseBody->getContents(); |
| 151 | + if (!in_array($returnType, ['string','integer','bool'])) { |
| 152 | + $content = json_decode($content); |
| 153 | + } |
| 154 | + } |
| 155 | + |
| 156 | + return [ |
| 157 | + ObjectSerializer::deserialize($content, $returnType, []), |
| 158 | + $response->getStatusCode(), |
| 159 | + $response->getHeaders() |
| 160 | + ]; |
| 161 | + |
| 162 | + } catch (ApiException $e) { |
| 163 | + switch ($e->getCode()) { |
| 164 | + case 200: |
| 165 | + $data = ObjectSerializer::deserialize( |
| 166 | + $e->getResponseBody(), |
| 167 | + '\DocPlanner\Client\Model\PullMultipleNotificationsResponse', |
| 168 | + $e->getResponseHeaders() |
| 169 | + ); |
| 170 | + $e->setResponseObject($data); |
| 171 | + break; |
| 172 | + case 404: |
| 173 | + $data = ObjectSerializer::deserialize( |
| 174 | + $e->getResponseBody(), |
| 175 | + '\DocPlanner\Client\Model\Error', |
| 176 | + $e->getResponseHeaders() |
| 177 | + ); |
| 178 | + $e->setResponseObject($data); |
| 179 | + break; |
| 180 | + } |
| 181 | + throw $e; |
| 182 | + } |
| 183 | + } |
| 184 | + |
| 185 | + /** |
| 186 | + * Operation pullMultipleNotificationAsync |
| 187 | + * |
| 188 | + * |
| 189 | + * |
| 190 | + * @param int $limit Maximum number of notifications pulled. Can take value from 1 to 100. If not provided the default value of 1 is applied. (optional) |
| 191 | + * |
| 192 | + * @throws \InvalidArgumentException |
| 193 | + * @return \GuzzleHttp\Promise\PromiseInterface |
| 194 | + */ |
| 195 | + public function pullMultipleNotificationAsync($limit = null) |
| 196 | + { |
| 197 | + return $this->pullMultipleNotificationAsyncWithHttpInfo($limit) |
| 198 | + ->then( |
| 199 | + function ($response) { |
| 200 | + return $response[0]; |
| 201 | + } |
| 202 | + ); |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * Operation pullMultipleNotificationAsyncWithHttpInfo |
| 207 | + * |
| 208 | + * |
| 209 | + * |
| 210 | + * @param int $limit Maximum number of notifications pulled. Can take value from 1 to 100. If not provided the default value of 1 is applied. (optional) |
| 211 | + * |
| 212 | + * @throws \InvalidArgumentException |
| 213 | + * @return \GuzzleHttp\Promise\PromiseInterface |
| 214 | + */ |
| 215 | + public function pullMultipleNotificationAsyncWithHttpInfo($limit = null) |
| 216 | + { |
| 217 | + $returnType = '\DocPlanner\Client\Model\PullMultipleNotificationsResponse'; |
| 218 | + $request = $this->pullMultipleNotificationRequest($limit); |
| 219 | + |
| 220 | + return $this->client |
| 221 | + ->sendAsync($request, $this->createHttpClientOption()) |
| 222 | + ->then( |
| 223 | + function ($response) use ($returnType) { |
| 224 | + $responseBody = $response->getBody(); |
| 225 | + if ($returnType === '\SplFileObject') { |
| 226 | + $content = $responseBody; //stream goes to serializer |
| 227 | + } else { |
| 228 | + $content = $responseBody->getContents(); |
| 229 | + if ($returnType !== 'string') { |
| 230 | + $content = json_decode($content); |
| 231 | + } |
| 232 | + } |
| 233 | + |
| 234 | + return [ |
| 235 | + ObjectSerializer::deserialize($content, $returnType, []), |
| 236 | + $response->getStatusCode(), |
| 237 | + $response->getHeaders() |
| 238 | + ]; |
| 239 | + }, |
| 240 | + function ($exception) { |
| 241 | + $response = $exception->getResponse(); |
| 242 | + $statusCode = $response->getStatusCode(); |
| 243 | + throw new ApiException( |
| 244 | + sprintf( |
| 245 | + '[%d] Error connecting to the API (%s)', |
| 246 | + $statusCode, |
| 247 | + $exception->getRequest()->getUri() |
| 248 | + ), |
| 249 | + $statusCode, |
| 250 | + $response->getHeaders(), |
| 251 | + $response->getBody() |
| 252 | + ); |
| 253 | + } |
| 254 | + ); |
| 255 | + } |
| 256 | + |
| 257 | + /** |
| 258 | + * Create request for operation 'pullMultipleNotification' |
| 259 | + * |
| 260 | + * @param int $limit Maximum number of notifications pulled. Can take value from 1 to 100. If not provided the default value of 1 is applied. (optional) |
| 261 | + * |
| 262 | + * @throws \InvalidArgumentException |
| 263 | + * @return \GuzzleHttp\Psr7\Request |
| 264 | + */ |
| 265 | + protected function pullMultipleNotificationRequest($limit = null) |
| 266 | + { |
| 267 | + |
| 268 | + $resourcePath = '/notifications/multiple'; |
| 269 | + $formParams = []; |
| 270 | + $queryParams = []; |
| 271 | + $headerParams = []; |
| 272 | + $httpBody = ''; |
| 273 | + $multipart = false; |
| 274 | + |
| 275 | + // query params |
| 276 | + if ($limit !== null) { |
| 277 | + $queryParams['limit'] = ObjectSerializer::toQueryValue($limit, null); |
| 278 | + } |
| 279 | + |
| 280 | + |
| 281 | + // body params |
| 282 | + $_tempBody = null; |
| 283 | + |
| 284 | + if ($multipart) { |
| 285 | + $headers = $this->headerSelector->selectHeadersForMultipart( |
| 286 | + ['application/vnd.docplanner+json; charset=UTF-8', 'application/vnd.error+docplanner+json'] |
| 287 | + ); |
| 288 | + } else { |
| 289 | + $headers = $this->headerSelector->selectHeaders( |
| 290 | + ['application/vnd.docplanner+json; charset=UTF-8', 'application/vnd.error+docplanner+json'], |
| 291 | + [] |
| 292 | + ); |
| 293 | + } |
| 294 | + |
| 295 | + // for model (json/xml) |
| 296 | + if (isset($_tempBody)) { |
| 297 | + // $_tempBody is the method argument, if present |
| 298 | + $httpBody = $_tempBody; |
| 299 | + // \stdClass has no __toString(), so we should encode it manually |
| 300 | + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { |
| 301 | + $httpBody = \GuzzleHttp\json_encode($httpBody); |
| 302 | + } |
| 303 | + } elseif (count($formParams) > 0) { |
| 304 | + if ($multipart) { |
| 305 | + $multipartContents = []; |
| 306 | + foreach ($formParams as $formParamName => $formParamValue) { |
| 307 | + $multipartContents[] = [ |
| 308 | + 'name' => $formParamName, |
| 309 | + 'contents' => $formParamValue |
| 310 | + ]; |
| 311 | + } |
| 312 | + // for HTTP post (form) |
| 313 | + $httpBody = new MultipartStream($multipartContents); |
| 314 | + |
| 315 | + } elseif ($headers['Content-Type'] === 'application/json') { |
| 316 | + $httpBody = \GuzzleHttp\json_encode($formParams); |
| 317 | + |
| 318 | + } else { |
| 319 | + // for HTTP post (form) |
| 320 | + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); |
| 321 | + } |
| 322 | + } |
| 323 | + |
| 324 | + // this endpoint requires OAuth (access token) |
| 325 | + if ($this->config->getAccessToken() !== null) { |
| 326 | + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); |
| 327 | + } |
| 328 | + |
| 329 | + $defaultHeaders = []; |
| 330 | + if ($this->config->getUserAgent()) { |
| 331 | + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); |
| 332 | + } |
| 333 | + |
| 334 | + $headers = array_merge( |
| 335 | + $defaultHeaders, |
| 336 | + $headerParams, |
| 337 | + $headers |
| 338 | + ); |
| 339 | + |
| 340 | + $query = \GuzzleHttp\Psr7\build_query($queryParams); |
| 341 | + return new Request( |
| 342 | + 'GET', |
| 343 | + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), |
| 344 | + $headers, |
| 345 | + $httpBody |
| 346 | + ); |
| 347 | + } |
| 348 | + |
89 | 349 | /**
|
90 | 350 | * Operation pullNotification
|
91 | 351 | *
|
|
0 commit comments