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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* MappingApi
* PHP version 7.4
* IDMappingApi
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Crm\Lists
Expand All @@ -10,13 +10,13 @@
*/

/**
* Lists
* CRM Lists
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* CRUD operations to manage lists and list memberships
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
* Generator version: 7.19.0
*/

/**
Expand All @@ -34,20 +34,23 @@
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\Lists\ApiException;
use HubSpot\Client\Crm\Lists\Configuration;
use HubSpot\Client\Crm\Lists\FormDataProcessor;
use HubSpot\Client\Crm\Lists\HeaderSelector;
use HubSpot\Client\Crm\Lists\ObjectSerializer;

/**
* MappingApi Class Doc Comment
* IDMappingApi Class Doc Comment
*
* @category Class
* @package HubSpot\Client\Crm\Lists
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class MappingApi
class IDMappingApi
{
/**
* @var ClientInterface
Expand Down Expand Up @@ -184,61 +187,21 @@ public function translateLegacyListIdToListIdWithHttpInfo($legacy_list_id = null

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



if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
Expand All @@ -252,34 +215,11 @@ public function translateLegacyListIdToListIdWithHttpInfo($legacy_list_id = null
);
}

$returnType = '\HubSpot\Client\Crm\Lists\Model\PublicMigrationMapping';
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\Lists\Model\PublicMigrationMapping',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
Expand All @@ -289,16 +229,18 @@ public function translateLegacyListIdToListIdWithHttpInfo($legacy_list_id = null
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Lists\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


throw $e;
}
}
Expand Down Expand Up @@ -526,61 +468,21 @@ public function translateLegacyListIdToListIdBatchWithHttpInfo($request_body, st

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



if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
Expand All @@ -594,34 +496,11 @@ public function translateLegacyListIdToListIdBatchWithHttpInfo($request_body, st
);
}

$returnType = '\HubSpot\Client\Crm\Lists\Model\PublicBatchMigrationMapping';
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\Lists\Model\PublicBatchMigrationMapping',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
Expand All @@ -631,16 +510,18 @@ public function translateLegacyListIdToListIdBatchWithHttpInfo($request_body, st
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Lists\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


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