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
46 changes: 23 additions & 23 deletions codegen/Crm/Objects/Leads/Api/BasicApi.php

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions codegen/Crm/Objects/Leads/Api/BatchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class BatchApi
'update' => [
'application/json',
],
'upsert' => [
'application/json',
],
];

/**
Expand Down Expand Up @@ -1233,6 +1236,291 @@ public function updateRequest($batch_input_simple_public_object_batch_input, str
);
}

/**
* Operation upsert
*
* Create or update a batch of leads by unique property values
*
* @param \HubSpot\Client\Crm\Objects\Leads\Model\BatchInputSimplePublicObjectBatchInputUpsert $batch_input_simple_public_object_batch_input_upsert batch_input_simple_public_object_batch_input_upsert (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upsert'] to see the possible values for this operation
*
* @throws \HubSpot\Client\Crm\Objects\Leads\ApiException on non-2xx response or if the response body is not in the expected format
* @throws \InvalidArgumentException
* @return \HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject|\HubSpot\Client\Crm\Objects\Leads\Model\Error
*/
public function upsert($batch_input_simple_public_object_batch_input_upsert, string $contentType = self::contentTypes['upsert'][0])
{
list($response) = $this->upsertWithHttpInfo($batch_input_simple_public_object_batch_input_upsert, $contentType);
return $response;
}

/**
* Operation upsertWithHttpInfo
*
* Create or update a batch of leads by unique property values
*
* @param \HubSpot\Client\Crm\Objects\Leads\Model\BatchInputSimplePublicObjectBatchInputUpsert $batch_input_simple_public_object_batch_input_upsert (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upsert'] to see the possible values for this operation
*
* @throws \HubSpot\Client\Crm\Objects\Leads\ApiException on non-2xx response or if the response body is not in the expected format
* @throws \InvalidArgumentException
* @return array of \HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject|\HubSpot\Client\Crm\Objects\Leads\Model\Error, HTTP status code, HTTP response headers (array of strings)
*/
public function upsertWithHttpInfo($batch_input_simple_public_object_batch_input_upsert, string $contentType = self::contentTypes['upsert'][0])
{
$request = $this->upsertRequest($batch_input_simple_public_object_batch_input_upsert, $contentType);

try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}

$statusCode = $response->getStatusCode();


switch($statusCode) {
case 200:
return $this->handleResponseWithDataType(
'\HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject',
$request,
$response,
);
default:
return $this->handleResponseWithDataType(
'\HubSpot\Client\Crm\Objects\Leads\Model\Error',
$request,
$response,
);
}



if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}

return $this->handleResponseWithDataType(
'\HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
throw $e;
default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\HubSpot\Client\Crm\Objects\Leads\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
throw $e;
}


throw $e;
}
}

/**
* Operation upsertAsync
*
* Create or update a batch of leads by unique property values
*
* @param \HubSpot\Client\Crm\Objects\Leads\Model\BatchInputSimplePublicObjectBatchInputUpsert $batch_input_simple_public_object_batch_input_upsert (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upsert'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function upsertAsync($batch_input_simple_public_object_batch_input_upsert, string $contentType = self::contentTypes['upsert'][0])
{
return $this->upsertAsyncWithHttpInfo($batch_input_simple_public_object_batch_input_upsert, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}

/**
* Operation upsertAsyncWithHttpInfo
*
* Create or update a batch of leads by unique property values
*
* @param \HubSpot\Client\Crm\Objects\Leads\Model\BatchInputSimplePublicObjectBatchInputUpsert $batch_input_simple_public_object_batch_input_upsert (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upsert'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function upsertAsyncWithHttpInfo($batch_input_simple_public_object_batch_input_upsert, string $contentType = self::contentTypes['upsert'][0])
{
$returnType = '\HubSpot\Client\Crm\Objects\Leads\Model\BatchResponseSimplePublicUpsertObject';
$request = $this->upsertRequest($batch_input_simple_public_object_batch_input_upsert, $contentType);

return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}

/**
* Create request for operation 'upsert'
*
* @param \HubSpot\Client\Crm\Objects\Leads\Model\BatchInputSimplePublicObjectBatchInputUpsert $batch_input_simple_public_object_batch_input_upsert (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['upsert'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function upsertRequest($batch_input_simple_public_object_batch_input_upsert, string $contentType = self::contentTypes['upsert'][0])
{

// verify the required parameter 'batch_input_simple_public_object_batch_input_upsert' is set
if ($batch_input_simple_public_object_batch_input_upsert === null || (is_array($batch_input_simple_public_object_batch_input_upsert) && count($batch_input_simple_public_object_batch_input_upsert) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $batch_input_simple_public_object_batch_input_upsert when calling upsert'
);
}


$resourcePath = '/crm/v3/objects/leads/batch/upsert';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;





$headers = $this->headerSelector->selectHeaders(
['application/json', '*/*', ],
$contentType,
$multipart
);

// for model (json/xml)
if (isset($batch_input_simple_public_object_batch_input_upsert)) {
if (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the body
$httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($batch_input_simple_public_object_batch_input_upsert));
} else {
$httpBody = $batch_input_simple_public_object_batch_input_upsert;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);

} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}

// this endpoint requires OAuth (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}

/**
* Create http client option
*
Expand Down
2 changes: 2 additions & 0 deletions codegen/Crm/Objects/Leads/Model/AssociationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public function getModelName()
public const ASSOCIATION_CATEGORY_HUBSPOT_DEFINED = 'HUBSPOT_DEFINED';
public const ASSOCIATION_CATEGORY_INTEGRATOR_DEFINED = 'INTEGRATOR_DEFINED';
public const ASSOCIATION_CATEGORY_USER_DEFINED = 'USER_DEFINED';
public const ASSOCIATION_CATEGORY_WORK = 'WORK';

/**
* Gets allowable values of the enum
Expand All @@ -250,6 +251,7 @@ public function getAssociationCategoryAllowableValues()
self::ASSOCIATION_CATEGORY_HUBSPOT_DEFINED,
self::ASSOCIATION_CATEGORY_INTEGRATOR_DEFINED,
self::ASSOCIATION_CATEGORY_USER_DEFINED,
self::ASSOCIATION_CATEGORY_WORK,
];
}

Expand Down
Loading