Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 82 additions & 89 deletions codegen/Conversations/VisitorIdentification/Api/GenerateApi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* GenerateApi
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Conversations\VisitorIdentification
Expand All @@ -12,11 +12,11 @@
/**
* Conversations Visitor Identification
*
* 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.
* Basepom for all HubSpot Projects
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
* Generator version: 7.19.0
*/

/**
Expand All @@ -34,8 +34,11 @@
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use HubSpot\Client\Conversations\VisitorIdentification\ApiException;
use HubSpot\Client\Conversations\VisitorIdentification\Configuration;
use HubSpot\Client\Conversations\VisitorIdentification\FormDataProcessor;
use HubSpot\Client\Conversations\VisitorIdentification\HeaderSelector;
use HubSpot\Client\Conversations\VisitorIdentification\ObjectSerializer;

Expand Down Expand Up @@ -125,7 +128,7 @@ public function getConfig()
/**
* Operation generateToken
*
* Generate a token
* Generate an identification token for a verified website visitor.
*
* @param \HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenGenerationRequest $identification_token_generation_request identification_token_generation_request (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateToken'] to see the possible values for this operation
Expand All @@ -143,7 +146,7 @@ public function generateToken($identification_token_generation_request, string $
/**
* Operation generateTokenWithHttpInfo
*
* Generate a token
* Generate an identification token for a verified website visitor.
*
* @param \HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenGenerationRequest $identification_token_generation_request (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateToken'] to see the possible values for this operation
Expand Down Expand Up @@ -181,61 +184,21 @@ public function generateTokenWithHttpInfo($identification_token_generation_reque

switch($statusCode) {
case 200:
if ('\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}

return [
ObjectSerializer::deserialize($content, '\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse',
$request,
$response,
);
default:
if ('\HubSpot\Client\Conversations\VisitorIdentification\Model\Error' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\HubSpot\Client\Conversations\VisitorIdentification\Model\Error' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}

return [
ObjectSerializer::deserialize($content, '\HubSpot\Client\Conversations\VisitorIdentification\Model\Error', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\HubSpot\Client\Conversations\VisitorIdentification\Model\Error',
$request,
$response,
);
}



if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
Expand All @@ -249,34 +212,11 @@ public function generateTokenWithHttpInfo($identification_token_generation_reque
);
}

$returnType = '\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];

return $this->handleResponseWithDataType(
'\HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
Expand All @@ -286,24 +226,26 @@ public function generateTokenWithHttpInfo($identification_token_generation_reque
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Conversations\VisitorIdentification\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}


throw $e;
}
}

/**
* Operation generateTokenAsync
*
* Generate a token
* Generate an identification token for a verified website visitor.
*
* @param \HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenGenerationRequest $identification_token_generation_request (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateToken'] to see the possible values for this operation
Expand All @@ -324,7 +266,7 @@ function ($response) {
/**
* Operation generateTokenAsyncWithHttpInfo
*
* Generate a token
* Generate an identification token for a verified website visitor.
*
* @param \HubSpot\Client\Conversations\VisitorIdentification\Model\IdentificationTokenGenerationRequest $identification_token_generation_request (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateToken'] to see the possible values for this operation
Expand Down Expand Up @@ -484,6 +426,57 @@ protected function createHttpClientOption()
}
}

if ($this->config->getCertFile()) {
$options[RequestOptions::CERT] = $this->config->getCertFile();
}

if ($this->config->getKeyFile()) {
$options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
}

return $options;
}

private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($dataType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$response->getStatusCode(),
$response->getHeaders(),
$content
);
}
}
}

return [
ObjectSerializer::deserialize($content, $dataType, []),
$response->getStatusCode(),
$response->getHeaders()
];
}

private function responseWithinRangeCode(
string $rangeCode,
int $statusCode
): bool {
$left = (int) ($rangeCode[0].'00');
$right = (int) ($rangeCode[0].'99');

return $statusCode >= $left && $statusCode <= $right;
}
}
6 changes: 3 additions & 3 deletions codegen/Conversations/VisitorIdentification/ApiException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* ApiException
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Conversations\VisitorIdentification
Expand All @@ -12,11 +12,11 @@
/**
* Conversations Visitor Identification
*
* 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.
* Basepom for all HubSpot Projects
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
* Generator version: 7.19.0
*/

/**
Expand Down
65 changes: 61 additions & 4 deletions codegen/Conversations/VisitorIdentification/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Configuration
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Conversations\VisitorIdentification
Expand All @@ -12,11 +12,11 @@
/**
* Conversations Visitor Identification
*
* 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.
* Basepom for all HubSpot Projects
*
* The version of the OpenAPI document: v3
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
* Generator version: 7.19.0
*/

/**
Expand All @@ -29,7 +29,7 @@

/**
* Configuration Class Doc Comment
* PHP version 7.4
* PHP version 8.1
*
* @category Class
* @package HubSpot\Client\Conversations\VisitorIdentification
Expand Down Expand Up @@ -123,6 +123,20 @@ class Configuration
*/
protected $tempFolderPath;

/**
* Path to a certificate file, for mTLS
*
* @var string
*/
protected $certFile;

/**
* Path to a key file, for mTLS
*
* @var string
*/
protected $keyFile;

/**
* Constructor
*/
Expand Down Expand Up @@ -396,6 +410,49 @@ public function getTempFolderPath()
return $this->tempFolderPath;
}

/**
* Sets the certificate file path, for mTLS
*
* @return $this
*/
public function setCertFile($certFile)
{
$this->certFile = $certFile;
return $this;
}

/**
* Gets the certificate file path, for mTLS
*
* @return string Certificate file path
*/
public function getCertFile()
{
return $this->certFile;
}

/**
* Sets the certificate key path, for mTLS
*
* @return $this
*/
public function setKeyFile($keyFile)
{
$this->keyFile = $keyFile;
return $this;
}

/**
* Gets the certificate key path, for mTLS
*
* @return string Certificate key path
*/
public function getKeyFile()
{
return $this->keyFile;
}


/**
* Gets the default configuration instance
*
Expand Down
Loading