Skip to content

Commit 69fc0a8

Browse files
Merge pull request #513 from HubSpot/codegen/cmsClients
Codegen: CMS Clients
2 parents a173899 + d512344 commit 69fc0a8

106 files changed

Lines changed: 3681 additions & 5079 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codegen/Cms/AuditLogs/Api/AuditLogsApi.php

Lines changed: 77 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* AuditLogsApi
4-
* PHP version 7.4
4+
* PHP version 8.1
55
*
66
* @category Class
77
* @package HubSpot\Client\Cms\AuditLogs
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* Generator version: 7.12.0
19+
* Generator version: 7.17.0
2020
*/
2121

2222
/**
@@ -34,8 +34,11 @@
3434
use GuzzleHttp\Psr7\MultipartStream;
3535
use GuzzleHttp\Psr7\Request;
3636
use GuzzleHttp\RequestOptions;
37+
use Psr\Http\Message\RequestInterface;
38+
use Psr\Http\Message\ResponseInterface;
3739
use HubSpot\Client\Cms\AuditLogs\ApiException;
3840
use HubSpot\Client\Cms\AuditLogs\Configuration;
41+
use HubSpot\Client\Cms\AuditLogs\FormDataProcessor;
3942
use HubSpot\Client\Cms\AuditLogs\HeaderSelector;
4043
use HubSpot\Client\Cms\AuditLogs\ObjectSerializer;
4144

@@ -195,61 +198,21 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
195198

196199
switch($statusCode) {
197200
case 200:
198-
if ('\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog' === '\SplFileObject') {
199-
$content = $response->getBody(); //stream goes to serializer
200-
} else {
201-
$content = (string) $response->getBody();
202-
if ('\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog' !== 'string') {
203-
try {
204-
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
205-
} catch (\JsonException $exception) {
206-
throw new ApiException(
207-
sprintf(
208-
'Error JSON decoding server response (%s)',
209-
$request->getUri()
210-
),
211-
$statusCode,
212-
$response->getHeaders(),
213-
$content
214-
);
215-
}
216-
}
217-
}
218-
219-
return [
220-
ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog', []),
221-
$response->getStatusCode(),
222-
$response->getHeaders()
223-
];
201+
return $this->handleResponseWithDataType(
202+
'\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog',
203+
$request,
204+
$response,
205+
);
224206
default:
225-
if ('\HubSpot\Client\Cms\AuditLogs\Model\Error' === '\SplFileObject') {
226-
$content = $response->getBody(); //stream goes to serializer
227-
} else {
228-
$content = (string) $response->getBody();
229-
if ('\HubSpot\Client\Cms\AuditLogs\Model\Error' !== 'string') {
230-
try {
231-
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
232-
} catch (\JsonException $exception) {
233-
throw new ApiException(
234-
sprintf(
235-
'Error JSON decoding server response (%s)',
236-
$request->getUri()
237-
),
238-
$statusCode,
239-
$response->getHeaders(),
240-
$content
241-
);
242-
}
243-
}
244-
}
245-
246-
return [
247-
ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\AuditLogs\Model\Error', []),
248-
$response->getStatusCode(),
249-
$response->getHeaders()
250-
];
207+
return $this->handleResponseWithDataType(
208+
'\HubSpot\Client\Cms\AuditLogs\Model\Error',
209+
$request,
210+
$response,
211+
);
251212
}
252213

214+
215+
253216
if ($statusCode < 200 || $statusCode > 299) {
254217
throw new ApiException(
255218
sprintf(
@@ -263,34 +226,11 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
263226
);
264227
}
265228

266-
$returnType = '\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog';
267-
if ($returnType === '\SplFileObject') {
268-
$content = $response->getBody(); //stream goes to serializer
269-
} else {
270-
$content = (string) $response->getBody();
271-
if ($returnType !== 'string') {
272-
try {
273-
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
274-
} catch (\JsonException $exception) {
275-
throw new ApiException(
276-
sprintf(
277-
'Error JSON decoding server response (%s)',
278-
$request->getUri()
279-
),
280-
$statusCode,
281-
$response->getHeaders(),
282-
$content
283-
);
284-
}
285-
}
286-
}
287-
288-
return [
289-
ObjectSerializer::deserialize($content, $returnType, []),
290-
$response->getStatusCode(),
291-
$response->getHeaders()
292-
];
293-
229+
return $this->handleResponseWithDataType(
230+
'\HubSpot\Client\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog',
231+
$request,
232+
$response,
233+
);
294234
} catch (ApiException $e) {
295235
switch ($e->getCode()) {
296236
case 200:
@@ -300,16 +240,18 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object
300240
$e->getResponseHeaders()
301241
);
302242
$e->setResponseObject($data);
303-
break;
243+
throw $e;
304244
default:
305245
$data = ObjectSerializer::deserialize(
306246
$e->getResponseBody(),
307247
'\HubSpot\Client\Cms\AuditLogs\Model\Error',
308248
$e->getResponseHeaders()
309249
);
310250
$e->setResponseObject($data);
311-
break;
251+
throw $e;
312252
}
253+
254+
313255
throw $e;
314256
}
315257
}
@@ -585,6 +527,57 @@ protected function createHttpClientOption()
585527
}
586528
}
587529

530+
if ($this->config->getCertFile()) {
531+
$options[RequestOptions::CERT] = $this->config->getCertFile();
532+
}
533+
534+
if ($this->config->getKeyFile()) {
535+
$options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
536+
}
537+
588538
return $options;
589539
}
540+
541+
private function handleResponseWithDataType(
542+
string $dataType,
543+
RequestInterface $request,
544+
ResponseInterface $response
545+
): array {
546+
if ($dataType === '\SplFileObject') {
547+
$content = $response->getBody(); //stream goes to serializer
548+
} else {
549+
$content = (string) $response->getBody();
550+
if ($dataType !== 'string') {
551+
try {
552+
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
553+
} catch (\JsonException $exception) {
554+
throw new ApiException(
555+
sprintf(
556+
'Error JSON decoding server response (%s)',
557+
$request->getUri()
558+
),
559+
$response->getStatusCode(),
560+
$response->getHeaders(),
561+
$content
562+
);
563+
}
564+
}
565+
}
566+
567+
return [
568+
ObjectSerializer::deserialize($content, $dataType, []),
569+
$response->getStatusCode(),
570+
$response->getHeaders()
571+
];
572+
}
573+
574+
private function responseWithinRangeCode(
575+
string $rangeCode,
576+
int $statusCode
577+
): bool {
578+
$left = (int) ($rangeCode[0].'00');
579+
$right = (int) ($rangeCode[0].'99');
580+
581+
return $statusCode >= $left && $statusCode <= $right;
582+
}
590583
}

codegen/Cms/AuditLogs/ApiException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* ApiException
4-
* PHP version 7.4
4+
* PHP version 8.1
55
*
66
* @category Class
77
* @package HubSpot\Client\Cms\AuditLogs
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* Generator version: 7.12.0
19+
* Generator version: 7.17.0
2020
*/
2121

