Skip to content

Commit 727c483

Browse files
Merge pull request #455 from HubSpot/feature/codegenConcersations
Codegen: Conversations Visotor Identification
2 parents 3e6b0dc + 0bae387 commit 727c483

10 files changed

Lines changed: 152 additions & 73 deletions

codegen/Conversations/VisitorIdentification/Api/GenerateApi.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
*/
1111

1212
/**
13-
* Visitor Identification
13+
* Conversations Visitor Identification
1414
*
1515
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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 GenerateApi
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
}
@@ -178,18 +178,6 @@ public function generateTokenWithHttpInfo($identification_token_generation_reque
178178

179179
$statusCode = $response->getStatusCode();
180180

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-
}
193181

194182
switch($statusCode) {
195183
case 200:
@@ -248,6 +236,19 @@ public function generateTokenWithHttpInfo($identification_token_generation_reque
248236
];
249237
}
250238

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+
251252
$returnType = '\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse';
252253
if ($returnType === '\SplFileObject') {
253254
$content = $response->getBody(); //stream goes to serializer

codegen/Conversations/VisitorIdentification/ApiException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
*/
1111

1212
/**
13-
* Visitor Identification
13+
* Conversations Visitor Identification
1414
*
1515
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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/Conversations/VisitorIdentification/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
*/
1111

1212
/**
13-
* Visitor Identification
13+
* Conversations Visitor Identification
1414
*
1515
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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/Conversations/VisitorIdentification/HeaderSelector.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
*/
1111

1212
/**
13-
* Visitor Identification
13+
* Conversations Visitor Identification
1414
*
1515
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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/Conversations/VisitorIdentification/Model/Error.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
*/
1212

1313
/**
14-
* Visitor Identification
14+
* Conversations Visitor Identification
1515
*
1616
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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
/**
@@ -275,10 +275,10 @@ public function getModelName()
275275
/**
276276
* Constructor
277277
*
278-
* @param mixed[] $data Associated array of property values
278+
* @param mixed[]|null $data Associated array of property values
279279
* initializing the model
280280
*/
281-
public function __construct(array $data = null)
281+
public function __construct(?array $data = null)
282282
{
283283
$this->setIfExists('sub_category', $data ?? [], null);
284284
$this->setIfExists('context', $data ?? [], null);

codegen/Conversations/VisitorIdentification/Model/ErrorDetail.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
*/
1212

1313
/**
14-
* Visitor Identification
14+
* Conversations Visitor Identification
1515
*
1616
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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
/**
@@ -263,10 +263,10 @@ public function getModelName()
263263
/**
264264
* Constructor
265265
*
266-
* @param mixed[] $data Associated array of property values
266+
* @param mixed[]|null $data Associated array of property values
267267
* initializing the model
268268
*/
269-
public function __construct(array $data = null)
269+
public function __construct(?array $data = null)
270270
{
271271
$this->setIfExists('sub_category', $data ?? [], null);
272272
$this->setIfExists('code', $data ?? [], null);

codegen/Conversations/VisitorIdentification/Model/IdentificationTokenGenerationRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
*/
1212

1313
/**
14-
* Visitor Identification
14+
* Conversations Visitor Identification
1515
*
1616
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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
/**
@@ -252,10 +252,10 @@ public function getModelName()
252252
/**
253253
* Constructor
254254
*
255-
* @param mixed[] $data Associated array of property values
255+
* @param mixed[]|null $data Associated array of property values
256256
* initializing the model
257257
*/
258-
public function __construct(array $data = null)
258+
public function __construct(?array $data = null)
259259
{
260260
$this->setIfExists('first_name', $data ?? [], null);
261261
$this->setIfExists('last_name', $data ?? [], null);

codegen/Conversations/VisitorIdentification/Model/IdentificationTokenResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
*/
1212

1313
/**
14-
* Visitor Identification
14+
* Conversations Visitor Identification
1515
*
1616
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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
/**
@@ -240,10 +240,10 @@ public function getModelName()
240240
/**
241241
* Constructor
242242
*
243-
* @param mixed[] $data Associated array of property values
243+
* @param mixed[]|null $data Associated array of property values
244244
* initializing the model
245245
*/
246-
public function __construct(array $data = null)
246+
public function __construct(?array $data = null)
247247
{
248248
$this->setIfExists('token', $data ?? [], null);
249249
}

codegen/Conversations/VisitorIdentification/Model/ModelInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
*/
1212

1313
/**
14-
* Visitor Identification
14+
* Conversations Visitor Identification
1515
*
1616
* The Visitor Identification API allows you to pass identification information to the HubSpot chat widget for otherwise unknown visitors that were verified by your own authentication system.
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
/**

0 commit comments

Comments
 (0)