Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 62 additions & 6 deletions codegen/Automation/Actions/Api/CallbacksApi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* CallbacksApi
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Automation\Actions
Expand All @@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: v4
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
* Generator version: 7.17.0
*/

/**
Expand All @@ -34,8 +34,11 @@
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use HubSpot\Client\Automation\Actions\ApiException;
use HubSpot\Client\Automation\Actions\Configuration;
use HubSpot\Client\Automation\Actions\FormDataProcessor;
use HubSpot\Client\Automation\Actions\HeaderSelector;
use HubSpot\Client\Automation\Actions\ObjectSerializer;

Expand Down Expand Up @@ -184,7 +187,6 @@ public function completeWithHttpInfo($callback_id, $callback_completion_request,


return [null, $statusCode, $response->getHeaders()];

} catch (ApiException $e) {
switch ($e->getCode()) {
default:
Expand All @@ -194,8 +196,10 @@ public function completeWithHttpInfo($callback_id, $callback_completion_request,
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


throw $e;
}
}
Expand Down Expand Up @@ -430,7 +434,6 @@ public function completeBatchWithHttpInfo($batch_input_callback_completion_batch


return [null, $statusCode, $response->getHeaders()];

} catch (ApiException $e) {
switch ($e->getCode()) {
default:
Expand All @@ -440,8 +443,10 @@ public function completeBatchWithHttpInfo($batch_input_callback_completion_batch
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


throw $e;
}
}
Expand Down Expand Up @@ -617,6 +622,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;
}
}
Loading