Skip to content

Commit 73cba4b

Browse files
Merge pull request #472 from HubSpot/feature/codegenCrmImports
Codegen: CRM Imports
2 parents 4e8851b + cd21465 commit 73cba4b

23 files changed

Lines changed: 1819 additions & 199 deletions

codegen/Crm/Imports/Api/CoreApi.php

Lines changed: 84 additions & 79 deletions
Large diffs are not rendered by default.

codegen/Crm/Imports/Api/PublicImportsApi.php

Lines changed: 68 additions & 37 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
/**
@@ -83,13 +83,13 @@ class PublicImportsApi
8383
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
8484
*/
8585
public function __construct(
86-
ClientInterface $client = null,
87-
Configuration $config = null,
88-
HeaderSelector $selector = null,
89-
$hostIndex = 0
86+
?ClientInterface $client = null,
87+
?Configuration $config = null,
88+
?HeaderSelector $selector = null,
89+
int $hostIndex = 0
9090
) {
9191
$this->client = $client ?: new Client();
92-
$this->config = $config ?: new Configuration();
92+
$this->config = $config ?: Configuration::getDefaultConfiguration();
9393
$this->headerSelector = $selector ?: new HeaderSelector();
9494
$this->hostIndex = $hostIndex;
9595
}
@@ -126,35 +126,39 @@ public function getConfig()
126126
* Operation getErrors
127127
*
128128
* @param int $import_id import_id (required)
129-
* @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional)
130-
* @param int $limit The maximum number of results to display per page. (optional)
129+
* @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional)
130+
* @param int|null $limit The maximum number of results to display per page. (optional)
131+
* @param bool|null $include_error_message Set to True to receive a message explaining the error. (optional)
132+
* @param bool|null $include_row_data Set to True to receive the data values for the errored row. (optional)
131133
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getErrors'] to see the possible values for this operation
132134
*
133135
* @throws \HubSpot\Client\Crm\Imports\ApiException on non-2xx response or if the response body is not in the expected format
134136
* @throws \InvalidArgumentException
135137
* @return \HubSpot\Client\Crm\Imports\Model\CollectionResponsePublicImportErrorForwardPaging|\HubSpot\Client\Crm\Imports\Model\Error
136138
*/
137-
public function getErrors($import_id, $after = null, $limit = null, string $contentType = self::contentTypes['getErrors'][0])
139+
public function getErrors($import_id, $after = null, $limit = null, $include_error_message = null, $include_row_data = null, string $contentType = self::contentTypes['getErrors'][0])
138140
{
139-
list($response) = $this->getErrorsWithHttpInfo($import_id, $after, $limit, $contentType);
141+
list($response) = $this->getErrorsWithHttpInfo($import_id, $after, $limit, $include_error_message, $include_row_data, $contentType);
140142
return $response;
141143
}
142144

