Skip to content

Commit 37dbd86

Browse files
Merge pull request #468 from HubSpot/feature/crmCodegen
Codegen: CRM Companies, Contacts and Deals
2 parents 988f66d + 0a935b1 commit 37dbd86

140 files changed

Lines changed: 4580 additions & 3357 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/Companies/Api/BasicApi.php

Lines changed: 492 additions & 151 deletions
Large diffs are not rendered by default.

codegen/Crm/Companies/Api/BatchApi.php

Lines changed: 95 additions & 103 deletions
Large diffs are not rendered by default.

codegen/Crm/Companies/Api/MergeApi.php

Lines changed: 0 additions & 488 deletions
This file was deleted.

codegen/Crm/Companies/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 companies
129+
*
128130
* @param \HubSpot\Client\Crm\Companies\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 companies
147+
*
144148
* @param \HubSpot\Client\Crm\Companies\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\Companies\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 companies
307+
*
301308
* @param \HubSpot\Client\Crm\Companies\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 companies
328+
*
320329
* @param \HubSpot\Client\Crm\Companies\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/Companies/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/Companies/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/Companies/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/Companies/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/Companies/Model/AssociationSpec.php

Lines changed: 13 additions & 7 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);
@@ -298,6 +298,9 @@ public function listInvalidProperties()
298298
{
299299
$invalidProperties = [];
300300

301+
if ($this->container['association_category'] === null) {
302+
$invalidProperties[] = "'association_category' can't be null";
303+
}
301304
$allowedValues = $this->getAssociationCategoryAllowableValues();
302305
if (!is_null($this->container['association_category']) && !in_array($this->container['association_category'], $allowedValues, true)) {
303306
$invalidProperties[] = sprintf(
@@ -307,6 +310,9 @@ public function listInvalidProperties()
307310
);
308311
}
309312

313+
if ($this->container['association_type_id'] === null) {
314+
$invalidProperties[] = "'association_type_id' can't be null";
315+
}
310316
return $invalidProperties;
311317
}
312318

@@ -325,7 +331,7 @@ public function valid()
325331
/**
326332
* Gets association_category
327333
*
328-
* @return string|null
334+
* @return string
329335
*/
330336
public function getAssociationCategory()
331337
{
@@ -335,7 +341,7 @@ public function getAssociationCategory()
335341
/**
336342
* Sets association_category
337343
*
338-
* @param string|null $association_category association_category
344+
* @param string $association_category For [labeled associations](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4#associate-records-with-a-label), the category of the association.
339345
*
340346
* @return self
341347
*/
@@ -362,7 +368,7 @@ public function setAssociationCategory($association_category)
362368
/**
363369
* Gets association_type_id
364370
*
365-
* @return int|null
371+
* @return int
366372
*/
367373
public function getAssociationTypeId()
368374
{
@@ -372,7 +378,7 @@ public function getAssociationTypeId()
372378
/**
373379
* Sets association_type_id
374380
*
375-
* @param int|null $association_type_id association_type_id
381+
* @param int $association_type_id The [association type ID](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4#association-type-id-values) (e.g., `4` for contact-to-company associations).
376382
*
377383
* @return self
378384
*/

codegen/Crm/Companies/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
}

0 commit comments

Comments
 (0)