11<?php
22/**
33 * ReportApi
4- * PHP version 7.4
4+ * PHP version 8.1
55 *
66 * @category Class
77 * @package HubSpot\Client\Crm\Associations\V4
1212/**
1313 * Associations
1414 *
15- * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
15+ * Basepom for all HubSpot Projects
1616 *
1717 * The version of the OpenAPI document: v4
1818 * Generated by: https://openapi-generator.tech
19- * Generator version: 7.12 .0
19+ * Generator version: 7.18 .0
2020 */
2121
2222/**
3434use GuzzleHttp \Psr7 \MultipartStream ;
3535use GuzzleHttp \Psr7 \Request ;
3636use GuzzleHttp \RequestOptions ;
37+ use Psr \Http \Message \RequestInterface ;
38+ use Psr \Http \Message \ResponseInterface ;
3739use HubSpot \Client \Crm \Associations \V4 \ApiException ;
3840use HubSpot \Client \Crm \Associations \V4 \Configuration ;
41+ use HubSpot \Client \Crm \Associations \V4 \FormDataProcessor ;
3942use HubSpot \Client \Crm \Associations \V4 \HeaderSelector ;
4043use HubSpot \Client \Crm \Associations \V4 \ObjectSerializer ;
4144
@@ -127,7 +130,7 @@ public function getConfig()
127130 *
128131 * Report
129132 *
130- * @param int $user_id (required)
133+ * @param int $user_id The user for the report (required)
131134 * @param string $contentType The value for the Content-Type header. Check self::contentTypes['request'] to see the possible values for this operation
132135 *
133136 * @throws \HubSpot\Client\Crm\Associations\V4\ApiException on non-2xx response or if the response body is not in the expected format
@@ -145,7 +148,7 @@ public function request($user_id, string $contentType = self::contentTypes['requ
145148 *
146149 * Report
147150 *
148- * @param int $user_id (required)
151+ * @param int $user_id The user for the report (required)
149152 * @param string $contentType The value for the Content-Type header. Check self::contentTypes['request'] to see the possible values for this operation
150153 *
151154 * @throws \HubSpot\Client\Crm\Associations\V4\ApiException on non-2xx response or if the response body is not in the expected format
@@ -181,61 +184,21 @@ public function requestWithHttpInfo($user_id, string $contentType = self::conten
181184
182185 switch ($ statusCode ) {
183186 case 200 :
184- if ('\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' === '\SplFileObject ' ) {
185- $ content = $ response ->getBody (); //stream goes to serializer
186- } else {
187- $ content = (string ) $ response ->getBody ();
188- if ('\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' !== 'string ' ) {
189- try {
190- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
191- } catch (\JsonException $ exception ) {
192- throw new ApiException (
193- sprintf (
194- 'Error JSON decoding server response (%s) ' ,
195- $ request ->getUri ()
196- ),
197- $ statusCode ,
198- $ response ->getHeaders (),
199- $ content
200- );
201- }
202- }
203- }
204-
205- return [
206- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' , []),
207- $ response ->getStatusCode (),
208- $ response ->getHeaders ()
209- ];
187+ return $ this ->handleResponseWithDataType (
188+ '\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' ,
189+ $ request ,
190+ $ response ,
191+ );
210192 default :
211- if ('\HubSpot\Client\Crm\Associations\V4\Model\Error ' === '\SplFileObject ' ) {
212- $ content = $ response ->getBody (); //stream goes to serializer
213- } else {
214- $ content = (string ) $ response ->getBody ();
215- if ('\HubSpot\Client\Crm\Associations\V4\Model\Error ' !== 'string ' ) {
216- try {
217- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
218- } catch (\JsonException $ exception ) {
219- throw new ApiException (
220- sprintf (
221- 'Error JSON decoding server response (%s) ' ,
222- $ request ->getUri ()
223- ),
224- $ statusCode ,
225- $ response ->getHeaders (),
226- $ content
227- );
228- }
229- }
230- }
231-
232- return [
233- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Crm\Associations\V4\Model\Error ' , []),
234- $ response ->getStatusCode (),
235- $ response ->getHeaders ()
236- ];
193+ return $ this ->handleResponseWithDataType (
194+ '\HubSpot\Client\Crm\Associations\V4\Model\Error ' ,
195+ $ request ,
196+ $ response ,
197+ );
237198 }
238199
200+
201+
239202 if ($ statusCode < 200 || $ statusCode > 299 ) {
240203 throw new ApiException (
241204 sprintf (
@@ -249,34 +212,11 @@ public function requestWithHttpInfo($user_id, string $contentType = self::conten
249212 );
250213 }
251214
252- $ returnType = '\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' ;
253- if ($ returnType === '\SplFileObject ' ) {
254- $ content = $ response ->getBody (); //stream goes to serializer
255- } else {
256- $ content = (string ) $ response ->getBody ();
257- if ($ returnType !== 'string ' ) {
258- try {
259- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
260- } catch (\JsonException $ exception ) {
261- throw new ApiException (
262- sprintf (
263- 'Error JSON decoding server response (%s) ' ,
264- $ request ->getUri ()
265- ),
266- $ statusCode ,
267- $ response ->getHeaders (),
268- $ content
269- );
270- }
271- }
272- }
273-
274- return [
275- ObjectSerializer::deserialize ($ content , $ returnType , []),
276- $ response ->getStatusCode (),
277- $ response ->getHeaders ()
278- ];
279-
215+ return $ this ->handleResponseWithDataType (
216+ '\HubSpot\Client\Crm\Associations\V4\Model\ReportCreationResponse ' ,
217+ $ request ,
218+ $ response ,
219+ );
280220 } catch (ApiException $ e ) {
281221 switch ($ e ->getCode ()) {
282222 case 200 :
@@ -286,16 +226,18 @@ public function requestWithHttpInfo($user_id, string $contentType = self::conten
286226 $ e ->getResponseHeaders ()
287227 );
288228 $ e ->setResponseObject ($ data );
289- break ;
229+ throw $ e ;
290230 default :
291231 $ data = ObjectSerializer::deserialize (
292232 $ e ->getResponseBody (),
293233 '\HubSpot\Client\Crm\Associations\V4\Model\Error ' ,
294234 $ e ->getResponseHeaders ()
295235 );
296236 $ e ->setResponseObject ($ data );
297- break ;
237+ throw $ e ;
298238 }
239+
240+
299241 throw $ e ;
300242 }
301243 }
@@ -305,7 +247,7 @@ public function requestWithHttpInfo($user_id, string $contentType = self::conten
305247 *
306248 * Report
307249 *
308- * @param int $user_id (required)
250+ * @param int $user_id The user for the report (required)
309251 * @param string $contentType The value for the Content-Type header. Check self::contentTypes['request'] to see the possible values for this operation
310252 *
311253 * @throws \InvalidArgumentException
@@ -326,7 +268,7 @@ function ($response) {
326268 *
327269 * Report
328270 *
329- * @param int $user_id (required)
271+ * @param int $user_id The user for the report (required)
330272 * @param string $contentType The value for the Content-Type header. Check self::contentTypes['request'] to see the possible values for this operation
331273 *
332274 * @throws \InvalidArgumentException
@@ -376,7 +318,7 @@ function ($exception) {
376318 /**
377319 * Create request for operation 'request'
378320 *
379- * @param int $user_id (required)
321+ * @param int $user_id The user for the report (required)
380322 * @param string $contentType The value for the Content-Type header. Check self::contentTypes['request'] to see the possible values for this operation
381323 *
382324 * @throws \InvalidArgumentException
@@ -485,6 +427,57 @@ protected function createHttpClientOption()
485427 }
486428 }
487429
430+ if ($ this ->config ->getCertFile ()) {
431+ $ options [RequestOptions::CERT ] = $ this ->config ->getCertFile ();
432+ }
433+
434+ if ($ this ->config ->getKeyFile ()) {
435+ $ options [RequestOptions::SSL_KEY ] = $ this ->config ->getKeyFile ();
436+ }
437+
488438 return $ options ;
489439 }
440+
441+ private function handleResponseWithDataType (
442+ string $ dataType ,
443+ RequestInterface $ request ,
444+ ResponseInterface $ response
445+ ): array {
446+ if ($ dataType === '\SplFileObject ' ) {
447+ $ content = $ response ->getBody (); //stream goes to serializer
448+ } else {
449+ $ content = (string ) $ response ->getBody ();
450+ if ($ dataType !== 'string ' ) {
451+ try {
452+ $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
453+ } catch (\JsonException $ exception ) {
454+ throw new ApiException (
455+ sprintf (
456+ 'Error JSON decoding server response (%s) ' ,
457+ $ request ->getUri ()
458+ ),
459+ $ response ->getStatusCode (),
460+ $ response ->getHeaders (),
461+ $ content
462+ );
463+ }
464+ }
465+ }
466+
467+ return [
468+ ObjectSerializer::deserialize ($ content , $ dataType , []),
469+ $ response ->getStatusCode (),
470+ $ response ->getHeaders ()
471+ ];
472+ }
473+
474+ private function responseWithinRangeCode (
475+ string $ rangeCode ,
476+ int $ statusCode
477+ ): bool {
478+ $ left = (int ) ($ rangeCode [0 ].'00 ' );
479+ $ right = (int ) ($ rangeCode [0 ].'99 ' );
480+
481+ return $ statusCode >= $ left && $ statusCode <= $ right ;
482+ }
490483}
0 commit comments