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
671 changes: 237 additions & 434 deletions codegen/Crm/Objects/Api/BasicApi.php

Large diffs are not rendered by default.

709 changes: 186 additions & 523 deletions codegen/Crm/Objects/Api/BatchApi.php

Large diffs are not rendered by default.

190 changes: 92 additions & 98 deletions codegen/Crm/Objects/Api/SearchApi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* SearchApi
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Crm\Objects
Expand All @@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 7.3.0
* Generator version: 7.19.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\Crm\Objects\ApiException;
use HubSpot\Client\Crm\Objects\Configuration;
use HubSpot\Client\Crm\Objects\FormDataProcessor;
use HubSpot\Client\Crm\Objects\HeaderSelector;
use HubSpot\Client\Crm\Objects\ObjectSerializer;

Expand Down Expand Up @@ -83,13 +86,13 @@ class SearchApi
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$hostIndex = 0
?ClientInterface $client = null,
?Configuration $config = null,
?HeaderSelector $selector = null,
int $hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->config = $config ?: Configuration::getDefaultConfiguration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
Expand Down Expand Up @@ -131,7 +134,7 @@ public function getConfig()
*
* @throws \HubSpot\Client\Crm\Objects\ApiException on non-2xx response or if the response body is not in the expected format
* @throws \InvalidArgumentException
* @return \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging|\HubSpot\Client\Crm\Objects\Model\Error
* @return \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject|\HubSpot\Client\Crm\Objects\Model\Error
*/
public function doSearch($object_type, $public_object_search_request, string $contentType = self::contentTypes['doSearch'][0])
{
Expand All @@ -148,7 +151,7 @@ public function doSearch($object_type, $public_object_search_request, string $co
*
* @throws \HubSpot\Client\Crm\Objects\ApiException on non-2xx response or if the response body is not in the expected format
* @throws \InvalidArgumentException
* @return array of \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging|\HubSpot\Client\Crm\Objects\Model\Error, HTTP status code, HTTP response headers (array of strings)
* @return array of \HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject|\HubSpot\Client\Crm\Objects\Model\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function doSearchWithHttpInfo($object_type, $public_object_search_request, string $contentType = self::contentTypes['doSearch'][0])
{
Expand Down Expand Up @@ -176,6 +179,24 @@ public function doSearchWithHttpInfo($object_type, $public_object_search_request

$statusCode = $response->getStatusCode();


switch($statusCode) {
case 200:
return $this->handleResponseWithDataType(
'\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject',
$request,
$response,
);
default:
return $this->handleResponseWithDataType(
'\HubSpot\Client\Crm\Objects\Model\Error',
$request,
$response,
);
}



if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
Expand All @@ -189,110 +210,32 @@ public function doSearchWithHttpInfo($object_type, $public_object_search_request
);
}

switch($statusCode) {
case 200:
if ('\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging' !== '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\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\HubSpot\Client\Crm\Objects\Model\Error' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\HubSpot\Client\Crm\Objects\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\Objects\Model\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
}

$returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging';
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\Objects\Model\CollectionResponseWithTotalSimplePublicObject',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging',
'\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Objects\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


throw $e;
}
}
Expand Down Expand Up @@ -329,7 +272,7 @@ function ($response) {
*/
public function doSearchAsyncWithHttpInfo($object_type, $public_object_search_request, string $contentType = self::contentTypes['doSearch'][0])
{
$returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging';
$returnType = '\HubSpot\Client\Crm\Objects\Model\CollectionResponseWithTotalSimplePublicObject';
$request = $this->doSearchRequest($object_type, $public_object_search_request, $contentType);

return $this->client
Expand Down Expand Up @@ -495,6 +438,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;
}
}
10 changes: 5 additions & 5 deletions codegen/Crm/Objects/ApiException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* ApiException
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Crm\Objects
Expand All @@ -16,7 +16,7 @@
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 7.3.0
* Generator version: 7.19.0
*/

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ class ApiException extends Exception
/**
* The HTTP header of the server response.
*
* @var string[]|null
* @var string[][]|null
*/
protected $responseHeaders;

Expand All @@ -65,7 +65,7 @@ class ApiException extends Exception
*
* @param string $message Error message
* @param int $code HTTP status code
* @param string[]|null $responseHeaders HTTP response header
* @param string[][]|null $responseHeaders HTTP response header
* @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string
*/
public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null)
Expand All @@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re
/**
* Gets the HTTP response header
*
* @return string[]|null HTTP response header
* @return string[][]|null HTTP response header
*/
public function getResponseHeaders()
{
Expand Down
Loading