11<?php
22/**
33 * SearchApi
4- * PHP version 7.4
4+ * PHP version 8.1
55 *
66 * @category Class
77 * @package HubSpot\Client\Crm\Objects
1616 *
1717 * The version of the OpenAPI document: v3
1818 * Generated by: https://openapi-generator.tech
19- * OpenAPI Generator version: 7.3 .0
19+ * Generator version: 7.19 .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 \Objects \ApiException ;
3840use HubSpot \Client \Crm \Objects \Configuration ;
41+ use HubSpot \Client \Crm \Objects \FormDataProcessor ;
3942use HubSpot \Client \Crm \Objects \HeaderSelector ;
4043use HubSpot \Client \Crm \Objects \ObjectSerializer ;
4144
@@ -83,13 +86,13 @@ class SearchApi
8386 * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
8487 */
8588 public function __construct (
86- ClientInterface $ client = null ,
87- Configuration $ config = null ,
88- HeaderSelector $ selector = null ,
89- $ hostIndex = 0
89+ ? ClientInterface $ client = null ,
90+ ? Configuration $ config = null ,
91+ ? HeaderSelector $ selector = null ,
92+ int $ hostIndex = 0
9093 ) {
9194 $ this ->client = $ client ?: new Client ();
92- $ this ->config = $ config ?: new Configuration ();
95+ $ this ->config = $ config ?: Configuration:: getDefaultConfiguration ();
9396 $ this ->headerSelector = $ selector ?: new HeaderSelector ();
9497 $ this ->hostIndex = $ hostIndex ;
9598 }
@@ -131,7 +134,7 @@ public function getConfig()
131134 *
132135 * @throws \HubSpot\Client\Crm\Objects\ApiException on non-2xx response or if the response body is not in the expected format
133136 * @throws \InvalidArgumentException
134- * @return \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging |\HubSpot\Client\Crm\Objects\Model\Error
137+ * @return \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject |\HubSpot\Client\Crm\Objects\Model\Error
135138 */
136139 public function doSearch ($ object_type , $ public_object_search_request , string $ contentType = self ::contentTypes['doSearch ' ][0 ])
137140 {
@@ -148,7 +151,7 @@ public function doSearch($object_type, $public_object_search_request, string $co
148151 *
149152 * @throws \HubSpot\Client\Crm\Objects\ApiException on non-2xx response or if the response body is not in the expected format
150153 * @throws \InvalidArgumentException
151- * @return array of \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging |\HubSpot\Client\Crm\Objects\Model\Error, HTTP status code, HTTP response headers (array of strings)
154+ * @return array of \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject |\HubSpot\Client\Crm\Objects\Model\Error, HTTP status code, HTTP response headers (array of strings)
152155 */
153156 public function doSearchWithHttpInfo ($ object_type , $ public_object_search_request , string $ contentType = self ::contentTypes['doSearch ' ][0 ])
154157 {
@@ -176,6 +179,24 @@ public function doSearchWithHttpInfo($object_type, $public_object_search_request
176179
177180 $ statusCode = $ response ->getStatusCode ();
178181
182+
183+ switch ($ statusCode ) {
184+ case 200 :
185+ return $ this ->handleResponseWithDataType (
186+ '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject ' ,
187+ $ request ,
188+ $ response ,
189+ );
190+ default :
191+ return $ this ->handleResponseWithDataType (
192+ '\HubSpot\Client\Crm\Objects\Model\Error ' ,
193+ $ request ,
194+ $ response ,
195+ );
196+ }
197+
198+
199+
179200 if ($ statusCode < 200 || $ statusCode > 299 ) {
180201 throw new ApiException (
181202 sprintf (
@@ -189,110 +210,32 @@ public function doSearchWithHttpInfo($object_type, $public_object_search_request
189210 );
190211 }
191212
192- switch ($ statusCode ) {
193- case 200 :
194- if ('\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' === '\SplFileObject ' ) {
195- $ content = $ response ->getBody (); //stream goes to serializer
196- } else {
197- $ content = (string ) $ response ->getBody ();
198- if ('\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' !== 'string ' ) {
199- try {
200- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
201- } catch (\JsonException $ exception ) {
202- throw new ApiException (
203- sprintf (
204- 'Error JSON decoding server response (%s) ' ,
205- $ request ->getUri ()
206- ),
207- $ statusCode ,
208- $ response ->getHeaders (),
209- $ content
210- );
211- }
212- }
213- }
214-
215- return [
216- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' , []),
217- $ response ->getStatusCode (),
218- $ response ->getHeaders ()
219- ];
220- default :
221- if ('\HubSpot\Client\Crm\Objects\Model\Error ' === '\SplFileObject ' ) {
222- $ content = $ response ->getBody (); //stream goes to serializer
223- } else {
224- $ content = (string ) $ response ->getBody ();
225- if ('\HubSpot\Client\Crm\Objects\Model\Error ' !== 'string ' ) {
226- try {
227- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
228- } catch (\JsonException $ exception ) {
229- throw new ApiException (
230- sprintf (
231- 'Error JSON decoding server response (%s) ' ,
232- $ request ->getUri ()
233- ),
234- $ statusCode ,
235- $ response ->getHeaders (),
236- $ content
237- );
238- }
239- }
240- }
241-
242- return [
243- ObjectSerializer::deserialize ($ content , '\HubSpot\Client\Crm\Objects\Model\Error ' , []),
244- $ response ->getStatusCode (),
245- $ response ->getHeaders ()
246- ];
247- }
248-
249- $ returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' ;
250- if ($ returnType === '\SplFileObject ' ) {
251- $ content = $ response ->getBody (); //stream goes to serializer
252- } else {
253- $ content = (string ) $ response ->getBody ();
254- if ($ returnType !== 'string ' ) {
255- try {
256- $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
257- } catch (\JsonException $ exception ) {
258- throw new ApiException (
259- sprintf (
260- 'Error JSON decoding server response (%s) ' ,
261- $ request ->getUri ()
262- ),
263- $ statusCode ,
264- $ response ->getHeaders (),
265- $ content
266- );
267- }
268- }
269- }
270-
271- return [
272- ObjectSerializer::deserialize ($ content , $ returnType , []),
273- $ response ->getStatusCode (),
274- $ response ->getHeaders ()
275- ];
276-
213+ return $ this ->handleResponseWithDataType (
214+ '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject ' ,
215+ $ request ,
216+ $ response ,
217+ );
277218 } catch (ApiException $ e ) {
278219 switch ($ e ->getCode ()) {
279220 case 200 :
280221 $ data = ObjectSerializer::deserialize (
281222 $ e ->getResponseBody (),
282- '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' ,
223+ '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject ' ,
283224 $ e ->getResponseHeaders ()
284225 );
285226 $ e ->setResponseObject ($ data );
286- break ;
227+ throw $ e ;
287228 default :
288229 $ data = ObjectSerializer::deserialize (
289230 $ e ->getResponseBody (),
290231 '\HubSpot\Client\Crm\Objects\Model\Error ' ,
291232 $ e ->getResponseHeaders ()
292233 );
293234 $ e ->setResponseObject ($ data );
294- break ;
235+ throw $ e ;
295236 }
237+
238+
296239 throw $ e ;
297240 }
298241 }
@@ -329,7 +272,7 @@ function ($response) {
329272 */
330273 public function doSearchAsyncWithHttpInfo ($ object_type , $ public_object_search_request , string $ contentType = self ::contentTypes['doSearch ' ][0 ])
331274 {
332- $ returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging ' ;
275+ $ returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject ' ;
333276 $ request = $ this ->doSearchRequest ($ object_type , $ public_object_search_request , $ contentType );
334277
335278 return $ this ->client
@@ -495,6 +438,57 @@ protected function createHttpClientOption()
495438 }
496439 }
497440
441+ if ($ this ->config ->getCertFile ()) {
442+ $ options [RequestOptions::CERT ] = $ this ->config ->getCertFile ();
443+ }
444+
445+ if ($ this ->config ->getKeyFile ()) {
446+ $ options [RequestOptions::SSL_KEY ] = $ this ->config ->getKeyFile ();
447+ }
448+
498449 return $ options ;
499450 }
451+
452+ private function handleResponseWithDataType (
453+ string $ dataType ,
454+ RequestInterface $ request ,
455+ ResponseInterface $ response
456+ ): array {
457+ if ($ dataType === '\SplFileObject ' ) {
458+ $ content = $ response ->getBody (); //stream goes to serializer
459+ } else {
460+ $ content = (string ) $ response ->getBody ();
461+ if ($ dataType !== 'string ' ) {
462+ try {
463+ $ content = json_decode ($ content , false , 512 , JSON_THROW_ON_ERROR );
464+ } catch (\JsonException $ exception ) {
465+ throw new ApiException (
466+ sprintf (
467+ 'Error JSON decoding server response (%s) ' ,
468+ $ request ->getUri ()
469+ ),
470+ $ response ->getStatusCode (),
471+ $ response ->getHeaders (),
472+ $ content
473+ );
474+ }
475+ }
476+ }
477+
478+ return [
479+ ObjectSerializer::deserialize ($ content , $ dataType , []),
480+ $ response ->getStatusCode (),
481+ $ response ->getHeaders ()
482+ ];
483+ }
484+
485+ private function responseWithinRangeCode (
486+ string $ rangeCode ,
487+ int $ statusCode
488+ ): bool {
489+ $ left = (int ) ($ rangeCode [0 ].'00 ' );
490+ $ right = (int ) ($ rangeCode [0 ].'99 ' );
491+
492+ return $ statusCode >= $ left && $ statusCode <= $ right ;
493+ }
500494}
0 commit comments