11<?php
22/**
33 * AuditLogsApi
4- * PHP version 7.4
4+ * PHP version 8.1
55 *
66 * @category Class
77 * @package HubSpot\Client\Cms\AuditLogs
1616 *
1717 * The version of the OpenAPI document: v3
1818 * Generated by: https://openapi-generator.tech
19- * Generator version: 7.12 .0
19+ * Generator version: 7.17 .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 \Cms \AuditLogs \ApiException ;
3840use HubSpot \Client \Cms \AuditLogs \Configuration ;
41+ use HubSpot \Client \Cms \AuditLogs \FormDataProcessor ;
3942use HubSpot \Client \Cms \AuditLogs \HeaderSelector ;
4043use HubSpot \Client \Cms \AuditLogs \ObjectSerializer ;
4144
@@ -195,61 +198,21 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
195198
196199 switch ($ statusCode ) {
197200 case 200 :
198- if ('\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' === '\SplFileObject ' ) {
199- $ content = $ response ->getBody (); //stream goes to serializer
200- } else {
201- $ content = (string ) $ response ->getBody ();
202- if ('\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' !== 'string ' ) {
203- try {
204- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
205- } catch (\JsonException $ exception ) {
206- throw new ApiException (
207- sprintf (
208- 'Error JSON decoding server response (%s) ' ,
209- $ request ->getUri ()
210- ),
211- $ statusCode ,
212- $ response ->getHeaders (),
213- $ content
214- );
215- }
216- }
217- }
218-
219- return [
220- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' , []),
221- $ response ->getStatusCode (),
222- $ response ->getHeaders ()
223- ];
201+ return $ this ->handleResponseWithDataType (
202+ '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' ,
203+ $ request ,
204+ $ response ,
205+ );
224206 default :
225- if ('\HubSpot\Client\Cms\AuditLogs\Model\Error ' === '\SplFileObject ' ) {
226- $ content = $ response ->getBody (); //stream goes to serializer
227- } else {
228- $ content = (string ) $ response ->getBody ();
229- if ('\HubSpot\Client\Cms\AuditLogs\Model\Error ' !== 'string ' ) {
230- try {
231- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
232- } catch (\JsonException $ exception ) {
233- throw new ApiException (
234- sprintf (
235- 'Error JSON decoding server response (%s) ' ,
236- $ request ->getUri ()
237- ),
238- $ statusCode ,
239- $ response ->getHeaders (),
240- $ content
241- );
242- }
243- }
244- }
245-
246- return [
247- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Cms\AuditLogs\Model\Error ' , []),
248- $ response ->getStatusCode (),
249- $ response ->getHeaders ()
250- ];
207+ return $ this ->handleResponseWithDataType (
208+ '\HubSpot\Client\Cms\AuditLogs\Model\Error ' ,
209+ $ request ,
210+ $ response ,
211+ );
251212 }
252213
214+
215+
253216 if ($ statusCode < 200 || $ statusCode > 299 ) {
254217 throw new ApiException (
255218 sprintf (
@@ -263,34 +226,11 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
263226 );
264227 }
265228
266- $ returnType = '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' ;
267- if ($ returnType === '\SplFileObject ' ) {
268- $ content = $ response ->getBody (); //stream goes to serializer
269- } else {
270- $ content = (string ) $ response ->getBody ();
271- if ($ returnType !== 'string ' ) {
272- try {
273- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
274- } catch (\JsonException $ exception ) {
275- throw new ApiException (
276- sprintf (
277- 'Error JSON decoding server response (%s) ' ,
278- $ request ->getUri ()
279- ),
280- $ statusCode ,
281- $ response ->getHeaders (),
282- $ content
283- );
284- }
285- }
286- }
287-
288- return [
289- ObjectSerializer::deserialize ($ content , $ returnType , []),
290- $ response ->getStatusCode (),
291- $ response ->getHeaders ()
292- ];
293-
229+ return $ this ->handleResponseWithDataType (
230+ '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog ' ,
231+ $ request ,
232+ $ response ,
233+ );
294234 } catch (ApiException $ e ) {
295235 switch ($ e ->getCode ()) {
296236 case 200 :
@@ -300,16 +240,18 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
300240 $ e ->getResponseHeaders ()
301241 );
302242 $ e ->setResponseObject ($ data );
303- break ;
243+ throw $ e ;
304244 default :
305245 $ data = ObjectSerializer::deserialize (
306246 $ e ->getResponseBody (),
307247 '\HubSpot\Client\Cms\AuditLogs\Model\Error ' ,
308248 $ e ->getResponseHeaders ()
309249 );
310250 $ e ->setResponseObject ($ data );
311- break ;
251+ throw $ e ;
312252 }
253+
254+
313255 throw $ e ;
314256 }
315257 }
@@ -585,6 +527,57 @@ protected function createHttpClientOption()
585527 }
586528 }
587529
530+ if ($ this ->config ->getCertFile ()) {
531+ $ options [RequestOptions::CERT ] = $ this ->config ->getCertFile ();
532+ }
533+
534+ if ($ this ->config ->getKeyFile ()) {
535+ $ options [RequestOptions::SSL_KEY ] = $ this ->config ->getKeyFile ();
536+ }
537+
588538 return $ options ;
589539 }
540+
541+ private function handleResponseWithDataType (
542+ string $ dataType ,
543+ RequestInterface $ request ,
544+ ResponseInterface $ response
545+ ): array {
546+ if ($ dataType === '\SplFileObject ' ) {
547+ $ content = $ response ->getBody (); //stream goes to serializer
548+ } else {
549+ $ content = (string ) $ response ->getBody ();
550+ if ($ dataType !== 'string ' ) {
551+ try {
552+ $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
553+ } catch (\JsonException $ exception ) {
554+ throw new ApiException (
555+ sprintf (
556+ 'Error JSON decoding server response (%s) ' ,
557+ $ request ->getUri ()
558+ ),
559+ $ response ->getStatusCode (),
560+ $ response ->getHeaders (),
561+ $ content
562+ );
563+ }
564+ }
565+ }
566+
567+ return [
568+ ObjectSerializer::deserialize ($ content , $ dataType , []),
569+ $ response ->getStatusCode (),
570+ $ response ->getHeaders ()
571+ ];
572+ }
573+
574+ private function responseWithinRangeCode (
575+ string $ rangeCode ,
576+ int $ statusCode
577+ ): bool {
578+ $ left = (int ) ($ rangeCode [0 ].'00 ' );
579+ $ right = (int ) ($ rangeCode [0 ].'99 ' );
580+
581+ return $ statusCode >= $ left && $ statusCode <= $ right ;
582+ }
590583}
0 commit comments