143145
/**
144146
* Operation getErrorsWithHttpInfo
145147
*
146148
* @param int $import_id (required)
147-
* @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional)
148-
* @param int $limit The maximum number of results to display per page. (optional)
149+
* @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional)
150+
* @param int|null $limit The maximum number of results to display per page. (optional)
151+
* @param bool|null $include_error_message Set to True to receive a message explaining the error. (optional)
152+
* @param bool|null $include_row_data Set to True to receive the data values for the errored row. (optional)
149153
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getErrors'] to see the possible values for this operation
150154
*
151155
* @throws \HubSpot\Client\Crm\Imports\ApiException on non-2xx response or if the response body is not in the expected format
152156
* @throws \InvalidArgumentException
153157
* @return array of \HubSpot\Client\Crm\Imports\Model\CollectionResponsePublicImportErrorForwardPaging|\HubSpot\Client\Crm\Imports\Model\Error, HTTP status code, HTTP response headers (array of strings)
154158
*/
155-
public function getErrorsWithHttpInfo($import_id, $after = null, $limit = null, string $contentType = self::contentTypes['getErrors'][0])
159+
public function getErrorsWithHttpInfo($import_id, $after = null, $limit = null, $include_error_message = null, $include_row_data = null, string $contentType = self::contentTypes['getErrors'][0])
156160
{
157-
$request = $this->getErrorsRequest($import_id, $after, $limit, $contentType);
161+
$request = $this->getErrorsRequest($import_id, $after, $limit, $include_error_message, $include_row_data, $contentType);
158162

159163
try {
160164
$options = $this->createHttpClientOption();
@@ -178,18 +182,6 @@ public function getErrorsWithHttpInfo($import_id, $after = null, $limit = null,
178182

179183
$statusCode = $response->getStatusCode();
180184

181-
if ($statusCode < 200 || $statusCode > 299) {
182-
throw new ApiException(
183-
sprintf(
184-
'[%d] Error connecting to the API (%s)',
185-
$statusCode,
186-
(string) $request->getUri()
187-
),
188-
$statusCode,
189-
$response->getHeaders(),
190-
(string) $response->getBody()
191-
);
192-
}
193185

194186
switch($statusCode) {
195187
case 200:
@@ -248,6 +240,19 @@ public function getErrorsWithHttpInfo($import_id, $after = null, $limit = null,
248240
];
249241
}
250242

243+
if ($statusCode < 200 || $statusCode > 299) {
244+
throw new ApiException(
245+
sprintf(
246+
'[%d] Error connecting to the API (%s)',
247+
$statusCode,
248+
(string) $request->getUri()
249+
),
250+
$statusCode,
251+
$response->getHeaders(),
252+
(string) $response->getBody()
253+
);
254+
}
255+
251256
$returnType = '\HubSpot\Client\Crm\Imports\Model\CollectionResponsePublicImportErrorForwardPaging';
252257
if ($returnType === '\SplFileObject') {
253258
$content = $response->getBody(); //stream goes to serializer
@@ -303,16 +308,18 @@ public function getErrorsWithHttpInfo($import_id, $after = null, $limit = null,
303308
* Operation getErrorsAsync
304309
*
305310
* @param int $import_id (required)
306-
* @param string $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
307-
* @param int $limit The maximum number of results to display per page. (optional)
311+
* @param string|null $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
312+
* @param int|null $limit The maximum number of results to display per page. (optional)
313+
* @param bool|null $include_error_message Set to True to receive a message explaining the error. (optional)
314+
* @param bool|null $include_row_data Set to True to receive the data values for the errored row. (optional)
308315
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getErrors'] to see the possible values for this operation
309316
*
310317
* @throws \InvalidArgumentException
311318
* @return \GuzzleHttp\Promise\PromiseInterface
312319
*/
313-
public function getErrorsAsync($import_id, $after = null, $limit = null, string $contentType = self::contentTypes['getErrors'][0])
320+
public function getErrorsAsync($import_id, $after = null, $limit = null, $include_error_message = null, $include_row_data = null, string $contentType = self::contentTypes['getErrors'][0])
314321
{
315-
return $this->getErrorsAsyncWithHttpInfo($import_id, $after, $limit, $contentType)
322+
return $this->getErrorsAsyncWithHttpInfo($import_id, $after, $limit, $include_error_message, $include_row_data, $contentType)
316323
->then(
317324
function ($response) {
318325
return $response[0];
@@ -324,17 +331,19 @@ function ($response) {
324331
* Operation getErrorsAsyncWithHttpInfo
325332
*
326333
* @param int $import_id (required)
327-
* @param string $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
328-
* @param int $limit The maximum number of results to display per page. (optional)
334+
* @param string|null $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
335+
* @param int|null $limit The maximum number of results to display per page. (optional)
336+
* @param bool|null $include_error_message Set to True to receive a message explaining the error. (optional)
337+
* @param bool|null $include_row_data Set to True to receive the data values for the errored row. (optional)
329338
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getErrors'] to see the possible values for this operation
330339
*
331340
* @throws \InvalidArgumentException
332341
* @return \GuzzleHttp\Promise\PromiseInterface
333342
*/
334-
public function getErrorsAsyncWithHttpInfo($import_id, $after = null, $limit = null, string $contentType = self::contentTypes['getErrors'][0])
343+
public function getErrorsAsyncWithHttpInfo($import_id, $after = null, $limit = null, $include_error_message = null, $include_row_data = null, string $contentType = self::contentTypes['getErrors'][0])
335344
{
336345
$returnType = '\HubSpot\Client\Crm\Imports\Model\CollectionResponsePublicImportErrorForwardPaging';
337-
$request = $this->getErrorsRequest($import_id, $after, $limit, $contentType);
346+
$request = $this->getErrorsRequest($import_id, $after, $limit, $include_error_message, $include_row_data, $contentType);
338347

339348
return $this->client
340349
->sendAsync($request, $this->createHttpClientOption())
@@ -376,14 +385,16 @@ function ($exception) {
376385
* Create request for operation 'getErrors'
377386
*
378387
* @param int $import_id (required)
379-
* @param string $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
380-
* @param int $limit The maximum number of results to display per page. (optional)
388+
* @param string|null $after The paging cursor token of the last successfully read resource will be returned as the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results. (optional)
389+
* @param int|null $limit The maximum number of results to display per page. (optional)
390+
* @param bool|null $include_error_message Set to True to receive a message explaining the error. (optional)
391+
* @param bool|null $include_row_data Set to True to receive the data values for the errored row. (optional)
381392
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['getErrors'] to see the possible values for this operation
382393
*
383394
* @throws \InvalidArgumentException
384395
* @return \GuzzleHttp\Psr7\Request
385396
*/
386-
public function getErrorsRequest($import_id, $after = null, $limit = null, string $contentType = self::contentTypes['getErrors'][0])
397+
public function getErrorsRequest($import_id, $after = null, $limit = null, $include_error_message = null, $include_row_data = null, string $contentType = self::contentTypes['getErrors'][0])
387398
{
388399

389400
// verify the required parameter 'import_id' is set
@@ -396,6 +407,8 @@ public function getErrorsRequest($import_id, $after = null, $limit = null, strin
396407

397408

398409

410+
411+
399412
$resourcePath = '/crm/v3/imports/{importId}/errors';
400413
$formParams = [];
401414
$queryParams = [];
@@ -421,6 +434,24 @@ public function getErrorsRequest($import_id, $after = null, $limit = null, strin
421434
true, // explode
422435
false // required
423436
) ?? []);
437+
// query params
438+
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
439+
$include_error_message,
440+
'includeErrorMessage', // param base name
441+
'boolean', // openApiType
442+
'form', // style
443+
true, // explode
444+
false // required
445+
) ?? []);
446+
// query params
447+
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
448+
$include_row_data,
449+
'includeRowData', // param base name
450+
'boolean', // openApiType
451+
'form', // style
452+
true, // explode
453+
false // required
454+
) ?? []);
424455

425456

426457
// path params

codegen/Crm/Imports/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/Imports/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/Imports/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/Imports/Model/ActionResponse.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
/**
@@ -282,10 +282,10 @@ public function getStatusAllowableValues()
282282
/**
283283
* Constructor
284284
*
285-
* @param mixed[] $data Associated array of property values
285+
* @param mixed[]|null $data Associated array of property values
286286
* initializing the model
287287
*/
288-
public function __construct(array $data = null)
288+
public function __construct(?array $data = null)
289289
{
290290
$this->setIfExists('completed_at', $data ?? [], null);
291291
$this->setIfExists('requested_at', $data ?? [], null);

codegen/Crm/Imports/Model/CollectionResponsePublicImportErrorForwardPaging.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('paging', $data ?? [], null);
254254
$this->setIfExists('results', $data ?? [], null);

codegen/Crm/Imports/Model/CollectionResponsePublicImportResponse.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('paging', $data ?? [], null);
254254
$this->setIfExists('results', $data ?? [], null);

0 commit comments

Comments
 (0)