Skip to content

Commit de7d35c

Browse files
Merge pull request #466 from HubSpot/feature/codegenAssociations
Codegen: CRM Associations
2 parents ed1a4fe + d09b91f commit de7d35c

99 files changed

Lines changed: 10571 additions & 826 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/Crm/Associations/Api/BatchApi.php

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -89,13 +89,13 @@ class BatchApi
8989
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
9090
*/
9191
public function __construct(
92-
ClientInterface $client = null,
93-
Configuration $config = null,
94-
HeaderSelector $selector = null,
95-
$hostIndex = 0
92+
?ClientInterface $client = null,
93+
?Configuration $config = null,
94+
?HeaderSelector $selector = null,
95+
int $hostIndex = 0
9696
) {
9797
$this->client = $client ?: new Client();
98-
$this->config = $config ?: new Configuration();
98+
$this->config = $config ?: Configuration::getDefaultConfiguration();
9999
$this->headerSelector = $selector ?: new HeaderSelector();
100100
$this->hostIndex = $hostIndex;
101101
}
@@ -187,18 +187,6 @@ public function archiveWithHttpInfo($from_object_type, $to_object_type, $batch_i
187187

188188
$statusCode = $response->getStatusCode();
189189

190-
if ($statusCode < 200 || $statusCode > 299) {
191-
throw new ApiException(
192-
sprintf(
193-
'[%d] Error connecting to the API (%s)',
194-
$statusCode,
195-
(string) $request->getUri()
196-
),
197-
$statusCode,
198-
$response->getHeaders(),
199-
(string) $response->getBody()
200-
);
201-
}
202190

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

@@ -468,18 +456,6 @@ public function createWithHttpInfo($from_object_type, $to_object_type, $batch_in
468456

469457
$statusCode = $response->getStatusCode();
470458

471-
if ($statusCode < 200 || $statusCode > 299) {
472-
throw new ApiException(
473-
sprintf(
474-
'[%d] Error connecting to the API (%s)',
475-
$statusCode,
476-
(string) $request->getUri()
477-
),
478-
$statusCode,
479-
$response->getHeaders(),
480-
(string) $response->getBody()
481-
);
482-
}
483459

484460
switch($statusCode) {
485461
case 201:
@@ -565,6 +541,19 @@ public function createWithHttpInfo($from_object_type, $to_object_type, $batch_in
565541
];
566542
}
567543

544+
if ($statusCode < 200 || $statusCode > 299) {
545+
throw new ApiException(
546+
sprintf(
547+
'[%d] Error connecting to the API (%s)',
548+
$statusCode,
549+
(string) $request->getUri()
550+
),
551+
$statusCode,
552+
$response->getHeaders(),
553+
(string) $response->getBody()
554+
);
555+
}
556+
568557
$returnType = '\HubSpot\Client\Crm\Associations\Model\BatchResponsePublicAssociation';
569558
if ($returnType === '\SplFileObject') {
570559
$content = $response->getBody(); //stream goes to serializer
@@ -888,18 +877,6 @@ public function readWithHttpInfo($from_object_type, $to_object_type, $batch_inpu
888877

889878
$statusCode = $response->getStatusCode();
890879

891-
if ($statusCode < 200 || $statusCode > 299) {
892-
throw new ApiException(
893-
sprintf(
894-
'[%d] Error connecting to the API (%s)',
895-
$statusCode,
896-
(string) $request->getUri()
897-
),
898-
$statusCode,
899-
$response->getHeaders(),
900-
(string) $response->getBody()
901-
);
902-
}
903880

904881
switch($statusCode) {
905882
case 200:
@@ -985,6 +962,19 @@ public function readWithHttpInfo($from_object_type, $to_object_type, $batch_inpu
985962
];
986963
}
987964

965+
if ($statusCode < 200 || $statusCode > 299) {
966+
throw new ApiException(
967+
sprintf(
968+
'[%d] Error connecting to the API (%s)',
969+
$statusCode,
970+
(string) $request->getUri()
971+
),
972+
$statusCode,
973+
$response->getHeaders(),
974+
(string) $response->getBody()
975+
);
976+
}
977+
988978
$returnType = '\HubSpot\Client\Crm\Associations\Model\BatchResponsePublicAssociationMulti';
989979
if ($returnType === '\SplFileObject') {
990980
$content = $response->getBody(); //stream goes to serializer

codegen/Crm/Associations/ApiException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -49,7 +49,7 @@ class ApiException extends Exception
4949
/**
5050
* The HTTP header of the server response.
5151
*
52-
* @var string[]|null
52+
* @var string[][]|null
5353
*/
5454
protected $responseHeaders;
5555

@@ -65,7 +65,7 @@ class ApiException extends Exception
6565
*
6666
* @param string $message Error message
6767
* @param int $code HTTP status code
68-
* @param string[]|null $responseHeaders HTTP response header
68+
* @param string[][]|null $responseHeaders HTTP response header
6969
* @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string
7070
*/
7171
public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null)
@@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re
7878
/**
7979
* Gets the HTTP response header
8080
*
81-
* @return string[]|null HTTP response header
81+
* @return string[][]|null HTTP response header
8282
*/
8383
public function getResponseHeaders()
8484
{

codegen/Crm/Associations/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -486,7 +486,7 @@ public function getHostSettings()
486486
* @param array|null $variables hash of variable and the corresponding value (optional)
487487
* @return string URL based on host settings
488488
*/
489-
public static function getHostString(array $hostSettings, $hostIndex, array $variables = null)
489+
public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null)
490490
{
491491
if (null === $variables) {
492492
$variables = [];

codegen/Crm/Associations/HeaderSelector.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* The version of the OpenAPI document: v3
1818
* Generated by: https://openapi-generator.tech
19-
* OpenAPI Generator version: 7.3.0
19+
* Generator version: 7.12.0
2020
*/
2121

2222
/**
@@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string
8585
}
8686

8787
# If none of the available Accept headers is of type "json", then just use all them
88-
$headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept);
88+
$headersWithJson = $this->selectJsonMimeList($accept);
8989
if (count($headersWithJson) === 0) {
9090
return implode(',', $accept);
9191
}
@@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string
9595
return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson);
9696
}
9797

98+
/**
99+
* Detects whether a string contains a valid JSON mime type
100+
*
101+
* @param string $searchString
102+
* @return bool
103+
*/
104+
public function isJsonMime(string $searchString): bool
105+
{
106+
return preg_match('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~', $searchString) === 1;
107+
}
108+
109+
/**
110+
* Select all items from a list containing a JSON mime type
111+
*
112+
* @param array $mimeList
113+
* @return array
114+
*/
115+
private function selectJsonMimeList(array $mimeList): array {
116+
$jsonMimeList = [];
117+
foreach ($mimeList as $mime) {
118+
if($this->isJsonMime($mime)) {
119+
$jsonMimeList[] = $mime;
120+
}
121+
}
122+
return $jsonMimeList;
123+
}
124+
125+
98126
/**
99127
* Create an Accept header string from the given "Accept" headers array, recalculating all weights
100128
*

codegen/Crm/Associations/Model/AssociatedId.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -245,10 +245,10 @@ public function getModelName()
245245
/**
246246
* Constructor
247247
*
248-
* @param mixed[] $data Associated array of property values
248+
* @param mixed[]|null $data Associated array of property values
249249
* initializing the model
250250
*/
251-
public function __construct(array $data = null)
251+
public function __construct(?array $data = null)
252252
{
253253
$this->setIfExists('id', $data ?? [], null);
254254
$this->setIfExists('type', $data ?? [], null);

codegen/Crm/Associations/Model/BatchInputPublicAssociation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -239,10 +239,10 @@ public function getModelName()
239239
/**
240240
* Constructor
241241
*
242-
* @param mixed[] $data Associated array of property values
242+
* @param mixed[]|null $data Associated array of property values
243243
* initializing the model
244244
*/
245-
public function __construct(array $data = null)
245+
public function __construct(?array $data = null)
246246
{
247247
$this->setIfExists('inputs', $data ?? [], null);
248248
}

codegen/Crm/Associations/Model/BatchInputPublicObjectId.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -239,10 +239,10 @@ public function getModelName()
239239
/**
240240
* Constructor
241241
*
242-
* @param mixed[] $data Associated array of property values
242+
* @param mixed[]|null $data Associated array of property values
243243
* initializing the model
244244
*/
245-
public function __construct(array $data = null)
245+
public function __construct(?array $data = null)
246246
{
247247
$this->setIfExists('inputs', $data ?? [], null);
248248
}

codegen/Crm/Associations/Model/BatchResponsePublicAssociation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -288,10 +288,10 @@ public function getStatusAllowableValues()
288288
/**
289289
* Constructor
290290
*
291-
* @param mixed[] $data Associated array of property values
291+
* @param mixed[]|null $data Associated array of property values
292292
* initializing the model
293293
*/
294-
public function __construct(array $data = null)
294+
public function __construct(?array $data = null)
295295
{
296296
$this->setIfExists('completed_at', $data ?? [], null);
297297
$this->setIfExists('requested_at', $data ?? [], null);

codegen/Crm/Associations/Model/BatchResponsePublicAssociationMulti.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -288,10 +288,10 @@ public function getStatusAllowableValues()
288288
/**
289289
* Constructor
290290
*
291-
* @param mixed[] $data Associated array of property values
291+
* @param mixed[]|null $data Associated array of property values
292292
* initializing the model
293293
*/
294-
public function __construct(array $data = null)
294+
public function __construct(?array $data = null)
295295
{
296296
$this->setIfExists('completed_at', $data ?? [], null);
297297
$this->setIfExists('requested_at', $data ?? [], null);

codegen/Crm/Associations/Model/BatchResponsePublicAssociationMultiWithErrors.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* The version of the OpenAPI document: v3
1919
* Generated by: https://openapi-generator.tech
20-
* OpenAPI Generator version: 7.3.0
20+
* Generator version: 7.12.0
2121
*/
2222

2323
/**
@@ -300,10 +300,10 @@ public function getStatusAllowableValues()
300300
/**
301301
* Constructor
302302
*
303-
* @param mixed[] $data Associated array of property values
303+
* @param mixed[]|null $data Associated array of property values
304304
* initializing the model
305305
*/
306-
public function __construct(array $data = null)
306+
public function __construct(?array $data = null)
307307
{
308308
$this->setIfExists('completed_at', $data ?? [], null);
309309
$this->setIfExists('num_errors', $data ?? [], null);

0 commit comments

Comments
 (0)