diff --git a/codegen/Crm/Pipelines/Api/PipelineAuditsApi.php b/codegen/Crm/Pipelines/Api/PipelineAuditsApi.php index 3e5e9423..1c7f421e 100644 --- a/codegen/Crm/Pipelines/Api/PipelineAuditsApi.php +++ b/codegen/Crm/Pipelines/Api/PipelineAuditsApi.php @@ -1,7 +1,7 @@ getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -251,34 +214,11 @@ public function getAuditWithHttpInfo($object_type, $pipeline_id, string $content ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -288,7 +228,7 @@ public function getAuditWithHttpInfo($object_type, $pipeline_id, string $content $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -296,8 +236,10 @@ public function getAuditWithHttpInfo($object_type, $pipeline_id, string $content $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -505,6 +447,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Pipelines/Api/PipelineStageAuditsApi.php b/codegen/Crm/Pipelines/Api/PipelineStageAuditsApi.php index 485d57e0..ad763810 100644 --- a/codegen/Crm/Pipelines/Api/PipelineStageAuditsApi.php +++ b/codegen/Crm/Pipelines/Api/PipelineStageAuditsApi.php @@ -1,7 +1,7 @@ getAuditWithHttpInfo($object_type, $stage_id, $contentType); + list($response) = $this->getAuditWithHttpInfo($object_type, $stage_id, $pipeline_id, $contentType); return $response; } /** * Operation getAuditWithHttpInfo * - * Return an audit of all changes to the pipeline stage - * * @param string $object_type (required) * @param string $stage_id (required) + * @param string $pipeline_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAudit'] to see the possible values for this operation * * @throws \HubSpot\Client\Crm\Pipelines\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging|\HubSpot\Client\Crm\Pipelines\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function getAuditWithHttpInfo($object_type, $stage_id, string $contentType = self::contentTypes['getAudit'][0]) + public function getAuditWithHttpInfo($object_type, $stage_id, $pipeline_id, string $contentType = self::contentTypes['getAudit'][0]) { - $request = $this->getAuditRequest($object_type, $stage_id, $contentType); + $request = $this->getAuditRequest($object_type, $stage_id, $pipeline_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -183,61 +184,21 @@ public function getAuditWithHttpInfo($object_type, $stage_id, string $contentTyp switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -251,34 +212,11 @@ public function getAuditWithHttpInfo($object_type, $stage_id, string $contentTyp ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -288,7 +226,7 @@ public function getAuditWithHttpInfo($object_type, $stage_id, string $contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -296,8 +234,10 @@ public function getAuditWithHttpInfo($object_type, $stage_id, string $contentTyp $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -305,18 +245,17 @@ public function getAuditWithHttpInfo($object_type, $stage_id, string $contentTyp /** * Operation getAuditAsync * - * Return an audit of all changes to the pipeline stage - * * @param string $object_type (required) * @param string $stage_id (required) + * @param string $pipeline_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAudit'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getAuditAsync($object_type, $stage_id, string $contentType = self::contentTypes['getAudit'][0]) + public function getAuditAsync($object_type, $stage_id, $pipeline_id, string $contentType = self::contentTypes['getAudit'][0]) { - return $this->getAuditAsyncWithHttpInfo($object_type, $stage_id, $contentType) + return $this->getAuditAsyncWithHttpInfo($object_type, $stage_id, $pipeline_id, $contentType) ->then( function ($response) { return $response[0]; @@ -327,19 +266,18 @@ function ($response) { /** * Operation getAuditAsyncWithHttpInfo * - * Return an audit of all changes to the pipeline stage - * * @param string $object_type (required) * @param string $stage_id (required) + * @param string $pipeline_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAudit'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getAuditAsyncWithHttpInfo($object_type, $stage_id, string $contentType = self::contentTypes['getAudit'][0]) + public function getAuditAsyncWithHttpInfo($object_type, $stage_id, $pipeline_id, string $contentType = self::contentTypes['getAudit'][0]) { $returnType = '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePublicAuditInfoNoPaging'; - $request = $this->getAuditRequest($object_type, $stage_id, $contentType); + $request = $this->getAuditRequest($object_type, $stage_id, $pipeline_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -382,12 +320,13 @@ function ($exception) { * * @param string $object_type (required) * @param string $stage_id (required) + * @param string $pipeline_id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAudit'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getAuditRequest($object_type, $stage_id, string $contentType = self::contentTypes['getAudit'][0]) + public function getAuditRequest($object_type, $stage_id, $pipeline_id, string $contentType = self::contentTypes['getAudit'][0]) { // verify the required parameter 'object_type' is set @@ -404,6 +343,16 @@ public function getAuditRequest($object_type, $stage_id, string $contentType = s ); } + // verify the required parameter 'pipeline_id' is set + if ($pipeline_id === null || (is_array($pipeline_id) && count($pipeline_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $pipeline_id when calling getAudit' + ); + } + if (!preg_match("/.+/", $pipeline_id)) { + throw new \InvalidArgumentException("invalid value for \"pipeline_id\" when calling PipelineStageAuditsApi.getAudit, must conform to the pattern /.+/."); + } + $resourcePath = '/crm/v3/pipelines/{objectType}/{pipelineId}/stages/{stageId}/audit'; $formParams = []; @@ -430,6 +379,14 @@ public function getAuditRequest($object_type, $stage_id, string $contentType = s $resourcePath ); } + // path params + if ($pipeline_id !== null) { + $resourcePath = str_replace( + '{' . 'pipelineId' . '}', + ObjectSerializer::toPathValue($pipeline_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -505,6 +462,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Pipelines/Api/PipelineStagesApi.php b/codegen/Crm/Pipelines/Api/PipelineStagesApi.php index a73c55f6..a65b5bab 100644 --- a/codegen/Crm/Pipelines/Api/PipelineStagesApi.php +++ b/codegen/Crm/Pipelines/Api/PipelineStagesApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -208,8 +210,10 @@ public function archiveWithHttpInfo($object_type, $pipeline_id, $stage_id, strin $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -469,61 +473,21 @@ public function createWithHttpInfo($object_type, $pipeline_id, $pipeline_stage_i switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -537,34 +501,11 @@ public function createWithHttpInfo($object_type, $pipeline_id, $pipeline_stage_i ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -574,7 +515,7 @@ public function createWithHttpInfo($object_type, $pipeline_id, $pipeline_stage_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -582,8 +523,10 @@ public function createWithHttpInfo($object_type, $pipeline_id, $pipeline_stage_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -853,61 +796,21 @@ public function getAllWithHttpInfo($object_type, $pipeline_id, string $contentTy switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -921,34 +824,11 @@ public function getAllWithHttpInfo($object_type, $pipeline_id, string $contentTy ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineStageNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -958,7 +838,7 @@ public function getAllWithHttpInfo($object_type, $pipeline_id, string $contentTy $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -966,8 +846,10 @@ public function getAllWithHttpInfo($object_type, $pipeline_id, string $contentTy $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1222,61 +1104,21 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, $stage_id, strin switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1290,34 +1132,11 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, $stage_id, strin ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1327,7 +1146,7 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, $stage_id, strin $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1335,8 +1154,10 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, $stage_id, strin $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1611,61 +1432,21 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipe switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1679,34 +1460,11 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipe ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1716,7 +1474,7 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipe $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1724,8 +1482,10 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipe $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1955,8 +1715,6 @@ public function replaceRequest($object_type, $pipeline_id, $stage_id, $pipeline_ /** * Operation update * - * Update a pipeline stage - * * @param string $object_type object_type (required) * @param string $pipeline_id pipeline_id (required) * @param string $stage_id stage_id (required) @@ -1976,8 +1734,6 @@ public function update($object_type, $pipeline_id, $stage_id, $pipeline_stage_pa /** * Operation updateWithHttpInfo * - * Update a pipeline stage - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param string $stage_id (required) @@ -2017,61 +1773,21 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipel switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\PipelineStage' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2085,34 +1801,11 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipel ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\PipelineStage', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -2122,7 +1815,7 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipel $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2130,8 +1823,10 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipel $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2139,8 +1834,6 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $stage_id, $pipel /** * Operation updateAsync * - * Update a pipeline stage - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param string $stage_id (required) @@ -2163,8 +1856,6 @@ function ($response) { /** * Operation updateAsyncWithHttpInfo * - * Update a pipeline stage - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param string $stage_id (required) @@ -2374,6 +2065,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Pipelines/Api/PipelinesApi.php b/codegen/Crm/Pipelines/Api/PipelinesApi.php index 68f5695e..ac343753 100644 --- a/codegen/Crm/Pipelines/Api/PipelinesApi.php +++ b/codegen/Crm/Pipelines/Api/PipelinesApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -210,8 +212,10 @@ public function archiveWithHttpInfo($object_type, $pipeline_id, $validate_refere $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -477,61 +481,21 @@ public function createWithHttpInfo($object_type, $pipeline_input, string $conten switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -545,34 +509,11 @@ public function createWithHttpInfo($object_type, $pipeline_input, string $conten ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\Pipeline'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -582,7 +523,7 @@ public function createWithHttpInfo($object_type, $pipeline_input, string $conten $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -590,8 +531,10 @@ public function createWithHttpInfo($object_type, $pipeline_input, string $conten $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -841,61 +784,21 @@ public function getAllWithHttpInfo($object_type, string $contentType = self::con switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -909,34 +812,11 @@ public function getAllWithHttpInfo($object_type, string $contentType = self::con ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\CollectionResponsePipelineNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -946,7 +826,7 @@ public function getAllWithHttpInfo($object_type, string $contentType = self::con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -954,8 +834,10 @@ public function getAllWithHttpInfo($object_type, string $contentType = self::con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1190,61 +1072,21 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, string $contentT switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1258,34 +1100,11 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, string $contentT ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\Pipeline'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1295,7 +1114,7 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, string $contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1303,8 +1122,10 @@ public function getByIdWithHttpInfo($object_type, $pipeline_id, string $contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1563,61 +1384,21 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $pipeline_input, switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1631,34 +1412,11 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $pipeline_input, ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\Pipeline'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1668,7 +1426,7 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $pipeline_input, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1676,8 +1434,10 @@ public function replaceWithHttpInfo($object_type, $pipeline_id, $pipeline_input, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1915,8 +1675,6 @@ public function replaceRequest($object_type, $pipeline_id, $pipeline_input, $val /** * Operation update * - * Update a pipeline - * * @param string $object_type object_type (required) * @param string $pipeline_id pipeline_id (required) * @param \HubSpot\Client\Crm\Pipelines\Model\PipelinePatchInput $pipeline_patch_input pipeline_patch_input (required) @@ -1937,8 +1695,6 @@ public function update($object_type, $pipeline_id, $pipeline_patch_input, $valid /** * Operation updateWithHttpInfo * - * Update a pipeline - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param \HubSpot\Client\Crm\Pipelines\Model\PipelinePatchInput $pipeline_patch_input (required) @@ -1979,61 +1735,21 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $pipeline_patch_i switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Pipeline' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Pipelines\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Pipelines\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2047,34 +1763,11 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $pipeline_patch_i ); } - $returnType = '\HubSpot\Client\Crm\Pipelines\Model\Pipeline'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Pipelines\Model\Pipeline', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -2084,7 +1777,7 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $pipeline_patch_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2092,8 +1785,10 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $pipeline_patch_i $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2101,8 +1796,6 @@ public function updateWithHttpInfo($object_type, $pipeline_id, $pipeline_patch_i /** * Operation updateAsync * - * Update a pipeline - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param \HubSpot\Client\Crm\Pipelines\Model\PipelinePatchInput $pipeline_patch_input (required) @@ -2126,8 +1819,6 @@ function ($response) { /** * Operation updateAsyncWithHttpInfo * - * Update a pipeline - * * @param string $object_type (required) * @param string $pipeline_id (required) * @param \HubSpot\Client\Crm\Pipelines\Model\PipelinePatchInput $pipeline_patch_input (required) @@ -2344,6 +2035,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Pipelines/ApiException.php b/codegen/Crm/Pipelines/ApiException.php index 3638a888..23bd4fa1 100644 --- a/codegen/Crm/Pipelines/ApiException.php +++ b/codegen/Crm/Pipelines/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Crm/Pipelines/FormDataProcessor.php b/codegen/Crm/Pipelines/FormDataProcessor.php new file mode 100644 index 00000000..5ddd5816 --- /dev/null +++ b/codegen/Crm/Pipelines/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Crm/Pipelines/HeaderSelector.php b/codegen/Crm/Pipelines/HeaderSelector.php index d80703a1..09785b6f 100644 --- a/codegen/Crm/Pipelines/HeaderSelector.php +++ b/codegen/Crm/Pipelines/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/CollectionResponsePipelineStageNoPaging.php b/codegen/Crm/Pipelines/Model/CollectionResponsePipelineStageNoPaging.php index c65c2904..3a576338 100644 --- a/codegen/Crm/Pipelines/Model/CollectionResponsePipelineStageNoPaging.php +++ b/codegen/Crm/Pipelines/Model/CollectionResponsePipelineStageNoPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponsePipelineStageNoPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -321,11 +321,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/CollectionResponsePublicAuditInfoNoPaging.php b/codegen/Crm/Pipelines/Model/CollectionResponsePublicAuditInfoNoPaging.php index 1c3873f3..1b2b33c5 100644 --- a/codegen/Crm/Pipelines/Model/CollectionResponsePublicAuditInfoNoPaging.php +++ b/codegen/Crm/Pipelines/Model/CollectionResponsePublicAuditInfoNoPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponsePublicAuditInfoNoPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -321,11 +321,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/Error.php b/codegen/Crm/Pipelines/Model/Error.php index 6de9f995..06344e2f 100644 --- a/codegen/Crm/Pipelines/Model/Error.php +++ b/codegen/Crm/Pipelines/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/ErrorDetail.php b/codegen/Crm/Pipelines/Model/ErrorDetail.php index 2c19b032..646e4cdc 100644 --- a/codegen/Crm/Pipelines/Model/ErrorDetail.php +++ b/codegen/Crm/Pipelines/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/ModelInterface.php b/codegen/Crm/Pipelines/Model/ModelInterface.php index d1b93647..a77e7b96 100644 --- a/codegen/Crm/Pipelines/Model/ModelInterface.php +++ b/codegen/Crm/Pipelines/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Crm/Pipelines/Model/Pipeline.php b/codegen/Crm/Pipelines/Model/Pipeline.php index 368b5da8..37f0ba01 100644 --- a/codegen/Crm/Pipelines/Model/Pipeline.php +++ b/codegen/Crm/Pipelines/Model/Pipeline.php @@ -2,7 +2,7 @@ /** * Pipeline * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -578,11 +578,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -590,12 +590,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -620,11 +620,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PipelineInput.php b/codegen/Crm/Pipelines/Model/PipelineInput.php index 3dc26667..8b4ada45 100644 --- a/codegen/Crm/Pipelines/Model/PipelineInput.php +++ b/codegen/Crm/Pipelines/Model/PipelineInput.php @@ -2,7 +2,7 @@ /** * PipelineInput * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -396,11 +396,11 @@ public function setLabel($label) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -408,12 +408,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -438,11 +438,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PipelinePatchInput.php b/codegen/Crm/Pipelines/Model/PipelinePatchInput.php index 62c7065d..7c8cd68f 100644 --- a/codegen/Crm/Pipelines/Model/PipelinePatchInput.php +++ b/codegen/Crm/Pipelines/Model/PipelinePatchInput.php @@ -2,7 +2,7 @@ /** * PipelinePatchInput * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -387,11 +387,11 @@ public function setLabel($label) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -399,12 +399,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -429,11 +429,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PipelineStage.php b/codegen/Crm/Pipelines/Model/PipelineStage.php index 17bce063..c4b19248 100644 --- a/codegen/Crm/Pipelines/Model/PipelineStage.php +++ b/codegen/Crm/Pipelines/Model/PipelineStage.php @@ -2,7 +2,7 @@ /** * PipelineStage * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -354,6 +354,9 @@ public function listInvalidProperties() if ($this->container['archived'] === null) { $invalidProperties[] = "'archived' can't be null"; } + if ($this->container['metadata'] === null) { + $invalidProperties[] = "'metadata' can't be null"; + } if ($this->container['display_order'] === null) { $invalidProperties[] = "'display_order' can't be null"; } @@ -474,7 +477,7 @@ public function setArchived($archived) /** * Gets metadata * - * @return array|null + * @return array */ public function getMetadata() { @@ -484,7 +487,7 @@ public function getMetadata() /** * Sets metadata * - * @param array|null $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. + * @param array $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. * * @return self */ @@ -538,7 +541,7 @@ public function getWritePermissions() /** * Sets write_permissions * - * @param string|null $write_permissions write_permissions + * @param string|null $write_permissions Defines the level of write access for the pipeline stage, with possible values being CRM_PERMISSIONS_ENFORCEMENT, READ_ONLY, or INTERNAL_ONLY. * * @return self */ @@ -645,11 +648,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -657,12 +660,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -687,11 +690,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PipelineStageInput.php b/codegen/Crm/Pipelines/Model/PipelineStageInput.php index abf71b8e..fd35b50c 100644 --- a/codegen/Crm/Pipelines/Model/PipelineStageInput.php +++ b/codegen/Crm/Pipelines/Model/PipelineStageInput.php @@ -2,7 +2,7 @@ /** * PipelineStageInput * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -289,6 +289,9 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['metadata'] === null) { + $invalidProperties[] = "'metadata' can't be null"; + } if ($this->container['display_order'] === null) { $invalidProperties[] = "'display_order' can't be null"; } @@ -313,7 +316,7 @@ public function valid() /** * Gets metadata * - * @return array|null + * @return array */ public function getMetadata() { @@ -323,7 +326,7 @@ public function getMetadata() /** * Sets metadata * - * @param array|null $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. + * @param array $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. * * @return self */ @@ -393,11 +396,11 @@ public function setLabel($label) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +408,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +438,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PipelineStagePatchInput.php b/codegen/Crm/Pipelines/Model/PipelineStagePatchInput.php index 8dfb18c3..8f9901aa 100644 --- a/codegen/Crm/Pipelines/Model/PipelineStagePatchInput.php +++ b/codegen/Crm/Pipelines/Model/PipelineStagePatchInput.php @@ -2,7 +2,7 @@ /** * PipelineStagePatchInput * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -296,6 +296,9 @@ public function listInvalidProperties() { $invalidProperties = []; + if ($this->container['metadata'] === null) { + $invalidProperties[] = "'metadata' can't be null"; + } return $invalidProperties; } @@ -341,7 +344,7 @@ public function setArchived($archived) /** * Gets metadata * - * @return array|null + * @return array */ public function getMetadata() { @@ -351,7 +354,7 @@ public function getMetadata() /** * Sets metadata * - * @param array|null $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. + * @param array $metadata A JSON object containing properties that are not present on all object pipelines. For `deals` pipelines, the `probability` field is required (`{ \"probability\": 0.5 }`), and represents the likelihood a deal will close. Possible values are between 0.0 and 1.0 in increments of 0.1. For `tickets` pipelines, the `ticketState` field is optional (`{ \"ticketState\": \"OPEN\" }`), and represents whether the ticket remains open or has been closed by a member of your Support team. Possible values are `OPEN` or `CLOSED`. * * @return self */ @@ -421,11 +424,11 @@ public function setLabel($label) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -433,12 +436,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -463,11 +466,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/Model/PublicAuditInfo.php b/codegen/Crm/Pipelines/Model/PublicAuditInfo.php index 7806413a..6e5a3d36 100644 --- a/codegen/Crm/Pipelines/Model/PublicAuditInfo.php +++ b/codegen/Crm/Pipelines/Model/PublicAuditInfo.php @@ -2,7 +2,7 @@ /** * PublicAuditInfo * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -353,7 +353,7 @@ public function getIdentifier() /** * Sets identifier * - * @param string $identifier identifier + * @param string $identifier A unique string identifier for the audit event. * * @return self */ @@ -380,7 +380,7 @@ public function getRawObject() /** * Sets raw_object * - * @param object|null $raw_object raw_object + * @param object|null $raw_object An object containing the raw data associated with the audit event. * * @return self */ @@ -407,7 +407,7 @@ public function getFromUserId() /** * Sets from_user_id * - * @param int|null $from_user_id from_user_id + * @param int|null $from_user_id The ID of the user who initiated the audit event. * * @return self */ @@ -434,7 +434,7 @@ public function getPortalId() /** * Sets portal_id * - * @param int $portal_id portal_id + * @param int $portal_id The unique identifier for the HubSpot portal where the audit event occurred. * * @return self */ @@ -461,7 +461,7 @@ public function getAction() /** * Sets action * - * @param string $action action + * @param string $action The action performed that triggered the audit event. * * @return self */ @@ -488,7 +488,7 @@ public function getMessage() /** * Sets message * - * @param string|null $message message + * @param string|null $message A descriptive message related to the audit event. * * @return self */ @@ -515,7 +515,7 @@ public function getTimestamp() /** * Sets timestamp * - * @param \DateTime|null $timestamp timestamp + * @param \DateTime|null $timestamp The date and time when the audit event took place. * * @return self */ @@ -531,11 +531,11 @@ public function setTimestamp($timestamp) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Pipelines/ObjectSerializer.php b/codegen/Crm/Pipelines/ObjectSerializer.php index cae9f224..74056fc1 100644 --- a/codegen/Crm/Pipelines/ObjectSerializer.php +++ b/codegen/Crm/Pipelines/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Pipelines @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Crm/Schemas/Api/CoreApi.php b/codegen/Crm/Schemas/Api/CoreApi.php index 8d5c4f32..7a52516e 100644 --- a/codegen/Crm/Schemas/Api/CoreApi.php +++ b/codegen/Crm/Schemas/Api/CoreApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -209,8 +207,10 @@ public function archiveWithHttpInfo($object_type, $archived = false, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -218,8 +218,6 @@ public function archiveWithHttpInfo($object_type, $archived = false, string $con /** * Operation archiveAsync * - * Delete a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation @@ -240,8 +238,6 @@ function ($response) { /** * Operation archiveAsyncWithHttpInfo * - * Delete a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation @@ -387,8 +383,6 @@ public function archiveRequest($object_type, $archived = false, string $contentT /** * Operation archiveAssociation * - * Remove an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $association_identifier Unique ID of the association to remove. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveAssociation'] to see the possible values for this operation @@ -405,8 +399,6 @@ public function archiveAssociation($object_type, $association_identifier, string /** * Operation archiveAssociationWithHttpInfo * - * Remove an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $association_identifier Unique ID of the association to remove. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveAssociation'] to see the possible values for this operation @@ -443,7 +435,6 @@ public function archiveAssociationWithHttpInfo($object_type, $association_identi return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -453,8 +444,10 @@ public function archiveAssociationWithHttpInfo($object_type, $association_identi $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -462,8 +455,6 @@ public function archiveAssociationWithHttpInfo($object_type, $association_identi /** * Operation archiveAssociationAsync * - * Remove an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $association_identifier Unique ID of the association to remove. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveAssociation'] to see the possible values for this operation @@ -484,8 +475,6 @@ function ($response) { /** * Operation archiveAssociationAsyncWithHttpInfo * - * Remove an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $association_identifier Unique ID of the association to remove. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveAssociation'] to see the possible values for this operation @@ -636,8 +625,6 @@ public function archiveAssociationRequest($object_type, $association_identifier, /** * Operation create * - * Create a new schema - * * @param \HubSpot\Client\Crm\Schemas\Model\ObjectSchemaEgg $object_schema_egg Object schema definition, including properties and associations. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * @@ -654,8 +641,6 @@ public function create($object_schema_egg, string $contentType = self::contentTy /** * Operation createWithHttpInfo * - * Create a new schema - * * @param \HubSpot\Client\Crm\Schemas\Model\ObjectSchemaEgg $object_schema_egg Object schema definition, including properties and associations. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * @@ -692,61 +677,21 @@ public function createWithHttpInfo($object_schema_egg, string $contentType = sel switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectSchema' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectSchema' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Schemas\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -760,34 +705,11 @@ public function createWithHttpInfo($object_schema_egg, string $contentType = sel ); } - $returnType = '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -797,7 +719,7 @@ public function createWithHttpInfo($object_schema_egg, string $contentType = sel $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -805,8 +727,10 @@ public function createWithHttpInfo($object_schema_egg, string $contentType = sel $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -814,8 +738,6 @@ public function createWithHttpInfo($object_schema_egg, string $contentType = sel /** * Operation createAsync * - * Create a new schema - * * @param \HubSpot\Client\Crm\Schemas\Model\ObjectSchemaEgg $object_schema_egg Object schema definition, including properties and associations. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * @@ -835,8 +757,6 @@ function ($response) { /** * Operation createAsyncWithHttpInfo * - * Create a new schema - * * @param \HubSpot\Client\Crm\Schemas\Model\ObjectSchemaEgg $object_schema_egg Object schema definition, including properties and associations. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * @@ -982,8 +902,6 @@ public function createRequest($object_schema_egg, string $contentType = self::co /** * Operation createAssociation * - * Create an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\AssociationDefinitionEgg $association_definition_egg Attributes that define the association. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createAssociation'] to see the possible values for this operation @@ -1001,8 +919,6 @@ public function createAssociation($object_type, $association_definition_egg, str /** * Operation createAssociationWithHttpInfo * - * Create an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\AssociationDefinitionEgg $association_definition_egg Attributes that define the association. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createAssociation'] to see the possible values for this operation @@ -1040,61 +956,21 @@ public function createAssociationWithHttpInfo($object_type, $association_definit switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Schemas\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1108,34 +984,11 @@ public function createAssociationWithHttpInfo($object_type, $association_definit ); } - $returnType = '\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\AssociationDefinition', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -1145,7 +998,7 @@ public function createAssociationWithHttpInfo($object_type, $association_definit $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1153,8 +1006,10 @@ public function createAssociationWithHttpInfo($object_type, $association_definit $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1162,8 +1017,6 @@ public function createAssociationWithHttpInfo($object_type, $association_definit /** * Operation createAssociationAsync * - * Create an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\AssociationDefinitionEgg $association_definition_egg Attributes that define the association. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createAssociation'] to see the possible values for this operation @@ -1184,8 +1037,6 @@ function ($response) { /** * Operation createAssociationAsyncWithHttpInfo * - * Create an association - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\AssociationDefinitionEgg $association_definition_egg Attributes that define the association. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createAssociation'] to see the possible values for this operation @@ -1348,8 +1199,6 @@ public function createAssociationRequest($object_type, $association_definition_e /** * Operation getAll * - * Get all schemas - * * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation * @@ -1366,8 +1215,6 @@ public function getAll($archived = false, string $contentType = self::contentTyp /** * Operation getAllWithHttpInfo * - * Get all schemas - * * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation * @@ -1404,61 +1251,21 @@ public function getAllWithHttpInfo($archived = false, string $contentType = self switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Schemas\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1472,34 +1279,11 @@ public function getAllWithHttpInfo($archived = false, string $contentType = self ); } - $returnType = '\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\CollectionResponseObjectSchemaNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1509,7 +1293,7 @@ public function getAllWithHttpInfo($archived = false, string $contentType = self $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1517,8 +1301,10 @@ public function getAllWithHttpInfo($archived = false, string $contentType = self $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1526,8 +1312,6 @@ public function getAllWithHttpInfo($archived = false, string $contentType = self /** * Operation getAllAsync * - * Get all schemas - * * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation * @@ -1547,8 +1331,6 @@ function ($response) { /** * Operation getAllAsyncWithHttpInfo * - * Get all schemas - * * @param bool|null $archived Whether to return only results that have been archived. (optional, default to false) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation * @@ -1690,8 +1472,6 @@ public function getAllRequest($archived = false, string $contentType = self::con /** * Operation getById * - * Get an existing schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * @@ -1708,8 +1488,6 @@ public function getById($object_type, string $contentType = self::contentTypes[' /** * Operation getByIdWithHttpInfo * - * Get an existing schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * @@ -1746,61 +1524,21 @@ public function getByIdWithHttpInfo($object_type, string $contentType = self::co switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectSchema' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectSchema' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Schemas\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1814,34 +1552,11 @@ public function getByIdWithHttpInfo($object_type, string $contentType = self::co ); } - $returnType = '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectSchema', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1851,7 +1566,7 @@ public function getByIdWithHttpInfo($object_type, string $contentType = self::co $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1859,8 +1574,10 @@ public function getByIdWithHttpInfo($object_type, string $contentType = self::co $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1868,8 +1585,6 @@ public function getByIdWithHttpInfo($object_type, string $contentType = self::co /** * Operation getByIdAsync * - * Get an existing schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * @@ -1889,8 +1604,6 @@ function ($response) { /** * Operation getByIdAsyncWithHttpInfo * - * Get an existing schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * @@ -2037,8 +1750,6 @@ public function getByIdRequest($object_type, string $contentType = self::content /** * Operation update * - * Update a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinitionPatch $object_type_definition_patch Attributes to update in your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation @@ -2056,8 +1767,6 @@ public function update($object_type, $object_type_definition_patch, string $cont /** * Operation updateWithHttpInfo * - * Update a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinitionPatch $object_type_definition_patch Attributes to update in your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation @@ -2095,61 +1804,21 @@ public function updateWithHttpInfo($object_type, $object_type_definition_patch, switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Schemas\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Schemas\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Schemas\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -2163,34 +1832,11 @@ public function updateWithHttpInfo($object_type, $object_type_definition_patch, ); } - $returnType = '\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinition', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -2200,7 +1846,7 @@ public function updateWithHttpInfo($object_type, $object_type_definition_patch, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -2208,8 +1854,10 @@ public function updateWithHttpInfo($object_type, $object_type_definition_patch, $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -2217,8 +1865,6 @@ public function updateWithHttpInfo($object_type, $object_type_definition_patch, /** * Operation updateAsync * - * Update a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinitionPatch $object_type_definition_patch Attributes to update in your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation @@ -2239,8 +1885,6 @@ function ($response) { /** * Operation updateAsyncWithHttpInfo * - * Update a schema - * * @param string $object_type Fully qualified name or object type ID of your schema. (required) * @param \HubSpot\Client\Crm\Schemas\Model\ObjectTypeDefinitionPatch $object_type_definition_patch Attributes to update in your schema. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation @@ -2416,6 +2060,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Schemas/ApiException.php b/codegen/Crm/Schemas/ApiException.php index b1c2a981..23fa5775 100644 --- a/codegen/Crm/Schemas/ApiException.php +++ b/codegen/Crm/Schemas/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Crm/Schemas/FormDataProcessor.php b/codegen/Crm/Schemas/FormDataProcessor.php new file mode 100644 index 00000000..5eafae12 --- /dev/null +++ b/codegen/Crm/Schemas/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Crm/Schemas/HeaderSelector.php b/codegen/Crm/Schemas/HeaderSelector.php index b3987dc9..172633f6 100644 --- a/codegen/Crm/Schemas/HeaderSelector.php +++ b/codegen/Crm/Schemas/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -510,12 +510,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -540,11 +540,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/AssociationDefinitionEgg.php b/codegen/Crm/Schemas/Model/AssociationDefinitionEgg.php index 11a88c53..417632ea 100644 --- a/codegen/Crm/Schemas/Model/AssociationDefinitionEgg.php +++ b/codegen/Crm/Schemas/Model/AssociationDefinitionEgg.php @@ -2,7 +2,7 @@ /** * AssociationDefinitionEgg * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -393,11 +393,11 @@ public function setToObjectTypeId($to_object_type_id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -405,12 +405,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -435,11 +435,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/CollectionResponseObjectSchemaNoPaging.php b/codegen/Crm/Schemas/Model/CollectionResponseObjectSchemaNoPaging.php index f11d1244..8c1380de 100644 --- a/codegen/Crm/Schemas/Model/CollectionResponseObjectSchemaNoPaging.php +++ b/codegen/Crm/Schemas/Model/CollectionResponseObjectSchemaNoPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponseObjectSchemaNoPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -321,11 +321,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/Error.php b/codegen/Crm/Schemas/Model/Error.php index acf6bfe1..0bcddcb8 100644 --- a/codegen/Crm/Schemas/Model/Error.php +++ b/codegen/Crm/Schemas/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ErrorDetail.php b/codegen/Crm/Schemas/Model/ErrorDetail.php index 3963a856..ef751491 100644 --- a/codegen/Crm/Schemas/Model/ErrorDetail.php +++ b/codegen/Crm/Schemas/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ModelInterface.php b/codegen/Crm/Schemas/Model/ModelInterface.php index 3d06a78a..a9a709a2 100644 --- a/codegen/Crm/Schemas/Model/ModelInterface.php +++ b/codegen/Crm/Schemas/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Crm/Schemas/Model/ObjectSchema.php b/codegen/Crm/Schemas/Model/ObjectSchema.php index a23f5747..d6db5677 100644 --- a/codegen/Crm/Schemas/Model/ObjectSchema.php +++ b/codegen/Crm/Schemas/Model/ObjectSchema.php @@ -2,7 +2,7 @@ /** * ObjectSchema * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -881,11 +881,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -893,12 +893,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -923,11 +923,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ObjectSchemaEgg.php b/codegen/Crm/Schemas/Model/ObjectSchemaEgg.php index 4dd7ce82..682ab454 100644 --- a/codegen/Crm/Schemas/Model/ObjectSchemaEgg.php +++ b/codegen/Crm/Schemas/Model/ObjectSchemaEgg.php @@ -2,7 +2,7 @@ /** * ObjectSchemaEgg * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -606,11 +606,11 @@ public function setLabels($labels) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -618,12 +618,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -648,11 +648,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ObjectTypeDefinition.php b/codegen/Crm/Schemas/Model/ObjectTypeDefinition.php index 84ffae67..0d685549 100644 --- a/codegen/Crm/Schemas/Model/ObjectTypeDefinition.php +++ b/codegen/Crm/Schemas/Model/ObjectTypeDefinition.php @@ -2,7 +2,7 @@ /** * ObjectTypeDefinition * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -773,11 +773,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -785,12 +785,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -815,11 +815,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ObjectTypeDefinitionLabels.php b/codegen/Crm/Schemas/Model/ObjectTypeDefinitionLabels.php index 1ed7a8a2..df41155f 100644 --- a/codegen/Crm/Schemas/Model/ObjectTypeDefinitionLabels.php +++ b/codegen/Crm/Schemas/Model/ObjectTypeDefinitionLabels.php @@ -2,7 +2,7 @@ /** * ObjectTypeDefinitionLabels * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -353,11 +353,11 @@ public function setSingular($singular) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -365,12 +365,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -395,11 +395,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ObjectTypeDefinitionPatch.php b/codegen/Crm/Schemas/Model/ObjectTypeDefinitionPatch.php index b4738f86..ab3f333e 100644 --- a/codegen/Crm/Schemas/Model/ObjectTypeDefinitionPatch.php +++ b/codegen/Crm/Schemas/Model/ObjectTypeDefinitionPatch.php @@ -2,7 +2,7 @@ /** * ObjectTypeDefinitionPatch * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -557,11 +557,11 @@ public function setLabels($labels) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -569,12 +569,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -599,11 +599,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/ObjectTypePropertyCreate.php b/codegen/Crm/Schemas/Model/ObjectTypePropertyCreate.php index 6e944929..87d8c1a9 100644 --- a/codegen/Crm/Schemas/Model/ObjectTypePropertyCreate.php +++ b/codegen/Crm/Schemas/Model/ObjectTypePropertyCreate.php @@ -2,7 +2,7 @@ /** * ObjectTypePropertyCreate * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -1039,11 +1039,11 @@ public function setFieldType($field_type) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -1051,12 +1051,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -1081,11 +1081,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/Option.php b/codegen/Crm/Schemas/Model/Option.php index d8522660..dee0058a 100644 --- a/codegen/Crm/Schemas/Model/Option.php +++ b/codegen/Crm/Schemas/Model/Option.php @@ -2,7 +2,7 @@ /** * Option * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -464,11 +464,11 @@ public function setValue($value) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -476,12 +476,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -506,11 +506,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/OptionInput.php b/codegen/Crm/Schemas/Model/OptionInput.php index 440fe717..1c449fd1 100644 --- a/codegen/Crm/Schemas/Model/OptionInput.php +++ b/codegen/Crm/Schemas/Model/OptionInput.php @@ -2,7 +2,7 @@ /** * OptionInput * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -467,11 +467,11 @@ public function setValue($value) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -479,12 +479,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -509,11 +509,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/Property.php b/codegen/Crm/Schemas/Model/Property.php index 22bc21cb..51aff8cd 100644 --- a/codegen/Crm/Schemas/Model/Property.php +++ b/codegen/Crm/Schemas/Model/Property.php @@ -2,7 +2,7 @@ /** * Property * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -525,7 +525,7 @@ public function getHidden() /** * Sets hidden * - * @param bool|null $hidden hidden + * @param bool|null $hidden Whether or not the property will be hidden from the HubSpot UI. It's recommended that this be set to false for custom properties. * * @return self */ @@ -849,7 +849,7 @@ public function getUpdatedAt() /** * Sets updated_at * - * @param \DateTime|null $updated_at + * @param \DateTime|null $updated_at The timestamp when the property was last updated, in ISO 8601 format. * * @return self */ @@ -930,7 +930,7 @@ public function getSensitiveDataCategories() /** * Sets sensitive_data_categories * - * @param string[]|null $sensitive_data_categories sensitive_data_categories + * @param string[]|null $sensitive_data_categories When sensitiveData is true, lists the type of sensitive data contained in the property (e.g., \"HIPAA\"). * * @return self */ @@ -1011,7 +1011,7 @@ public function getDataSensitivity() /** * Sets data_sensitivity * - * @param string|null $data_sensitivity data_sensitivity + * @param string|null $data_sensitivity Indicates the sensitivity level of the property, such as \"non_sensitive\", \"sensitive\", or \"highly_sensitive\". * * @return self */ @@ -1156,7 +1156,7 @@ public function getCalculationFormula() /** * Sets calculation_formula * - * @param string|null $calculation_formula calculation_formula + * @param string|null $calculation_formula The formula used for calculated properties. * * @return self */ @@ -1226,11 +1226,11 @@ public function setUpdatedUserId($updated_user_id) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -1238,12 +1238,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -1268,11 +1268,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/Model/PropertyModificationMetadata.php b/codegen/Crm/Schemas/Model/PropertyModificationMetadata.php index 5e89c506..cfdfb5dd 100644 --- a/codegen/Crm/Schemas/Model/PropertyModificationMetadata.php +++ b/codegen/Crm/Schemas/Model/PropertyModificationMetadata.php @@ -2,7 +2,7 @@ /** * PropertyModificationMetadata * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -332,7 +332,7 @@ public function getReadOnlyOptions() /** * Sets read_only_options * - * @param bool|null $read_only_options + * @param bool|null $read_only_options read_only_options * * @return self */ @@ -359,7 +359,7 @@ public function getReadOnlyValue() /** * Sets read_only_value * - * @param bool $read_only_value + * @param bool $read_only_value read_only_value * * @return self */ @@ -386,7 +386,7 @@ public function getReadOnlyDefinition() /** * Sets read_only_definition * - * @param bool $read_only_definition + * @param bool $read_only_definition read_only_definition * * @return self */ @@ -413,7 +413,7 @@ public function getArchivable() /** * Sets archivable * - * @param bool $archivable + * @param bool $archivable archivable * * @return self */ @@ -429,11 +429,11 @@ public function setArchivable($archivable) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -441,12 +441,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -471,11 +471,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Schemas/ObjectSerializer.php b/codegen/Crm/Schemas/ObjectSerializer.php index 5f8fccbb..6b24268c 100644 --- a/codegen/Crm/Schemas/ObjectSerializer.php +++ b/codegen/Crm/Schemas/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Schemas @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } } diff --git a/codegen/Crm/Timeline/Api/EventsApi.php b/codegen/Crm/Timeline/Api/EventsApi.php index 36e716c8..c0b7a6c0 100644 --- a/codegen/Crm/Timeline/Api/EventsApi.php +++ b/codegen/Crm/Timeline/Api/EventsApi.php @@ -1,7 +1,7 @@ [ 'application/json', ], - 'getRenderById' => [ - 'application/json', - ], ]; /** @@ -137,7 +137,7 @@ public function getConfig() /** * Operation create * - * Create a single event + * Send event data (single) * * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEvent $timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation @@ -155,7 +155,7 @@ public function create($timeline_event, string $contentType = self::contentTypes /** * Operation createWithHttpInfo * - * Create a single event + * Send event data (single) * * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEvent $timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation @@ -193,61 +193,21 @@ public function createWithHttpInfo($timeline_event, string $contentType = self:: switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -261,34 +221,11 @@ public function createWithHttpInfo($timeline_event, string $contentType = self:: ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -298,7 +235,7 @@ public function createWithHttpInfo($timeline_event, string $contentType = self:: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -306,8 +243,10 @@ public function createWithHttpInfo($timeline_event, string $contentType = self:: $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -315,7 +254,7 @@ public function createWithHttpInfo($timeline_event, string $contentType = self:: /** * Operation createAsync * - * Create a single event + * Send event data (single) * * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEvent $timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation @@ -336,7 +275,7 @@ function ($response) { /** * Operation createAsyncWithHttpInfo * - * Create a single event + * Send event data (single) * * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEvent $timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation @@ -483,7 +422,7 @@ public function createRequest($timeline_event, string $contentType = self::conte /** * Operation createBatch * - * Creates multiple events + * Create multiple events * * @param \HubSpot\Client\Crm\Timeline\Model\BatchInputTimelineEvent $batch_input_timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation @@ -500,7 +439,7 @@ public function createBatch($batch_input_timeline_event, string $contentType = s /** * Operation createBatchWithHttpInfo * - * Creates multiple events + * Create multiple events * * @param \HubSpot\Client\Crm\Timeline\Model\BatchInputTimelineEvent $batch_input_timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation @@ -537,7 +476,6 @@ public function createBatchWithHttpInfo($batch_input_timeline_event, string $con return [null, $statusCode, $response->getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -547,7 +485,7 @@ public function createBatchWithHttpInfo($batch_input_timeline_event, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; case 207: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -555,7 +493,7 @@ public function createBatchWithHttpInfo($batch_input_timeline_event, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -563,8 +501,10 @@ public function createBatchWithHttpInfo($batch_input_timeline_event, string $con $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -572,7 +512,7 @@ public function createBatchWithHttpInfo($batch_input_timeline_event, string $con /** * Operation createBatchAsync * - * Creates multiple events + * Create multiple events * * @param \HubSpot\Client\Crm\Timeline\Model\BatchInputTimelineEvent $batch_input_timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation @@ -593,7 +533,7 @@ function ($response) { /** * Operation createBatchAsyncWithHttpInfo * - * Creates multiple events + * Create multiple events * * @param \HubSpot\Client\Crm\Timeline\Model\BatchInputTimelineEvent $batch_input_timeline_event The timeline event definition. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation @@ -727,7 +667,7 @@ public function createBatchRequest($batch_input_timeline_event, string $contentT /** * Operation getById * - * Gets the event + * Get an event instance * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -746,7 +686,7 @@ public function getById($event_template_id, $event_id, string $contentType = sel /** * Operation getByIdWithHttpInfo * - * Gets the event + * Get an event instance * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -785,61 +725,21 @@ public function getByIdWithHttpInfo($event_template_id, $event_id, string $conte switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -853,34 +753,11 @@ public function getByIdWithHttpInfo($event_template_id, $event_id, string $conte ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventResponse', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -890,7 +767,7 @@ public function getByIdWithHttpInfo($event_template_id, $event_id, string $conte $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -898,8 +775,10 @@ public function getByIdWithHttpInfo($event_template_id, $event_id, string $conte $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -907,7 +786,7 @@ public function getByIdWithHttpInfo($event_template_id, $event_id, string $conte /** * Operation getByIdAsync * - * Gets the event + * Get an event instance * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -929,7 +808,7 @@ function ($response) { /** * Operation getByIdAsyncWithHttpInfo * - * Gets the event + * Get an event instance * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -1094,7 +973,7 @@ public function getByIdRequest($event_template_id, $event_id, string $contentTyp /** * Operation getDetailById * - * Gets the detailTemplate as rendered + * Get event details * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -1113,7 +992,7 @@ public function getDetailById($event_template_id, $event_id, string $contentType /** * Operation getDetailByIdWithHttpInfo * - * Gets the detailTemplate as rendered + * Get event details * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -1152,61 +1031,21 @@ public function getDetailByIdWithHttpInfo($event_template_id, $event_id, string switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\EventDetail' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\EventDetail' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\EventDetail', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\EventDetail', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1220,34 +1059,11 @@ public function getDetailByIdWithHttpInfo($event_template_id, $event_id, string ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\EventDetail'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\EventDetail', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1257,7 +1073,7 @@ public function getDetailByIdWithHttpInfo($event_template_id, $event_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1265,8 +1081,10 @@ public function getDetailByIdWithHttpInfo($event_template_id, $event_id, string $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1274,7 +1092,7 @@ public function getDetailByIdWithHttpInfo($event_template_id, $event_id, string /** * Operation getDetailByIdAsync * - * Gets the detailTemplate as rendered + * Get event details * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -1296,7 +1114,7 @@ function ($response) { /** * Operation getDetailByIdAsyncWithHttpInfo * - * Gets the detailTemplate as rendered + * Get event details * * @param string $event_template_id The event template ID. (required) * @param string $event_id The event ID. (required) @@ -1459,403 +1277,72 @@ public function getDetailByIdRequest($event_template_id, $event_id, string $cont } /** - * Operation getRenderById - * - * Renders the header or detail as HTML - * - * @param string $event_template_id The event template ID. (required) - * @param string $event_id The event ID. (required) - * @param bool|null $detail Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getRenderById'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Crm\Timeline\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return string|\HubSpot\Client\Crm\Timeline\Model\Error - */ - public function getRenderById($event_template_id, $event_id, $detail = null, string $contentType = self::contentTypes['getRenderById'][0]) - { - list($response) = $this->getRenderByIdWithHttpInfo($event_template_id, $event_id, $detail, $contentType); - return $response; - } - - /** - * Operation getRenderByIdWithHttpInfo - * - * Renders the header or detail as HTML - * - * @param string $event_template_id The event template ID. (required) - * @param string $event_id The event ID. (required) - * @param bool|null $detail Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getRenderById'] to see the possible values for this operation + * Create http client option * - * @throws \HubSpot\Client\Crm\Timeline\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of string|\HubSpot\Client\Crm\Timeline\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @throws \RuntimeException on file opening failure + * @return array of http client options */ - public function getRenderByIdWithHttpInfo($event_template_id, $event_id, $detail = null, string $contentType = self::contentTypes['getRenderById'][0]) + protected function createHttpClientOption() { - $request = $this->getRenderByIdRequest($event_template_id, $event_id, $detail, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - - switch($statusCode) { - case 200: - if ('string' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('string' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, 'string', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - $returnType = 'string'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } + } - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'string', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Crm\Timeline\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); } - } - /** - * Operation getRenderByIdAsync - * - * Renders the header or detail as HTML - * - * @param string $event_template_id The event template ID. (required) - * @param string $event_id The event ID. (required) - * @param bool|null $detail Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getRenderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getRenderByIdAsync($event_template_id, $event_id, $detail = null, string $contentType = self::contentTypes['getRenderById'][0]) - { - return $this->getRenderByIdAsyncWithHttpInfo($event_template_id, $event_id, $detail, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); + return $options; } - /** - * Operation getRenderByIdAsyncWithHttpInfo - * - * Renders the header or detail as HTML - * - * @param string $event_template_id The event template ID. (required) - * @param string $event_id The event ID. (required) - * @param bool|null $detail Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getRenderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getRenderByIdAsyncWithHttpInfo($event_template_id, $event_id, $detail = null, string $contentType = self::contentTypes['getRenderById'][0]) - { - $returnType = 'string'; - $request = $this->getRenderByIdRequest($event_template_id, $event_id, $detail, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { throw new ApiException( sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() + 'Error JSON decoding server response (%s)', + $request->getUri() ), - $statusCode, + $response->getStatusCode(), $response->getHeaders(), - (string) $response->getBody() + $content ); } - ); - } - - /** - * Create request for operation 'getRenderById' - * - * @param string $event_template_id The event template ID. (required) - * @param string $event_id The event ID. (required) - * @param bool|null $detail Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getRenderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getRenderByIdRequest($event_template_id, $event_id, $detail = null, string $contentType = self::contentTypes['getRenderById'][0]) - { - - // verify the required parameter 'event_template_id' is set - if ($event_template_id === null || (is_array($event_template_id) && count($event_template_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $event_template_id when calling getRenderById' - ); - } - - // verify the required parameter 'event_id' is set - if ($event_id === null || (is_array($event_id) && count($event_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $event_id when calling getRenderById' - ); - } - - - - $resourcePath = '/integrators/timeline/v3/events/{eventTemplateId}/{eventId}/render'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $detail, - 'detail', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - // path params - if ($event_template_id !== null) { - $resourcePath = str_replace( - '{' . 'eventTemplateId' . '}', - ObjectSerializer::toPathValue($event_template_id), - $resourcePath - ); - } - // path params - if ($event_id !== null) { - $resourcePath = str_replace( - '{' . 'eventId' . '}', - ObjectSerializer::toPathValue($event_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['text/html', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); } } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); - return $options; + return $statusCode >= $left && $statusCode <= $right; } } diff --git a/codegen/Crm/Timeline/Api/TemplatesApi.php b/codegen/Crm/Timeline/Api/TemplatesApi.php index 51d3d8eb..e0d4e4ac 100644 --- a/codegen/Crm/Timeline/Api/TemplatesApi.php +++ b/codegen/Crm/Timeline/Api/TemplatesApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -203,8 +205,10 @@ public function archiveWithHttpInfo($event_template_id, $app_id, string $content $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -212,7 +216,7 @@ public function archiveWithHttpInfo($event_template_id, $app_id, string $content /** * Operation archiveAsync * - * Deletes an event template for the app + * Delete an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -234,7 +238,7 @@ function ($response) { /** * Operation archiveAsyncWithHttpInfo * - * Deletes an event template for the app + * Delete an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -387,7 +391,7 @@ public function archiveRequest($event_template_id, $app_id, string $contentType /** * Operation create * - * Create an event template for your app + * Create an event template * * @param int $app_id The ID of the target app. (required) * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateCreateRequest $timeline_event_template_create_request The new event template definition. (required) @@ -406,7 +410,7 @@ public function create($app_id, $timeline_event_template_create_request, string /** * Operation createWithHttpInfo * - * Create an event template for your app + * Create an event template * * @param int $app_id The ID of the target app. (required) * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateCreateRequest $timeline_event_template_create_request The new event template definition. (required) @@ -445,61 +449,21 @@ public function createWithHttpInfo($app_id, $timeline_event_template_create_requ switch($statusCode) { case 201: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -513,34 +477,11 @@ public function createWithHttpInfo($app_id, $timeline_event_template_create_requ ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 201: @@ -550,7 +491,7 @@ public function createWithHttpInfo($app_id, $timeline_event_template_create_requ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -558,8 +499,10 @@ public function createWithHttpInfo($app_id, $timeline_event_template_create_requ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -567,7 +510,7 @@ public function createWithHttpInfo($app_id, $timeline_event_template_create_requ /** * Operation createAsync * - * Create an event template for your app + * Create an event template * * @param int $app_id The ID of the target app. (required) * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateCreateRequest $timeline_event_template_create_request The new event template definition. (required) @@ -589,7 +532,7 @@ function ($response) { /** * Operation createAsyncWithHttpInfo * - * Create an event template for your app + * Create an event template * * @param int $app_id The ID of the target app. (required) * @param \HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateCreateRequest $timeline_event_template_create_request The new event template definition. (required) @@ -754,7 +697,7 @@ public function createRequest($app_id, $timeline_event_template_create_request, /** * Operation getAll * - * List all event templates for your app + * Get all event templates * * @param int $app_id The ID of the target app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation @@ -772,7 +715,7 @@ public function getAll($app_id, string $contentType = self::contentTypes['getAll /** * Operation getAllWithHttpInfo * - * List all event templates for your app + * Get all event templates * * @param int $app_id The ID of the target app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation @@ -810,61 +753,21 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -878,34 +781,11 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\CollectionResponseTimelineEventTemplateNoPaging', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -915,7 +795,7 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -923,8 +803,10 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -932,7 +814,7 @@ public function getAllWithHttpInfo($app_id, string $contentType = self::contentT /** * Operation getAllAsync * - * List all event templates for your app + * Get all event templates * * @param int $app_id The ID of the target app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation @@ -953,7 +835,7 @@ function ($response) { /** * Operation getAllAsyncWithHttpInfo * - * List all event templates for your app + * Get all event templates * * @param int $app_id The ID of the target app. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAll'] to see the possible values for this operation @@ -1102,7 +984,7 @@ public function getAllRequest($app_id, string $contentType = self::contentTypes[ /** * Operation getById * - * Gets a specific event template for your app + * Get an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1121,7 +1003,7 @@ public function getById($event_template_id, $app_id, string $contentType = self: /** * Operation getByIdWithHttpInfo * - * Gets a specific event template for your app + * Get an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1160,61 +1042,21 @@ public function getByIdWithHttpInfo($event_template_id, $app_id, string $content switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1228,34 +1070,11 @@ public function getByIdWithHttpInfo($event_template_id, $app_id, string $content ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1265,7 +1084,7 @@ public function getByIdWithHttpInfo($event_template_id, $app_id, string $content $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1273,8 +1092,10 @@ public function getByIdWithHttpInfo($event_template_id, $app_id, string $content $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1282,7 +1103,7 @@ public function getByIdWithHttpInfo($event_template_id, $app_id, string $content /** * Operation getByIdAsync * - * Gets a specific event template for your app + * Get an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1304,7 +1125,7 @@ function ($response) { /** * Operation getByIdAsyncWithHttpInfo * - * Gets a specific event template for your app + * Get an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1470,7 +1291,7 @@ public function getByIdRequest($event_template_id, $app_id, string $contentType /** * Operation update * - * Update an existing event template + * Update an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1490,7 +1311,7 @@ public function update($event_template_id, $app_id, $timeline_event_template_upd /** * Operation updateWithHttpInfo * - * Update an existing event template + * Update an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1530,61 +1351,21 @@ public function updateWithHttpInfo($event_template_id, $app_id, $timeline_event_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -1598,34 +1379,11 @@ public function updateWithHttpInfo($event_template_id, $app_id, $timeline_event_ ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplate', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -1635,7 +1393,7 @@ public function updateWithHttpInfo($event_template_id, $app_id, $timeline_event_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -1643,8 +1401,10 @@ public function updateWithHttpInfo($event_template_id, $app_id, $timeline_event_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -1652,7 +1412,7 @@ public function updateWithHttpInfo($event_template_id, $app_id, $timeline_event_ /** * Operation updateAsync * - * Update an existing event template + * Update an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1675,7 +1435,7 @@ function ($response) { /** * Operation updateAsyncWithHttpInfo * - * Update an existing event template + * Update an event template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -1870,6 +1630,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Timeline/Api/TokensApi.php b/codegen/Crm/Timeline/Api/TokensApi.php index 5afc2264..266c405a 100644 --- a/codegen/Crm/Timeline/Api/TokensApi.php +++ b/codegen/Crm/Timeline/Api/TokensApi.php @@ -1,7 +1,7 @@ getHeaders()]; - } catch (ApiException $e) { switch ($e->getCode()) { default: @@ -199,8 +201,10 @@ public function archiveWithHttpInfo($event_template_id, $token_name, $app_id, st $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -208,7 +212,7 @@ public function archiveWithHttpInfo($event_template_id, $token_name, $app_id, st /** * Operation archiveAsync * - * Removes a token from the event template + * Delete a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -231,7 +235,7 @@ function ($response) { /** * Operation archiveAsyncWithHttpInfo * - * Removes a token from the event template + * Delete a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -401,7 +405,7 @@ public function archiveRequest($event_template_id, $token_name, $app_id, string /** * Operation create * - * Adds a token to an existing event template + * Add tokens to an existing template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -421,7 +425,7 @@ public function create($event_template_id, $app_id, $timeline_event_template_tok /** * Operation createWithHttpInfo * - * Adds a token to an existing event template + * Add tokens to an existing template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -461,61 +465,21 @@ public function createWithHttpInfo($event_template_id, $app_id, $timeline_event_ switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -529,34 +493,11 @@ public function createWithHttpInfo($event_template_id, $app_id, $timeline_event_ ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -566,7 +507,7 @@ public function createWithHttpInfo($event_template_id, $app_id, $timeline_event_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -574,8 +515,10 @@ public function createWithHttpInfo($event_template_id, $app_id, $timeline_event_ $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -583,7 +526,7 @@ public function createWithHttpInfo($event_template_id, $app_id, $timeline_event_ /** * Operation createAsync * - * Adds a token to an existing event template + * Add tokens to an existing template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -606,7 +549,7 @@ function ($response) { /** * Operation createAsyncWithHttpInfo * - * Adds a token to an existing event template + * Add tokens to an existing template * * @param string $event_template_id The event template ID. (required) * @param int $app_id The ID of the target app. (required) @@ -788,7 +731,7 @@ public function createRequest($event_template_id, $app_id, $timeline_event_templ /** * Operation update * - * Updates an existing token on an event template + * Update a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -809,7 +752,7 @@ public function update($event_template_id, $token_name, $app_id, $timeline_event /** * Operation updateWithHttpInfo * - * Updates an existing token on an event template + * Update a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -850,61 +793,21 @@ public function updateWithHttpInfo($event_template_id, $token_name, $app_id, $ti switch($statusCode) { case 200: - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', + $request, + $response, + ); default: - if ('\HubSpot\Client\Crm\Timeline\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Crm\Timeline\Model\Error' !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Timeline\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\Error', + $request, + $response, + ); } + + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( @@ -918,34 +821,11 @@ public function updateWithHttpInfo($event_template_id, $token_name, $app_id, $ti ); } - $returnType = '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - try { - $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new ApiException( - sprintf( - 'Error JSON decoding server response (%s)', - $request->getUri() - ), - $statusCode, - $response->getHeaders(), - $content - ); - } - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - + return $this->handleResponseWithDataType( + '\HubSpot\Client\Crm\Timeline\Model\TimelineEventTemplateToken', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -955,7 +835,7 @@ public function updateWithHttpInfo($event_template_id, $token_name, $app_id, $ti $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -963,8 +843,10 @@ public function updateWithHttpInfo($event_template_id, $token_name, $app_id, $ti $e->getResponseHeaders() ); $e->setResponseObject($data); - break; + throw $e; } + + throw $e; } } @@ -972,7 +854,7 @@ public function updateWithHttpInfo($event_template_id, $token_name, $app_id, $ti /** * Operation updateAsync * - * Updates an existing token on an event template + * Update a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -996,7 +878,7 @@ function ($response) { /** * Operation updateAsyncWithHttpInfo * - * Updates an existing token on an event template + * Update a template token * * @param string $event_template_id The event template ID. (required) * @param string $token_name The token name. (required) @@ -1208,6 +1090,57 @@ protected function createHttpClientOption() } } + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + return $options; } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } } diff --git a/codegen/Crm/Timeline/ApiException.php b/codegen/Crm/Timeline/ApiException.php index 25f054f9..6ba21de1 100644 --- a/codegen/Crm/Timeline/ApiException.php +++ b/codegen/Crm/Timeline/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath; } + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** * Gets the default configuration instance * diff --git a/codegen/Crm/Timeline/FormDataProcessor.php b/codegen/Crm/Timeline/FormDataProcessor.php new file mode 100644 index 00000000..9a6fa86d --- /dev/null +++ b/codegen/Crm/Timeline/FormDataProcessor.php @@ -0,0 +1,246 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/codegen/Crm/Timeline/HeaderSelector.php b/codegen/Crm/Timeline/HeaderSelector.php index a0928e64..2d331588 100644 --- a/codegen/Crm/Timeline/HeaderSelector.php +++ b/codegen/Crm/Timeline/HeaderSelector.php @@ -1,7 +1,7 @@ container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponse.php b/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponse.php index 9a26c545..542dde9f 100644 --- a/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponse.php +++ b/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponse.php @@ -2,7 +2,7 @@ /** * BatchResponseTimelineEventResponse * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -539,11 +539,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -551,12 +551,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -581,11 +581,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponseWithErrors.php b/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponseWithErrors.php index 1b26a1f4..2de0173e 100644 --- a/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponseWithErrors.php +++ b/codegen/Crm/Timeline/Model/BatchResponseTimelineEventResponseWithErrors.php @@ -2,7 +2,7 @@ /** * BatchResponseTimelineEventResponseWithErrors * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -606,11 +606,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -618,12 +618,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -648,11 +648,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/CollectionResponseTimelineEventTemplateNoPaging.php b/codegen/Crm/Timeline/Model/CollectionResponseTimelineEventTemplateNoPaging.php index d383155a..ca6af4de 100644 --- a/codegen/Crm/Timeline/Model/CollectionResponseTimelineEventTemplateNoPaging.php +++ b/codegen/Crm/Timeline/Model/CollectionResponseTimelineEventTemplateNoPaging.php @@ -2,7 +2,7 @@ /** * CollectionResponseTimelineEventTemplateNoPaging * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -321,11 +321,11 @@ public function setResults($results) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -333,12 +333,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -363,11 +363,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/Error.php b/codegen/Crm/Timeline/Model/Error.php index 2ff7992a..f7a76f3b 100644 --- a/codegen/Crm/Timeline/Model/Error.php +++ b/codegen/Crm/Timeline/Model/Error.php @@ -2,7 +2,7 @@ /** * Error * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -531,11 +531,11 @@ public function setErrors($errors) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -543,12 +543,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -573,11 +573,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/ErrorDetail.php b/codegen/Crm/Timeline/Model/ErrorDetail.php index 315e1a10..b5982eb3 100644 --- a/codegen/Crm/Timeline/Model/ErrorDetail.php +++ b/codegen/Crm/Timeline/Model/ErrorDetail.php @@ -2,7 +2,7 @@ /** * ErrorDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -457,11 +457,11 @@ public function setMessage($message) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -469,12 +469,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -499,11 +499,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/EventDetail.php b/codegen/Crm/Timeline/Model/EventDetail.php index bda490f3..1edaeefc 100644 --- a/codegen/Crm/Timeline/Model/EventDetail.php +++ b/codegen/Crm/Timeline/Model/EventDetail.php @@ -2,7 +2,7 @@ /** * EventDetail * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -322,11 +322,11 @@ public function setDetails($details) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -334,12 +334,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -364,11 +364,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/ModelInterface.php b/codegen/Crm/Timeline/Model/ModelInterface.php index 2493c8d7..56517bae 100644 --- a/codegen/Crm/Timeline/Model/ModelInterface.php +++ b/codegen/Crm/Timeline/Model/ModelInterface.php @@ -2,7 +2,7 @@ /** * ModelInterface * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline\Model @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** diff --git a/codegen/Crm/Timeline/Model/StandardError.php b/codegen/Crm/Timeline/Model/StandardError.php index 4d7df475..882fd8cc 100644 --- a/codegen/Crm/Timeline/Model/StandardError.php +++ b/codegen/Crm/Timeline/Model/StandardError.php @@ -2,7 +2,7 @@ /** * StandardError * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -35,6 +35,7 @@ * StandardError Class Doc Comment * * @category Class + * @description Ye olde error * @package HubSpot\Client\Crm\Timeline * @author OpenAPI Generator team * @link https://openapi-generator.tech @@ -369,7 +370,7 @@ public function getSubCategory() /** * Sets sub_category * - * @param object|null $sub_category sub_category + * @param object|null $sub_category A more specific error category within each main category. * * @return self */ @@ -396,7 +397,7 @@ public function getContext() /** * Sets context * - * @param array $context context + * @param array $context Additional context-specific information related to the error. * * @return self */ @@ -423,7 +424,7 @@ public function getLinks() /** * Sets links * - * @param array $links links + * @param array $links URLs linking to documentation or resources associated with the error. * * @return self */ @@ -450,7 +451,7 @@ public function getId() /** * Sets id * - * @param string|null $id id + * @param string|null $id A unique ID for the error instance. * * @return self */ @@ -477,7 +478,7 @@ public function getCategory() /** * Sets category * - * @param string $category category + * @param string $category The main category of the error. * * @return self */ @@ -504,7 +505,7 @@ public function getMessage() /** * Sets message * - * @param string $message message + * @param string $message A human-readable string describing the error and possible remediation steps. * * @return self */ @@ -531,7 +532,7 @@ public function getErrors() /** * Sets errors * - * @param \HubSpot\Client\Crm\Timeline\Model\ErrorDetail[] $errors errors + * @param \HubSpot\Client\Crm\Timeline\Model\ErrorDetail[] $errors The detailed error objects. * * @return self */ @@ -558,7 +559,7 @@ public function getStatus() /** * Sets status * - * @param string $status status + * @param string $status The HTTP status code associated with the error. * * @return self */ @@ -574,11 +575,11 @@ public function setStatus($status) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -586,12 +587,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -616,11 +617,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEvent.php b/codegen/Crm/Timeline/Model/TimelineEvent.php index 58150d68..1d11472e 100644 --- a/codegen/Crm/Timeline/Model/TimelineEvent.php +++ b/codegen/Crm/Timeline/Model/TimelineEvent.php @@ -2,7 +2,7 @@ /** * TimelineEvent * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -631,11 +631,11 @@ public function setTimestamp($timestamp) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -643,12 +643,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -673,11 +673,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventIFrame.php b/codegen/Crm/Timeline/Model/TimelineEventIFrame.php index 63fcdb05..4b6f74a2 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventIFrame.php +++ b/codegen/Crm/Timeline/Model/TimelineEventIFrame.php @@ -2,7 +2,7 @@ /** * TimelineEventIFrame * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -469,11 +469,11 @@ public function setHeight($height) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -481,12 +481,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -511,11 +511,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventResponse.php b/codegen/Crm/Timeline/Model/TimelineEventResponse.php index ae63225f..cbc283b6 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventResponse.php +++ b/codegen/Crm/Timeline/Model/TimelineEventResponse.php @@ -2,7 +2,7 @@ /** * TimelineEventResponse * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -705,11 +705,11 @@ public function setObjectType($object_type) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -717,12 +717,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -747,11 +747,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplate.php b/codegen/Crm/Timeline/Model/TimelineEventTemplate.php index 61a48ba9..a2b196c9 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplate.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplate.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplate * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -569,11 +569,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -581,12 +581,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -611,11 +611,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplateCreateRequest.php b/codegen/Crm/Timeline/Model/TimelineEventTemplateCreateRequest.php index 6262807a..d74d8be9 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplateCreateRequest.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplateCreateRequest.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplateCreateRequest * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -464,11 +464,11 @@ public function setObjectType($object_type) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -476,12 +476,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -506,11 +506,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplateToken.php b/codegen/Crm/Timeline/Model/TimelineEventTemplateToken.php index 08f59cc1..16c9e958 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplateToken.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplateToken.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplateToken * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -570,11 +570,11 @@ public function setUpdatedAt($updated_at) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -582,12 +582,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -612,11 +612,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenOption.php b/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenOption.php index a11be593..91009b27 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenOption.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenOption.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplateTokenOption * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -358,11 +358,11 @@ public function setValue($value) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -370,12 +370,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -400,11 +400,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenUpdateRequest.php b/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenUpdateRequest.php index 4dab70c1..30e3e882 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenUpdateRequest.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplateTokenUpdateRequest.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplateTokenUpdateRequest * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -390,11 +390,11 @@ public function setObjectPropertyName($object_property_name) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -402,12 +402,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -432,11 +432,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/Model/TimelineEventTemplateUpdateRequest.php b/codegen/Crm/Timeline/Model/TimelineEventTemplateUpdateRequest.php index 45e405c2..dab8f2dd 100644 --- a/codegen/Crm/Timeline/Model/TimelineEventTemplateUpdateRequest.php +++ b/codegen/Crm/Timeline/Model/TimelineEventTemplateUpdateRequest.php @@ -2,7 +2,7 @@ /** * TimelineEventTemplateUpdateRequest * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -464,11 +464,11 @@ public function setHeaderTemplate($header_template) /** * Returns true if offset exists. False otherwise. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return boolean */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } @@ -476,12 +476,12 @@ public function offsetExists($offset): bool /** * Gets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } @@ -506,11 +506,11 @@ public function offsetSet($offset, $value): void /** * Unsets offset. * - * @param integer $offset Offset + * @param integer|string $offset Offset * * @return void */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } diff --git a/codegen/Crm/Timeline/ObjectSerializer.php b/codegen/Crm/Timeline/ObjectSerializer.php index 48cfc164..51017b88 100644 --- a/codegen/Crm/Timeline/ObjectSerializer.php +++ b/codegen/Crm/Timeline/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.4 + * PHP version 8.1 * * @category Class * @package HubSpot\Client\Crm\Timeline @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * Generator version: 7.12.0 + * Generator version: 7.17.0 */ /** @@ -323,24 +323,6 @@ public static function toHeaderValue($value) return self::toString($value); } - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged @@ -612,6 +594,6 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): } } - return $qs ? (string) substr($qs, 0, -1) : ''; + return $qs ? substr($qs, 0, -1) : ''; } }