Skip to content

Commit 03b5848

Browse files
Merge pull request #473 from HubSpot/feature/codegenCrmClients
Codegen: Crm clients
2 parents 73cba4b + 57bc81c commit 03b5848

309 files changed

Lines changed: 4324 additions & 2834 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/LineItems/Api/BasicApi.php

Lines changed: 118 additions & 126 deletions
Large diffs are not rendered by default.

codegen/Crm/LineItems/Api/BatchApi.php

Lines changed: 83 additions & 91 deletions
Large diffs are not rendered by default.

codegen/Crm/LineItems/Api/SearchApi.php

Lines changed: 27 additions & 18 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 SearchApi
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
}
@@ -125,6 +125,8 @@ public function getConfig()
125125
/**
126126
* Operation doSearch
127127
*
128+
* Search for line items
129+
*
128130
* @param \HubSpot\Client\Crm\LineItems\Model\PublicObjectSearchRequest $public_object_search_request public_object_search_request (required)
129131
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['doSearch'] to see the possible values for this operation
130132
*
@@ -141,6 +143,8 @@ public function doSearch($public_object_search_request, string $contentType = se
141143
/**
142144
* Operation doSearchWithHttpInfo
143145
*
146+
* Search for line items
147+
*
144148
* @param \HubSpot\Client\Crm\LineItems\Model\PublicObjectSearchRequest $public_object_search_request (required)
145149
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['doSearch'] to see the possible values for this operation
146150
*
@@ -174,18 +178,6 @@ public function doSearchWithHttpInfo($public_object_search_request, string $cont
174178

175179
$statusCode = $response->getStatusCode();
176180

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

190182
switch($statusCode) {
191183
case 200:
@@ -244,6 +236,19 @@ public function doSearchWithHttpInfo($public_object_search_request, string $cont
244236
];
245237
}
246238

239+
if ($statusCode < 200 || $statusCode > 299) {
240+
throw new ApiException(
241+
sprintf(
242+
'[%d] Error connecting to the API (%s)',
243+
$statusCode,
244+
(string) $request->getUri()
245+
),
246+
$statusCode,
247+
$response->getHeaders(),
248+
(string) $response->getBody()
249+
);
250+
}
251+
247252
$returnType = '\HubSpot\Client\Crm\LineItems\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging';
248253
if ($returnType === '\SplFileObject') {
249254
$content = $response->getBody(); //stream goes to serializer
@@ -298,6 +303,8 @@ public function doSearchWithHttpInfo($public_object_search_request, string $cont
298303
/**
299304
* Operation doSearchAsync
300305
*
306+
* Search for line items
307+
*
301308
* @param \HubSpot\Client\Crm\LineItems\Model\PublicObjectSearchRequest $public_object_search_request (required)
302309
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['doSearch'] to see the possible values for this operation
303310
*
@@ -317,6 +324,8 @@ function ($response) {
317324
/**
318325
* Operation doSearchAsyncWithHttpInfo
319326
*
327+
* Search for line items
328+
*
320329
* @param \HubSpot\Client\Crm\LineItems\Model\PublicObjectSearchRequest $public_object_search_request (required)
321330
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['doSearch'] to see the possible values for this operation
322331
*

codegen/Crm/LineItems/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/LineItems/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/LineItems/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/LineItems/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/LineItems/Model/AssociationSpec.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
/**
@@ -262,10 +262,10 @@ public function getAssociationCategoryAllowableValues()
262262
/**
263263
* Constructor
264264
*
265-
* @param mixed[] $data Associated array of property values
265+
* @param mixed[]|null $data Associated array of property values
266266
* initializing the model
267267
*/
268-
public function __construct(array $data = null)
268+
public function __construct(?array $data = null)
269269
{
270270
$this->setIfExists('association_category', $data ?? [], null);
271271
$this->setIfExists('association_type_id', $data ?? [], null);

codegen/Crm/LineItems/Model/BatchInputSimplePublicObjectBatchInput.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/LineItems/Model/BatchInputSimplePublicObjectInputForCreate.php renamed to codegen/Crm/LineItems/Model/BatchInputSimplePublicObjectBatchInputForCreate.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* BatchInputSimplePublicObjectInputForCreate
3+
* BatchInputSimplePublicObjectBatchInputForCreate
44
*
55
* PHP version 7.4
66
*
@@ -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
/**
@@ -32,15 +32,15 @@
3232
use \HubSpot\Client\Crm\LineItems\ObjectSerializer;
3333

3434
/**
35-
* BatchInputSimplePublicObjectInputForCreate Class Doc Comment
35+
* BatchInputSimplePublicObjectBatchInputForCreate Class Doc Comment
3636
*
3737
* @category Class
3838
* @package HubSpot\Client\Crm\LineItems
3939
* @author OpenAPI Generator team
4040
* @link https://openapi-generator.tech
4141
* @implements \ArrayAccess<string, mixed>
4242
*/
43-
class BatchInputSimplePublicObjectInputForCreate implements ModelInterface, ArrayAccess, \JsonSerializable
43+
class BatchInputSimplePublicObjectBatchInputForCreate implements ModelInterface, ArrayAccess, \JsonSerializable
4444
{
4545
public const DISCRIMINATOR = null;
4646

@@ -49,15 +49,15 @@ class BatchInputSimplePublicObjectInputForCreate implements ModelInterface, Arra
4949
*
5050
* @var string
5151
*/
52-
protected static $openAPIModelName = 'BatchInputSimplePublicObjectInputForCreate';
52+
protected static $openAPIModelName = 'BatchInputSimplePublicObjectBatchInputForCreate';
5353

5454
/**
5555
* Array of property to type mappings. Used for (de)serialization
5656
*
5757
* @var string[]
5858
*/
5959
protected static $openAPITypes = [
60-
'inputs' => '\HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInputForCreate[]'
60+
'inputs' => '\HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectBatchInputForCreate[]'
6161
];
6262

6363
/**
@@ -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
}
@@ -295,7 +295,7 @@ public function valid()
295295
/**
296296
* Gets inputs
297297
*
298-
* @return \HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInputForCreate[]
298+
* @return \HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectBatchInputForCreate[]
299299
*/
300300
public function getInputs()
301301
{
@@ -305,7 +305,7 @@ public function getInputs()
305305
/**
306306
* Sets inputs
307307
*
308-
* @param \HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectInputForCreate[] $inputs inputs
308+
* @param \HubSpot\Client\Crm\LineItems\Model\SimplePublicObjectBatchInputForCreate[] $inputs inputs
309309
*
310310
* @return self
311311
*/

0 commit comments

Comments
 (0)