2222
/**

codegen/Cms/AuditLogs/Configuration.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Configuration
4-
* PHP version 7.4
4+
* PHP version 8.1
55
*
66
* @category Class
77
* @package HubSpot\Client\Cms\AuditLogs
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* Generator version: 7.12.0
19+
* Generator version: 7.17.0
2020
*/
2121

2222
/**
@@ -29,7 +29,7 @@
2929

3030
/**
3131
* Configuration Class Doc Comment
32-
* PHP version 7.4
32+
* PHP version 8.1
3333
*
3434
* @category Class
3535
* @package HubSpot\Client\Cms\AuditLogs
@@ -123,6 +123,20 @@ class Configuration
123123
*/
124124
protected $tempFolderPath;
125125

126+
/**
127+
* Path to a certificate file, for mTLS
128+
*
129+
* @var string
130+
*/
131+
protected $certFile;
132+
133+
/**
134+
* Path to a key file, for mTLS
135+
*
136+
* @var string
137+
*/
138+
protected $keyFile;
139+
126140
/**
127141
* Constructor
128142
*/
@@ -396,6 +410,49 @@ public function getTempFolderPath()
396410
return $this->tempFolderPath;
397411
}
398412

413+
/**
414+
* Sets the certificate file path, for mTLS
415+
*
416+
* @return $this
417+
*/
418+
public function setCertFile($certFile)
419+
{
420+
$this->certFile = $certFile;
421+
return $this;
422+
}
423+
424+
/**
425+
* Gets the certificate file path, for mTLS
426+
*
427+
* @return string Certificate file path
428+
*/
429+
public function getCertFile()
430+
{
431+
return $this->certFile;
432+
}
433+
434+
/**
435+
* Sets the certificate key path, for mTLS
436+
*
437+
* @return $this
438+
*/
439+
public function setKeyFile($keyFile)
440+
{
441+
$this->keyFile = $keyFile;
442+
return $this;
443+
}
444+
445+
/**
446+
* Gets the certificate key path, for mTLS
447+
*
448+
* @return string Certificate key path
449+
*/
450+
public function getKeyFile()
451+
{
452+
return $this->keyFile;
453+
}
454+
455+
399456
/**
400457
* Gets the default configuration instance
401458
*

0 commit comments

Comments
 (0)