From 7dafa89ffaa25fec548124bcad98f0373cd13ee4 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 10 Apr 2025 17:46:29 +0300 Subject: [PATCH 1/2] Codegen: CMS Blogs Posts --- .../Api/{BlogPostsApi.php => BasicApi.php} | 5464 ++++------------- codegen/Cms/Blogs/BlogPosts/Api/BatchApi.php | 1562 +++++ .../Blogs/BlogPosts/Api/MultiLanguageApi.php | 1460 +++++ .../Cms/Blogs/BlogPosts/Model/BlogPost.php | 36 +- 4 files changed, 4401 insertions(+), 4121 deletions(-) rename codegen/Cms/Blogs/BlogPosts/Api/{BlogPostsApi.php => BasicApi.php} (61%) create mode 100644 codegen/Cms/Blogs/BlogPosts/Api/BatchApi.php create mode 100644 codegen/Cms/Blogs/BlogPosts/Api/MultiLanguageApi.php diff --git a/codegen/Cms/Blogs/BlogPosts/Api/BlogPostsApi.php b/codegen/Cms/Blogs/BlogPosts/Api/BasicApi.php similarity index 61% rename from codegen/Cms/Blogs/BlogPosts/Api/BlogPostsApi.php rename to codegen/Cms/Blogs/BlogPosts/Api/BasicApi.php index fe3b75f74..09f365fa2 100644 --- a/codegen/Cms/Blogs/BlogPosts/Api/BlogPostsApi.php +++ b/codegen/Cms/Blogs/BlogPosts/Api/BasicApi.php @@ -1,6 +1,6 @@ [ 'application/json', ], - 'archiveBatch' => [ - 'application/json', - ], - 'attachToLangGroup' => [ - 'application/json', - ], 'callClone' => [ 'application/json', ], 'create' => [ 'application/json', ], - 'createBatch' => [ - 'application/json', - ], - 'createLangVariation' => [ - 'application/json', - ], - 'detachFromLangGroup' => [ - 'application/json', - ], 'getById' => [ 'application/json', ], @@ -113,9 +98,6 @@ class BlogPostsApi 'pushLive' => [ 'application/json', ], - 'readBatch' => [ - 'application/json', - ], 'resetDraft' => [ 'application/json', ], @@ -128,21 +110,12 @@ class BlogPostsApi 'schedule' => [ 'application/json', ], - 'setLangPrimary' => [ - 'application/json', - ], 'update' => [ 'application/json', ], - 'updateBatch' => [ - 'application/json', - ], 'updateDraft' => [ 'application/json', ], - 'updateLangs' => [ - 'application/json', - ], ]; /** @@ -194,10 +167,10 @@ public function getConfig() /** * Operation archive * - * Delete a Blog Post + * Delete a blog post * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param string $object_id The ID of the blog post to delete. (required) + * @param bool $archived Whether to return only results that have been deleted. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format @@ -212,10 +185,10 @@ public function archive($object_id, $archived = null, string $contentType = self /** * Operation archiveWithHttpInfo * - * Delete a Blog Post + * Delete a blog post * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param string $object_id The ID of the blog post to delete. (required) + * @param bool $archived Whether to return only results that have been deleted. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format @@ -281,10 +254,10 @@ public function archiveWithHttpInfo($object_id, $archived = null, string $conten /** * Operation archiveAsync * - * Delete a Blog Post + * Delete a blog post * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param string $object_id The ID of the blog post to delete. (required) + * @param bool $archived Whether to return only results that have been deleted. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -303,10 +276,10 @@ function ($response) { /** * Operation archiveAsyncWithHttpInfo * - * Delete a Blog Post + * Delete a blog post * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param string $object_id The ID of the blog post to delete. (required) + * @param bool $archived Whether to return only results that have been deleted. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -343,8 +316,8 @@ function ($exception) { /** * Create request for operation 'archive' * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param string $object_id The ID of the blog post to delete. (required) + * @param bool $archived Whether to return only results that have been deleted. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -448,37 +421,38 @@ public function archiveRequest($object_id, $archived = null, string $contentType } /** - * Operation archiveBatch + * Operation callClone * - * Delete a batch of Blog Posts + * Clone a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return void + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function archiveBatch($batch_input_string, string $contentType = self::contentTypes['archiveBatch'][0]) + public function callClone($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) { - $this->archiveBatchWithHttpInfo($batch_input_string, $contentType); + list($response) = $this->callCloneWithHttpInfo($content_clone_request_v_next, $contentType); + return $response; } /** - * Operation archiveBatchWithHttpInfo + * Operation callCloneWithHttpInfo * - * Delete a batch of Blog Posts + * Clone a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function archiveBatchWithHttpInfo($batch_input_string, string $contentType = self::contentTypes['archiveBatch'][0]) + public function callCloneWithHttpInfo($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) { - $request = $this->archiveBatchRequest($batch_input_string, $contentType); + $request = $this->callCloneRequest($content_clone_request_v_next, $contentType); try { $options = $this->createHttpClientOption(); @@ -515,10 +489,101 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp ); } - return [null, $statusCode, $response->getHeaders()]; + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + 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() + ]; } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -533,19 +598,19 @@ public function archiveBatchWithHttpInfo($batch_input_string, string $contentTyp } /** - * Operation archiveBatchAsync + * Operation callCloneAsync * - * Delete a batch of Blog Posts + * Clone a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function archiveBatchAsync($batch_input_string, string $contentType = self::contentTypes['archiveBatch'][0]) + public function callCloneAsync($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) { - return $this->archiveBatchAsyncWithHttpInfo($batch_input_string, $contentType) + return $this->callCloneAsyncWithHttpInfo($content_clone_request_v_next, $contentType) ->then( function ($response) { return $response[0]; @@ -554,26 +619,39 @@ function ($response) { } /** - * Operation archiveBatchAsyncWithHttpInfo + * Operation callCloneAsyncWithHttpInfo * - * Delete a batch of Blog Posts + * Clone a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function archiveBatchAsyncWithHttpInfo($batch_input_string, string $contentType = self::contentTypes['archiveBatch'][0]) + public function callCloneAsyncWithHttpInfo($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) { - $returnType = ''; - $request = $this->archiveBatchRequest($batch_input_string, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $request = $this->callCloneRequest($content_clone_request_v_next, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; + 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(); @@ -593,26 +671,26 @@ function ($exception) { } /** - * Create request for operation 'archiveBatch' + * Create request for operation 'callClone' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archiveBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function archiveBatchRequest($batch_input_string, string $contentType = self::contentTypes['archiveBatch'][0]) + public function callCloneRequest($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) { - // verify the required parameter 'batch_input_string' is set - if ($batch_input_string === null || (is_array($batch_input_string) && count($batch_input_string) === 0)) { + // verify the required parameter 'content_clone_request_v_next' is set + if ($content_clone_request_v_next === null || (is_array($content_clone_request_v_next) && count($content_clone_request_v_next) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $batch_input_string when calling archiveBatch' + 'Missing the required parameter $content_clone_request_v_next when calling callClone' ); } - $resourcePath = '/cms/v3/blogs/posts/batch/archive'; + $resourcePath = '/cms/v3/blogs/posts/clone'; $formParams = []; $queryParams = []; $headerParams = []; @@ -624,18 +702,18 @@ public function archiveBatchRequest($batch_input_string, string $contentType = s $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', '*/*', ], $contentType, $multipart ); // for model (json/xml) - if (isset($batch_input_string)) { + if (isset($content_clone_request_v_next)) { 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_string)); + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($content_clone_request_v_next)); } else { - $httpBody = $batch_input_string; + $httpBody = $content_clone_request_v_next; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -688,37 +766,38 @@ public function archiveBatchRequest($batch_input_string, string $contentType = s } /** - * Operation attachToLangGroup + * Operation create * - * Attach a Blog Post to a multi-language group + * Create a new post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return void + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function attachToLangGroup($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + public function create($blog_post, string $contentType = self::contentTypes['create'][0]) { - $this->attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_next, $contentType); + list($response) = $this->createWithHttpInfo($blog_post, $contentType); + return $response; } /** - * Operation attachToLangGroupWithHttpInfo + * Operation createWithHttpInfo * - * Attach a Blog Post to a multi-language group + * Create a new post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + public function createWithHttpInfo($blog_post, string $contentType = self::contentTypes['create'][0]) { - $request = $this->attachToLangGroupRequest($attach_to_lang_primary_request_v_next, $contentType); + $request = $this->createRequest($blog_post, $contentType); try { $options = $this->createHttpClientOption(); @@ -755,38 +834,129 @@ public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_ ); } - return [null, $statusCode, $response->getHeaders()]; + switch($statusCode) { + case 201: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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 + ); + } + } + } - } catch (ApiException $e) { - switch ($e->getCode()) { + return [ + ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; } - throw $e; - } - } - /** - * Operation attachToLangGroupAsync - * - * Attach a Blog Post to a multi-language group - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function attachToLangGroupAsync($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) - { - return $this->attachToLangGroupAsyncWithHttpInfo($attach_to_lang_primary_request_v_next, $contentType) - ->then( + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createAsync + * + * Create a new post + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createAsync($blog_post, string $contentType = self::contentTypes['create'][0]) + { + return $this->createAsyncWithHttpInfo($blog_post, $contentType) + ->then( function ($response) { return $response[0]; } @@ -794,26 +964,39 @@ function ($response) { } /** - * Operation attachToLangGroupAsyncWithHttpInfo + * Operation createAsyncWithHttpInfo * - * Attach a Blog Post to a multi-language group + * Create a new post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function attachToLangGroupAsyncWithHttpInfo($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + public function createAsyncWithHttpInfo($blog_post, string $contentType = self::contentTypes['create'][0]) { - $returnType = ''; - $request = $this->attachToLangGroupRequest($attach_to_lang_primary_request_v_next, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $request = $this->createRequest($blog_post, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; + 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(); @@ -833,26 +1016,26 @@ function ($exception) { } /** - * Create request for operation 'attachToLangGroup' + * Create request for operation 'create' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function attachToLangGroupRequest($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + public function createRequest($blog_post, string $contentType = self::contentTypes['create'][0]) { - // verify the required parameter 'attach_to_lang_primary_request_v_next' is set - if ($attach_to_lang_primary_request_v_next === null || (is_array($attach_to_lang_primary_request_v_next) && count($attach_to_lang_primary_request_v_next) === 0)) { + // verify the required parameter 'blog_post' is set + if ($blog_post === null || (is_array($blog_post) && count($blog_post) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $attach_to_lang_primary_request_v_next when calling attachToLangGroup' + 'Missing the required parameter $blog_post when calling create' ); } - $resourcePath = '/cms/v3/blogs/posts/multi-language/attach-to-lang-group'; + $resourcePath = '/cms/v3/blogs/posts'; $formParams = []; $queryParams = []; $headerParams = []; @@ -864,18 +1047,18 @@ public function attachToLangGroupRequest($attach_to_lang_primary_request_v_next, $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', '*/*', ], $contentType, $multipart ); // for model (json/xml) - if (isset($attach_to_lang_primary_request_v_next)) { + if (isset($blog_post)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($attach_to_lang_primary_request_v_next)); + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post)); } else { - $httpBody = $attach_to_lang_primary_request_v_next; + $httpBody = $blog_post; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -928,38 +1111,42 @@ public function attachToLangGroupRequest($attach_to_lang_primary_request_v_next, } /** - * Operation callClone + * Operation getById * - * Clone a Blog Post + * Retrieve a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve. (required) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property Specific properties to return. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function callClone($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) + public function getById($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) { - list($response) = $this->callCloneWithHttpInfo($content_clone_request_v_next, $contentType); + list($response) = $this->getByIdWithHttpInfo($object_id, $archived, $property, $contentType); return $response; } /** - * Operation callCloneWithHttpInfo + * Operation getByIdWithHttpInfo * - * Clone a Blog Post + * Retrieve a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve. (required) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property Specific properties to return. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function callCloneWithHttpInfo($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) + public function getByIdWithHttpInfo($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) { - $request = $this->callCloneRequest($content_clone_request_v_next, $contentType); + $request = $this->getByIdRequest($object_id, $archived, $property, $contentType); try { $options = $this->createHttpClientOption(); @@ -1105,19 +1292,21 @@ public function callCloneWithHttpInfo($content_clone_request_v_next, string $con } /** - * Operation callCloneAsync + * Operation getByIdAsync * - * Clone a Blog Post + * Retrieve a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve. (required) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property Specific properties to return. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function callCloneAsync($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) + public function getByIdAsync($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) { - return $this->callCloneAsyncWithHttpInfo($content_clone_request_v_next, $contentType) + return $this->getByIdAsyncWithHttpInfo($object_id, $archived, $property, $contentType) ->then( function ($response) { return $response[0]; @@ -1126,20 +1315,22 @@ function ($response) { } /** - * Operation callCloneAsyncWithHttpInfo + * Operation getByIdAsyncWithHttpInfo * - * Clone a Blog Post + * Retrieve a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve. (required) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property Specific properties to return. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function callCloneAsyncWithHttpInfo($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) + public function getByIdAsyncWithHttpInfo($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) { $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->callCloneRequest($content_clone_request_v_next, $contentType); + $request = $this->getByIdRequest($object_id, $archived, $property, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1178,34 +1369,64 @@ function ($exception) { } /** - * Create request for operation 'callClone' + * Create request for operation 'getById' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentCloneRequestVNext $content_clone_request_v_next The JSON representation of the ContentCloneRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callClone'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve. (required) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property Specific properties to return. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function callCloneRequest($content_clone_request_v_next, string $contentType = self::contentTypes['callClone'][0]) + public function getByIdRequest($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) { - // verify the required parameter 'content_clone_request_v_next' is set - if ($content_clone_request_v_next === null || (is_array($content_clone_request_v_next) && count($content_clone_request_v_next) === 0)) { + // verify the required parameter 'object_id' is set + if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $content_clone_request_v_next when calling callClone' + 'Missing the required parameter $object_id when calling getById' ); } - $resourcePath = '/cms/v3/blogs/posts/clone'; + + + $resourcePath = '/cms/v3/blogs/posts/{objectId}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $property, + 'property', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // path params + if ($object_id !== null) { + $resourcePath = str_replace( + '{' . 'objectId' . '}', + ObjectSerializer::toPathValue($object_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -1215,14 +1436,7 @@ public function callCloneRequest($content_clone_request_v_next, string $contentT ); // for model (json/xml) - if (isset($content_clone_request_v_next)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($content_clone_request_v_next)); - } else { - $httpBody = $content_clone_request_v_next; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -1265,7 +1479,7 @@ public function callCloneRequest($content_clone_request_v_next, string $contentT $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -1273,38 +1487,38 @@ public function callCloneRequest($content_clone_request_v_next, string $contentT } /** - * Operation create + * Operation getDraftById * - * Create a new Blog Post + * Retrieve the full draft version of the Blog Post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve the draft of. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function create($blog_post, string $contentType = self::contentTypes['create'][0]) + public function getDraftById($object_id, string $contentType = self::contentTypes['getDraftById'][0]) { - list($response) = $this->createWithHttpInfo($blog_post, $contentType); + list($response) = $this->getDraftByIdWithHttpInfo($object_id, $contentType); return $response; } /** - * Operation createWithHttpInfo + * Operation getDraftByIdWithHttpInfo * - * Create a new Blog Post + * Retrieve the full draft version of the Blog Post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve the draft of. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function createWithHttpInfo($blog_post, string $contentType = self::contentTypes['create'][0]) + public function getDraftByIdWithHttpInfo($object_id, string $contentType = self::contentTypes['getDraftById'][0]) { - $request = $this->createRequest($blog_post, $contentType); + $request = $this->getDraftByIdRequest($object_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -1342,7 +1556,7 @@ public function createWithHttpInfo($blog_post, string $contentType = self::conte } switch($statusCode) { - case 201: + case 200: if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1428,7 +1642,7 @@ public function createWithHttpInfo($blog_post, string $contentType = self::conte } catch (ApiException $e) { switch ($e->getCode()) { - case 201: + case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', @@ -1450,19 +1664,19 @@ public function createWithHttpInfo($blog_post, string $contentType = self::conte } /** - * Operation createAsync + * Operation getDraftByIdAsync * - * Create a new Blog Post + * Retrieve the full draft version of the Blog Post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve the draft of. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createAsync($blog_post, string $contentType = self::contentTypes['create'][0]) + public function getDraftByIdAsync($object_id, string $contentType = self::contentTypes['getDraftById'][0]) { - return $this->createAsyncWithHttpInfo($blog_post, $contentType) + return $this->getDraftByIdAsyncWithHttpInfo($object_id, $contentType) ->then( function ($response) { return $response[0]; @@ -1471,20 +1685,20 @@ function ($response) { } /** - * Operation createAsyncWithHttpInfo + * Operation getDraftByIdAsyncWithHttpInfo * - * Create a new Blog Post + * Retrieve the full draft version of the Blog Post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve the draft of. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createAsyncWithHttpInfo($blog_post, string $contentType = self::contentTypes['create'][0]) + public function getDraftByIdAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['getDraftById'][0]) { $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->createRequest($blog_post, $contentType); + $request = $this->getDraftByIdRequest($object_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1523,26 +1737,26 @@ function ($exception) { } /** - * Create request for operation 'create' + * Create request for operation 'getDraftById' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of a new Blog Post. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve the draft of. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createRequest($blog_post, string $contentType = self::contentTypes['create'][0]) + public function getDraftByIdRequest($object_id, string $contentType = self::contentTypes['getDraftById'][0]) { - // verify the required parameter 'blog_post' is set - if ($blog_post === null || (is_array($blog_post) && count($blog_post) === 0)) { + // verify the required parameter 'object_id' is set + if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $blog_post when calling create' + 'Missing the required parameter $object_id when calling getDraftById' ); } - $resourcePath = '/cms/v3/blogs/posts'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft'; $formParams = []; $queryParams = []; $headerParams = []; @@ -1551,23 +1765,24 @@ public function createRequest($blog_post, string $contentType = self::contentTyp + // path params + if ($object_id !== null) { + $resourcePath = str_replace( + '{' . 'objectId' . '}', + ObjectSerializer::toPathValue($object_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - // for model (json/xml) - if (isset($blog_post)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post)); - } else { - $httpBody = $blog_post; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -1610,7 +1825,7 @@ public function createRequest($blog_post, string $contentType = self::contentTyp $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -1618,38 +1833,58 @@ public function createRequest($blog_post, string $contentType = self::contentTyp } /** - * Operation createBatch + * Operation getPage * - * Create a batch of Blog Posts + * Get all posts * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation + * @param \DateTime $created_at Only return blog posts created at exactly the specified time. (optional) + * @param \DateTime $created_after Only return blog posts created after the specified time. (optional) + * @param \DateTime $created_before Only return blog posts created before the specified time. (optional) + * @param \DateTime $updated_at Only return blog posts last updated at exactly the specified time. (optional) + * @param \DateTime $updated_after Only return blog posts last updated after the specified time. (optional) + * @param \DateTime $updated_before Only return blog posts last updated before the specified time. (optional) + * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `createdAt` (default), `name`, `updatedAt`, `createdBy`, `updatedBy`. (optional) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to return. Default is 20. (optional) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property property (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function createBatch($batch_input_blog_post, string $contentType = self::contentTypes['createBatch'][0]) + public function getPage($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) { - list($response) = $this->createBatchWithHttpInfo($batch_input_blog_post, $contentType); + list($response) = $this->getPageWithHttpInfo($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType); return $response; } /** - * Operation createBatchWithHttpInfo + * Operation getPageWithHttpInfo * - * Create a batch of Blog Posts + * Get all posts * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation + * @param \DateTime $created_at Only return blog posts created at exactly the specified time. (optional) + * @param \DateTime $created_after Only return blog posts created after the specified time. (optional) + * @param \DateTime $created_before Only return blog posts created before the specified time. (optional) + * @param \DateTime $updated_at Only return blog posts last updated at exactly the specified time. (optional) + * @param \DateTime $updated_after Only return blog posts last updated after the specified time. (optional) + * @param \DateTime $updated_before Only return blog posts last updated before the specified time. (optional) + * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `createdAt` (default), `name`, `updatedAt`, `createdBy`, `updatedBy`. (optional) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to return. Default is 20. (optional) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function createBatchWithHttpInfo($batch_input_blog_post, string $contentType = self::contentTypes['createBatch'][0]) + public function getPageWithHttpInfo($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) { - $request = $this->createBatchRequest($batch_input_blog_post, $contentType); + $request = $this->getPageRequest($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType); try { $options = $this->createHttpClientOption(); @@ -1687,39 +1922,12 @@ public function createBatchWithHttpInfo($batch_input_blog_post, string $contentT } switch($statusCode) { - case 201: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 207: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== 'string') { + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging' !== 'string') { try { $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { @@ -1737,7 +1945,7 @@ public function createBatchWithHttpInfo($batch_input_blog_post, string $contentT } return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), + ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -1770,7 +1978,7 @@ public function createBatchWithHttpInfo($batch_input_blog_post, string $contentT ]; } - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -1800,18 +2008,10 @@ public function createBatchWithHttpInfo($batch_input_blog_post, string $contentT } catch (ApiException $e) { switch ($e->getCode()) { - case 201: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 207: + case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -1830,19 +2030,29 @@ public function createBatchWithHttpInfo($batch_input_blog_post, string $contentT } /** - * Operation createBatchAsync + * Operation getPageAsync * - * Create a batch of Blog Posts + * Get all posts * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation + * @param \DateTime $created_at Only return blog posts created at exactly the specified time. (optional) + * @param \DateTime $created_after Only return blog posts created after the specified time. (optional) + * @param \DateTime $created_before Only return blog posts created before the specified time. (optional) + * @param \DateTime $updated_at Only return blog posts last updated at exactly the specified time. (optional) + * @param \DateTime $updated_after Only return blog posts last updated after the specified time. (optional) + * @param \DateTime $updated_before Only return blog posts last updated before the specified time. (optional) + * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `createdAt` (default), `name`, `updatedAt`, `createdBy`, `updatedBy`. (optional) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to return. Default is 20. (optional) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createBatchAsync($batch_input_blog_post, string $contentType = self::contentTypes['createBatch'][0]) + public function getPageAsync($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) { - return $this->createBatchAsyncWithHttpInfo($batch_input_blog_post, $contentType) + return $this->getPageAsyncWithHttpInfo($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType) ->then( function ($response) { return $response[0]; @@ -1851,20 +2061,30 @@ function ($response) { } /** - * Operation createBatchAsyncWithHttpInfo + * Operation getPageAsyncWithHttpInfo * - * Create a batch of Blog Posts + * Get all posts * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation + * @param \DateTime $created_at Only return blog posts created at exactly the specified time. (optional) + * @param \DateTime $created_after Only return blog posts created after the specified time. (optional) + * @param \DateTime $created_before Only return blog posts created before the specified time. (optional) + * @param \DateTime $updated_at Only return blog posts last updated at exactly the specified time. (optional) + * @param \DateTime $updated_after Only return blog posts last updated after the specified time. (optional) + * @param \DateTime $updated_before Only return blog posts last updated before the specified time. (optional) + * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `createdAt` (default), `name`, `updatedAt`, `createdBy`, `updatedBy`. (optional) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to return. Default is 20. (optional) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createBatchAsyncWithHttpInfo($batch_input_blog_post, string $contentType = self::contentTypes['createBatch'][0]) + public function getPageAsyncWithHttpInfo($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; - $request = $this->createBatchRequest($batch_input_blog_post, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging'; + $request = $this->getPageRequest($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1903,32 +2123,145 @@ function ($exception) { } /** - * Create request for operation 'createBatch' + * Create request for operation 'getPage' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createBatch'] to see the possible values for this operation + * @param \DateTime $created_at Only return blog posts created at exactly the specified time. (optional) + * @param \DateTime $created_after Only return blog posts created after the specified time. (optional) + * @param \DateTime $created_before Only return blog posts created before the specified time. (optional) + * @param \DateTime $updated_at Only return blog posts last updated at exactly the specified time. (optional) + * @param \DateTime $updated_after Only return blog posts last updated after the specified time. (optional) + * @param \DateTime $updated_before Only return blog posts last updated before the specified time. (optional) + * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `createdAt` (default), `name`, `updatedAt`, `createdBy`, `updatedBy`. (optional) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to return. Default is 20. (optional) + * @param bool $archived Specifies whether to return deleted blog posts. Defaults to `false`. (optional) + * @param string $property (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createBatchRequest($batch_input_blog_post, string $contentType = self::contentTypes['createBatch'][0]) + public function getPageRequest($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) { - // verify the required parameter 'batch_input_blog_post' is set - if ($batch_input_blog_post === null || (is_array($batch_input_blog_post) && count($batch_input_blog_post) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $batch_input_blog_post when calling createBatch' - ); - } - $resourcePath = '/cms/v3/blogs/posts/batch/create'; + + + + + + + + + + + $resourcePath = '/cms/v3/blogs/posts'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $created_at, + 'createdAt', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $created_after, + 'createdAfter', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $created_before, + 'createdBefore', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at, + 'updatedAt', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_after, + 'updatedAfter', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_before, + 'updatedBefore', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $sort, + 'sort', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $after, + 'after', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $property, + 'property', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); @@ -1940,14 +2273,7 @@ public function createBatchRequest($batch_input_blog_post, string $contentType = ); // for model (json/xml) - if (isset($batch_input_blog_post)) { - 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_blog_post)); - } else { - $httpBody = $batch_input_blog_post; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -1990,7 +2316,7 @@ public function createBatchRequest($batch_input_blog_post, string $contentType = $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -1998,38 +2324,40 @@ public function createBatchRequest($batch_input_blog_post, string $contentType = } /** - * Operation createLangVariation + * Operation getPreviousVersion * - * Create a new language variation + * Retrieve a previous version of a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function createLangVariation($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + public function getPreviousVersion($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) { - list($response) = $this->createLangVariationWithHttpInfo($blog_post_language_clone_request_v_next, $contentType); + list($response) = $this->getPreviousVersionWithHttpInfo($object_id, $revision_id, $contentType); return $response; } /** - * Operation createLangVariationWithHttpInfo + * Operation getPreviousVersionWithHttpInfo * - * Create a new language variation + * Retrieve a previous version of a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function createLangVariationWithHttpInfo($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) { - $request = $this->createLangVariationRequest($blog_post_language_clone_request_v_next, $contentType); + $request = $this->getPreviousVersionRequest($object_id, $revision_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -2068,11 +2396,11 @@ public function createLangVariationWithHttpInfo($blog_post_language_clone_reques switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== 'string') { + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost' !== 'string') { try { $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { @@ -2090,7 +2418,7 @@ public function createLangVariationWithHttpInfo($blog_post_language_clone_reques } return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', []), + ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -2123,7 +2451,7 @@ public function createLangVariationWithHttpInfo($blog_post_language_clone_reques ]; } - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -2156,7 +2484,7 @@ public function createLangVariationWithHttpInfo($blog_post_language_clone_reques case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -2175,19 +2503,20 @@ public function createLangVariationWithHttpInfo($blog_post_language_clone_reques } /** - * Operation createLangVariationAsync + * Operation getPreviousVersionAsync * - * Create a new language variation + * Retrieve a previous version of a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createLangVariationAsync($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + public function getPreviousVersionAsync($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) { - return $this->createLangVariationAsyncWithHttpInfo($blog_post_language_clone_request_v_next, $contentType) + return $this->getPreviousVersionAsyncWithHttpInfo($object_id, $revision_id, $contentType) ->then( function ($response) { return $response[0]; @@ -2196,20 +2525,21 @@ function ($response) { } /** - * Operation createLangVariationAsyncWithHttpInfo + * Operation getPreviousVersionAsyncWithHttpInfo * - * Create a new language variation + * Retrieve a previous version of a blog post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createLangVariationAsyncWithHttpInfo($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + public function getPreviousVersionAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->createLangVariationRequest($blog_post_language_clone_request_v_next, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost'; + $request = $this->getPreviousVersionRequest($object_id, $revision_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2248,3112 +2578,34 @@ function ($exception) { } /** - * Create request for operation 'createLangVariation' + * Create request for operation 'getPreviousVersion' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to retrieve. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createLangVariationRequest($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) - { - - // verify the required parameter 'blog_post_language_clone_request_v_next' is set - if ($blog_post_language_clone_request_v_next === null || (is_array($blog_post_language_clone_request_v_next) && count($blog_post_language_clone_request_v_next) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $blog_post_language_clone_request_v_next when calling createLangVariation' - ); - } - - - $resourcePath = '/cms/v3/blogs/posts/multi-language/create-language-variation'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($blog_post_language_clone_request_v_next)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post_language_clone_request_v_next)); - } else { - $httpBody = $blog_post_language_clone_request_v_next; - } - } 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 - ); - } - - /** - * Operation detachFromLangGroup - * - * Detach a Blog Post from a multi-language group - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return void - */ - public function detachFromLangGroup($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) - { - $this->detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_v_next, $contentType); - } - - /** - * Operation detachFromLangGroupWithHttpInfo - * - * Detach a Blog Post from a multi-language group - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) - { - $request = $this->detachFromLangGroupRequest($detach_from_lang_group_request_v_next, $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(); - - 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 [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation detachFromLangGroupAsync - * - * Detach a Blog Post from a multi-language group - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function detachFromLangGroupAsync($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) - { - return $this->detachFromLangGroupAsyncWithHttpInfo($detach_from_lang_group_request_v_next, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation detachFromLangGroupAsyncWithHttpInfo - * - * Detach a Blog Post from a multi-language group - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function detachFromLangGroupAsyncWithHttpInfo($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) - { - $returnType = ''; - $request = $this->detachFromLangGroupRequest($detach_from_lang_group_request_v_next, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $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 'detachFromLangGroup' - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function detachFromLangGroupRequest($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) - { - - // verify the required parameter 'detach_from_lang_group_request_v_next' is set - if ($detach_from_lang_group_request_v_next === null || (is_array($detach_from_lang_group_request_v_next) && count($detach_from_lang_group_request_v_next) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $detach_from_lang_group_request_v_next when calling detachFromLangGroup' - ); - } - - - $resourcePath = '/cms/v3/blogs/posts/multi-language/detach-from-lang-group'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($detach_from_lang_group_request_v_next)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($detach_from_lang_group_request_v_next)); - } else { - $httpBody = $detach_from_lang_group_request_v_next; - } - } 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 - ); - } - - /** - * Operation getById - * - * Retrieve a Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function getById($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) - { - list($response) = $this->getByIdWithHttpInfo($object_id, $archived, $property, $contentType); - return $response; - } - - /** - * Operation getByIdWithHttpInfo - * - * Retrieve a Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getByIdWithHttpInfo($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) - { - $request = $this->getByIdRequest($object_id, $archived, $property, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getByIdAsync - * - * Retrieve a Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getByIdAsync($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) - { - return $this->getByIdAsyncWithHttpInfo($object_id, $archived, $property, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getByIdAsyncWithHttpInfo - * - * Retrieve a Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getByIdAsyncWithHttpInfo($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->getByIdRequest($object_id, $archived, $property, $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 'getById' - * - * @param string $object_id The Blog Post id. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getByIdRequest($object_id, $archived = null, $property = null, string $contentType = self::contentTypes['getById'][0]) - { - - // verify the required parameter 'object_id' is set - if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling getById' - ); - } - - - - - $resourcePath = '/cms/v3/blogs/posts/{objectId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $archived, - 'archived', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $property, - 'property', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - // path params - if ($object_id !== null) { - $resourcePath = str_replace( - '{' . 'objectId' . '}', - ObjectSerializer::toPathValue($object_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getDraftById - * - * Retrieve the full draft version of the Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function getDraftById($object_id, string $contentType = self::contentTypes['getDraftById'][0]) - { - list($response) = $this->getDraftByIdWithHttpInfo($object_id, $contentType); - return $response; - } - - /** - * Operation getDraftByIdWithHttpInfo - * - * Retrieve the full draft version of the Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getDraftByIdWithHttpInfo($object_id, string $contentType = self::contentTypes['getDraftById'][0]) - { - $request = $this->getDraftByIdRequest($object_id, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getDraftByIdAsync - * - * Retrieve the full draft version of the Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getDraftByIdAsync($object_id, string $contentType = self::contentTypes['getDraftById'][0]) - { - return $this->getDraftByIdAsyncWithHttpInfo($object_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getDraftByIdAsyncWithHttpInfo - * - * Retrieve the full draft version of the Blog Post - * - * @param string $object_id The Blog Post id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getDraftByIdAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['getDraftById'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->getDraftByIdRequest($object_id, $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 'getDraftById' - * - * @param string $object_id The Blog Post id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDraftById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getDraftByIdRequest($object_id, string $contentType = self::contentTypes['getDraftById'][0]) - { - - // verify the required parameter 'object_id' is set - if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling getDraftById' - ); - } - - - $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($object_id !== null) { - $resourcePath = str_replace( - '{' . 'objectId' . '}', - ObjectSerializer::toPathValue($object_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getPage - * - * Get all Blog Posts - * - * @param \DateTime $created_at Only return Blog Posts created at exactly the specified time. (optional) - * @param \DateTime $created_after Only return Blog Posts created after the specified time. (optional) - * @param \DateTime $created_before Only return Blog Posts created before the specified time. (optional) - * @param \DateTime $updated_at Only return Blog Posts last updated at exactly the specified time. (optional) - * @param \DateTime $updated_after Only return Blog Posts last updated after the specified time. (optional) - * @param \DateTime $updated_before Only return Blog Posts last updated before the specified time. (optional) - * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default. (optional) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit The maximum number of results to return. Default is 20. (optional) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function getPage($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) - { - list($response) = $this->getPageWithHttpInfo($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType); - return $response; - } - - /** - * Operation getPageWithHttpInfo - * - * Get all Blog Posts - * - * @param \DateTime $created_at Only return Blog Posts created at exactly the specified time. (optional) - * @param \DateTime $created_after Only return Blog Posts created after the specified time. (optional) - * @param \DateTime $created_before Only return Blog Posts created before the specified time. (optional) - * @param \DateTime $updated_at Only return Blog Posts last updated at exactly the specified time. (optional) - * @param \DateTime $updated_after Only return Blog Posts last updated after the specified time. (optional) - * @param \DateTime $updated_before Only return Blog Posts last updated before the specified time. (optional) - * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default. (optional) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit The maximum number of results to return. Default is 20. (optional) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getPageWithHttpInfo($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) - { - $request = $this->getPageRequest($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging' !== '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\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getPageAsync - * - * Get all Blog Posts - * - * @param \DateTime $created_at Only return Blog Posts created at exactly the specified time. (optional) - * @param \DateTime $created_after Only return Blog Posts created after the specified time. (optional) - * @param \DateTime $created_before Only return Blog Posts created before the specified time. (optional) - * @param \DateTime $updated_at Only return Blog Posts last updated at exactly the specified time. (optional) - * @param \DateTime $updated_after Only return Blog Posts last updated after the specified time. (optional) - * @param \DateTime $updated_before Only return Blog Posts last updated before the specified time. (optional) - * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default. (optional) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit The maximum number of results to return. Default is 20. (optional) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPageAsync($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) - { - return $this->getPageAsyncWithHttpInfo($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getPageAsyncWithHttpInfo - * - * Get all Blog Posts - * - * @param \DateTime $created_at Only return Blog Posts created at exactly the specified time. (optional) - * @param \DateTime $created_after Only return Blog Posts created after the specified time. (optional) - * @param \DateTime $created_before Only return Blog Posts created before the specified time. (optional) - * @param \DateTime $updated_at Only return Blog Posts last updated at exactly the specified time. (optional) - * @param \DateTime $updated_after Only return Blog Posts last updated after the specified time. (optional) - * @param \DateTime $updated_before Only return Blog Posts last updated before the specified time. (optional) - * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default. (optional) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit The maximum number of results to return. Default is 20. (optional) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPageAsyncWithHttpInfo($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalBlogPostForwardPaging'; - $request = $this->getPageRequest($created_at, $created_after, $created_before, $updated_at, $updated_after, $updated_before, $sort, $after, $limit, $archived, $property, $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 'getPage' - * - * @param \DateTime $created_at Only return Blog Posts created at exactly the specified time. (optional) - * @param \DateTime $created_after Only return Blog Posts created after the specified time. (optional) - * @param \DateTime $created_before Only return Blog Posts created before the specified time. (optional) - * @param \DateTime $updated_at Only return Blog Posts last updated at exactly the specified time. (optional) - * @param \DateTime $updated_after Only return Blog Posts last updated after the specified time. (optional) - * @param \DateTime $updated_before Only return Blog Posts last updated before the specified time. (optional) - * @param string[] $sort Specifies which fields to use for sorting results. Valid fields are `name`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. `createdAt` will be used by default. (optional) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit The maximum number of results to return. Default is 20. (optional) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $property (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getPageRequest($created_at = null, $created_after = null, $created_before = null, $updated_at = null, $updated_after = null, $updated_before = null, $sort = null, $after = null, $limit = null, $archived = null, $property = null, string $contentType = self::contentTypes['getPage'][0]) - { - - - - - - - - - - - - - - $resourcePath = '/cms/v3/blogs/posts'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $created_at, - 'createdAt', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $created_after, - 'createdAfter', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $created_before, - 'createdBefore', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $updated_at, - 'updatedAt', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $updated_after, - 'updatedAfter', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $updated_before, - 'updatedBefore', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $sort, - 'sort', // param base name - 'array', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $after, - 'after', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $limit, - 'limit', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $archived, - 'archived', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $property, - 'property', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getPreviousVersion - * - * Retrieves a previous version of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function getPreviousVersion($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) - { - list($response) = $this->getPreviousVersionWithHttpInfo($object_id, $revision_id, $contentType); - return $response; - } - - /** - * Operation getPreviousVersionWithHttpInfo - * - * Retrieves a previous version of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getPreviousVersionWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) - { - $request = $this->getPreviousVersionRequest($object_id, $revision_id, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\VersionBlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getPreviousVersionAsync - * - * Retrieves a previous version of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPreviousVersionAsync($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) - { - return $this->getPreviousVersionAsyncWithHttpInfo($object_id, $revision_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getPreviousVersionAsyncWithHttpInfo - * - * Retrieves a previous version of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPreviousVersionAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\VersionBlogPost'; - $request = $this->getPreviousVersionRequest($object_id, $revision_id, $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 'getPreviousVersion' - * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersion'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getPreviousVersionRequest($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) - { - - // verify the required parameter 'object_id' is set - if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling getPreviousVersion' - ); - } - - // verify the required parameter 'revision_id' is set - if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $revision_id when calling getPreviousVersion' - ); - } - - - $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($object_id !== null) { - $resourcePath = str_replace( - '{' . 'objectId' . '}', - ObjectSerializer::toPathValue($object_id), - $resourcePath - ); - } - // path params - if ($revision_id !== null) { - $resourcePath = str_replace( - '{' . 'revisionId' . '}', - ObjectSerializer::toPathValue($revision_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getPreviousVersions - * - * Retrieves all the previous versions of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param string $before before (optional) - * @param int $limit The maximum number of results to return. Default is 100. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function getPreviousVersions($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) - { - list($response) = $this->getPreviousVersionsWithHttpInfo($object_id, $after, $before, $limit, $contentType); - return $response; - } - - /** - * Operation getPreviousVersionsWithHttpInfo - * - * Retrieves all the previous versions of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param string $before (optional) - * @param int $limit The maximum number of results to return. Default is 100. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) - { - $request = $this->getPreviousVersionsRequest($object_id, $after, $before, $limit, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getPreviousVersionsAsync - * - * Retrieves all the previous versions of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param string $before (optional) - * @param int $limit The maximum number of results to return. Default is 100. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPreviousVersionsAsync($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) - { - return $this->getPreviousVersionsAsyncWithHttpInfo($object_id, $after, $before, $limit, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getPreviousVersionsAsyncWithHttpInfo - * - * Retrieves all the previous versions of a blog post - * - * @param string $object_id The Blog Post id. (required) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param string $before (optional) - * @param int $limit The maximum number of results to return. Default is 100. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPreviousVersionsAsyncWithHttpInfo($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost'; - $request = $this->getPreviousVersionsRequest($object_id, $after, $before, $limit, $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 'getPreviousVersions' - * - * @param string $object_id The Blog Post id. (required) - * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param string $before (optional) - * @param int $limit The maximum number of results to return. Default is 100. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getPreviousVersionsRequest($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) - { - - // verify the required parameter 'object_id' is set - if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling getPreviousVersions' - ); - } - - - - - - $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $after, - 'after', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $before, - 'before', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $limit, - 'limit', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - // path params - if ($object_id !== null) { - $resourcePath = str_replace( - '{' . 'objectId' . '}', - ObjectSerializer::toPathValue($object_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation pushLive - * - * Push Blog Post draft edits live - * - * @param string $object_id The id of the Blog Post for which it's draft will be pushed live. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return void - */ - public function pushLive($object_id, string $contentType = self::contentTypes['pushLive'][0]) - { - $this->pushLiveWithHttpInfo($object_id, $contentType); - } - - /** - * Operation pushLiveWithHttpInfo - * - * Push Blog Post draft edits live - * - * @param string $object_id The id of the Blog Post for which it's draft will be pushed live. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function pushLiveWithHttpInfo($object_id, string $contentType = self::contentTypes['pushLive'][0]) - { - $request = $this->pushLiveRequest($object_id, $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(); - - 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 [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation pushLiveAsync - * - * Push Blog Post draft edits live - * - * @param string $object_id The id of the Blog Post for which it's draft will be pushed live. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function pushLiveAsync($object_id, string $contentType = self::contentTypes['pushLive'][0]) - { - return $this->pushLiveAsyncWithHttpInfo($object_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation pushLiveAsyncWithHttpInfo - * - * Push Blog Post draft edits live - * - * @param string $object_id The id of the Blog Post for which it's draft will be pushed live. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function pushLiveAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['pushLive'][0]) - { - $returnType = ''; - $request = $this->pushLiveRequest($object_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $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 'pushLive' - * - * @param string $object_id The id of the Blog Post for which it's draft will be pushed live. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function pushLiveRequest($object_id, string $contentType = self::contentTypes['pushLive'][0]) - { - - // verify the required parameter 'object_id' is set - if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling pushLive' - ); - } - - - $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft/push-live'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($object_id !== null) { - $resourcePath = str_replace( - '{' . 'objectId' . '}', - ObjectSerializer::toPathValue($object_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (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 - ); - } - - /** - * Operation readBatch - * - * Retrieve a batch of Blog Posts - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['readBatch'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error - */ - public function readBatch($batch_input_string, $archived = null, string $contentType = self::contentTypes['readBatch'][0]) - { - list($response) = $this->readBatchWithHttpInfo($batch_input_string, $archived, $contentType); - return $response; - } - - /** - * Operation readBatchWithHttpInfo - * - * Retrieve a batch of Blog Posts - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['readBatch'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) - */ - public function readBatchWithHttpInfo($batch_input_string, $archived = null, string $contentType = self::contentTypes['readBatch'][0]) - { - $request = $this->readBatchRequest($batch_input_string, $archived, $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(); - - 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() - ); - } - - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 207: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; - 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() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 207: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation readBatchAsync - * - * Retrieve a batch of Blog Posts - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['readBatch'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function readBatchAsync($batch_input_string, $archived = null, string $contentType = self::contentTypes['readBatch'][0]) - { - return $this->readBatchAsyncWithHttpInfo($batch_input_string, $archived, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation readBatchAsyncWithHttpInfo - * - * Retrieve a batch of Blog Posts - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['readBatch'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function readBatchAsyncWithHttpInfo($batch_input_string, $archived = null, string $contentType = self::contentTypes['readBatch'][0]) - { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; - $request = $this->readBatchRequest($batch_input_string, $archived, $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 'readBatch' - * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) - * @param bool $archived Specifies whether to return deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['readBatch'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function readBatchRequest($batch_input_string, $archived = null, string $contentType = self::contentTypes['readBatch'][0]) - { - - // verify the required parameter 'batch_input_string' is set - if ($batch_input_string === null || (is_array($batch_input_string) && count($batch_input_string) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $batch_input_string when calling readBatch' - ); - } - - - - $resourcePath = '/cms/v3/blogs/posts/batch/read'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $archived, - 'archived', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (isset($batch_input_string)) { - 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_string)); - } else { - $httpBody = $batch_input_string; - } - } 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 - ); - } - - /** - * Operation resetDraft - * - * Reset the Blog Post draft to the live version - * - * @param string $object_id The id of the Blog Post for which it's draft will be reset. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return void - */ - public function resetDraft($object_id, string $contentType = self::contentTypes['resetDraft'][0]) - { - $this->resetDraftWithHttpInfo($object_id, $contentType); - } - - /** - * Operation resetDraftWithHttpInfo - * - * Reset the Blog Post draft to the live version - * - * @param string $object_id The id of the Blog Post for which it's draft will be reset. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation - * - * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function resetDraftWithHttpInfo($object_id, string $contentType = self::contentTypes['resetDraft'][0]) - { - $request = $this->resetDraftRequest($object_id, $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(); - - 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 [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation resetDraftAsync - * - * Reset the Blog Post draft to the live version - * - * @param string $object_id The id of the Blog Post for which it's draft will be reset. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function resetDraftAsync($object_id, string $contentType = self::contentTypes['resetDraft'][0]) - { - return $this->resetDraftAsyncWithHttpInfo($object_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation resetDraftAsyncWithHttpInfo - * - * Reset the Blog Post draft to the live version - * - * @param string $object_id The id of the Blog Post for which it's draft will be reset. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function resetDraftAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['resetDraft'][0]) - { - $returnType = ''; - $request = $this->resetDraftRequest($object_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $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 'resetDraft' - * - * @param string $object_id The id of the Blog Post for which it's draft will be reset. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function resetDraftRequest($object_id, string $contentType = self::contentTypes['resetDraft'][0]) + public function getPreviousVersionRequest($object_id, $revision_id, string $contentType = self::contentTypes['getPreviousVersion'][0]) { // verify the required parameter 'object_id' is set if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling resetDraft' + 'Missing the required parameter $object_id when calling getPreviousVersion' + ); + } + + // verify the required parameter 'revision_id' is set + if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $revision_id when calling getPreviousVersion' ); } - $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft/reset'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -5370,10 +2622,18 @@ public function resetDraftRequest($object_id, string $contentType = self::conten $resourcePath ); } + // path params + if ($revision_id !== null) { + $resourcePath = str_replace( + '{' . 'revisionId' . '}', + ObjectSerializer::toPathValue($revision_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', '*/*', ], $contentType, $multipart ); @@ -5422,7 +2682,7 @@ public function resetDraftRequest($object_id, string $contentType = self::conten $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -5430,40 +2690,44 @@ public function resetDraftRequest($object_id, string $contentType = self::conten } /** - * Operation restorePreviousVersion + * Operation getPreviousVersions * - * Restore a previous version of a blog post + * Retrieves all previous versions of a post * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve previous versions of. (required) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param string $before before (optional) + * @param int $limit The maximum number of results to return. Default is 100. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function restorePreviousVersion($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) + public function getPreviousVersions($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) { - list($response) = $this->restorePreviousVersionWithHttpInfo($object_id, $revision_id, $contentType); + list($response) = $this->getPreviousVersionsWithHttpInfo($object_id, $after, $before, $limit, $contentType); return $response; } /** - * Operation restorePreviousVersionWithHttpInfo + * Operation getPreviousVersionsWithHttpInfo * - * Restore a previous version of a blog post + * Retrieves all previous versions of a post * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve previous versions of. (required) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param string $before (optional) + * @param int $limit The maximum number of results to return. Default is 100. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) + public function getPreviousVersionsWithHttpInfo($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) { - $request = $this->restorePreviousVersionRequest($object_id, $revision_id, $contentType); + $request = $this->getPreviousVersionsRequest($object_id, $after, $before, $limit, $contentType); try { $options = $this->createHttpClientOption(); @@ -5502,11 +2766,11 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str switch($statusCode) { case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost' === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== 'string') { + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost' !== 'string') { try { $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { @@ -5524,7 +2788,7 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str } return [ - ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', []), + ObjectSerializer::deserialize($content, '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost', []), $response->getStatusCode(), $response->getHeaders() ]; @@ -5557,7 +2821,7 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str ]; } - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { @@ -5590,7 +2854,7 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -5609,20 +2873,22 @@ public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, str } /** - * Operation restorePreviousVersionAsync + * Operation getPreviousVersionsAsync * - * Restore a previous version of a blog post + * Retrieves all previous versions of a post * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve previous versions of. (required) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param string $before (optional) + * @param int $limit The maximum number of results to return. Default is 100. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function restorePreviousVersionAsync($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) + public function getPreviousVersionsAsync($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) { - return $this->restorePreviousVersionAsyncWithHttpInfo($object_id, $revision_id, $contentType) + return $this->getPreviousVersionsAsyncWithHttpInfo($object_id, $after, $before, $limit, $contentType) ->then( function ($response) { return $response[0]; @@ -5631,21 +2897,23 @@ function ($response) { } /** - * Operation restorePreviousVersionAsyncWithHttpInfo + * Operation getPreviousVersionsAsyncWithHttpInfo * - * Restore a previous version of a blog post + * Retrieves all previous versions of a post * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve previous versions of. (required) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param string $before (optional) + * @param int $limit The maximum number of results to return. Default is 100. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function restorePreviousVersionAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) + public function getPreviousVersionsAsyncWithHttpInfo($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->restorePreviousVersionRequest($object_id, $revision_id, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\CollectionResponseWithTotalVersionBlogPost'; + $request = $this->getPreviousVersionsRequest($object_id, $after, $before, $limit, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -5684,40 +2952,65 @@ function ($exception) { } /** - * Create request for operation 'restorePreviousVersion' + * Create request for operation 'getPreviousVersions' * - * @param string $object_id The Blog Post id. (required) - * @param string $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to retrieve previous versions of. (required) + * @param string $after The cursor token value to get the next set of results. You can get this from the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param string $before (optional) + * @param int $limit The maximum number of results to return. Default is 100. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPreviousVersions'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function restorePreviousVersionRequest($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) + public function getPreviousVersionsRequest($object_id, $after = null, $before = null, $limit = null, string $contentType = self::contentTypes['getPreviousVersions'][0]) { // verify the required parameter 'object_id' is set if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling restorePreviousVersion' + 'Missing the required parameter $object_id when calling getPreviousVersions' ); } - // verify the required parameter 'revision_id' is set - if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $revision_id when calling restorePreviousVersion' - ); - } - $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}/restore'; + + + $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $after, + 'after', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $before, + 'before', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params @@ -5728,14 +3021,6 @@ public function restorePreviousVersionRequest($object_id, $revision_id, string $ $resourcePath ); } - // path params - if ($revision_id !== null) { - $resourcePath = str_replace( - '{' . 'revisionId' . '}', - ObjectSerializer::toPathValue($revision_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( @@ -5788,7 +3073,7 @@ public function restorePreviousVersionRequest($object_id, $revision_id, string $ $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -5796,40 +3081,37 @@ public function restorePreviousVersionRequest($object_id, $revision_id, string $ } /** - * Operation restorePreviousVersionToDraft + * Operation pushLive * - * Restore a previous version of a blog post, to the draft version of the blog post + * Publish blog post draft * - * @param string $object_id The Blog Post id. (required) - * @param int $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation + * @param string $object_id The ID of the post to publish. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + * @return void */ - public function restorePreviousVersionToDraft($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) + public function pushLive($object_id, string $contentType = self::contentTypes['pushLive'][0]) { - list($response) = $this->restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_id, $contentType); - return $response; + $this->pushLiveWithHttpInfo($object_id, $contentType); } /** - * Operation restorePreviousVersionToDraftWithHttpInfo + * Operation pushLiveWithHttpInfo * - * Restore a previous version of a blog post, to the draft version of the blog post + * Publish blog post draft * - * @param string $object_id The Blog Post id. (required) - * @param int $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation + * @param string $object_id The ID of the post to publish. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) + public function pushLiveWithHttpInfo($object_id, string $contentType = self::contentTypes['pushLive'][0]) { - $request = $this->restorePreviousVersionToDraftRequest($object_id, $revision_id, $contentType); + $request = $this->pushLiveRequest($object_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -5866,101 +3148,10 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ ); } - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - 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 [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -5975,20 +3166,19 @@ public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_ } /** - * Operation restorePreviousVersionToDraftAsync + * Operation pushLiveAsync * - * Restore a previous version of a blog post, to the draft version of the blog post + * Publish blog post draft * - * @param string $object_id The Blog Post id. (required) - * @param int $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation + * @param string $object_id The ID of the post to publish. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function restorePreviousVersionToDraftAsync($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) + public function pushLiveAsync($object_id, string $contentType = self::contentTypes['pushLive'][0]) { - return $this->restorePreviousVersionToDraftAsyncWithHttpInfo($object_id, $revision_id, $contentType) + return $this->pushLiveAsyncWithHttpInfo($object_id, $contentType) ->then( function ($response) { return $response[0]; @@ -5997,40 +3187,26 @@ function ($response) { } /** - * Operation restorePreviousVersionToDraftAsyncWithHttpInfo + * Operation pushLiveAsyncWithHttpInfo * - * Restore a previous version of a blog post, to the draft version of the blog post + * Publish blog post draft * - * @param string $object_id The Blog Post id. (required) - * @param int $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation + * @param string $object_id The ID of the post to publish. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function restorePreviousVersionToDraftAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) + public function pushLiveAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['pushLive'][0]) { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->restorePreviousVersionToDraftRequest($object_id, $revision_id, $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() - ]; + $returnType = ''; + $request = $this->pushLiveRequest($object_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { $response = $exception->getResponse(); @@ -6050,34 +3226,26 @@ function ($exception) { } /** - * Create request for operation 'restorePreviousVersionToDraft' + * Create request for operation 'pushLive' * - * @param string $object_id The Blog Post id. (required) - * @param int $revision_id The Blog Post version id to restore. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation + * @param string $object_id The ID of the post to publish. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['pushLive'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function restorePreviousVersionToDraftRequest($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) + public function pushLiveRequest($object_id, string $contentType = self::contentTypes['pushLive'][0]) { // verify the required parameter 'object_id' is set if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling restorePreviousVersionToDraft' - ); - } - - // verify the required parameter 'revision_id' is set - if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $revision_id when calling restorePreviousVersionToDraft' + 'Missing the required parameter $object_id when calling pushLive' ); } - $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}/restore-to-draft'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft/push-live'; $formParams = []; $queryParams = []; $headerParams = []; @@ -6094,18 +3262,10 @@ public function restorePreviousVersionToDraftRequest($object_id, $revision_id, s $resourcePath ); } - // path params - if ($revision_id !== null) { - $resourcePath = str_replace( - '{' . 'revisionId' . '}', - ObjectSerializer::toPathValue($revision_id), - $resourcePath - ); - } $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], + ['*/*', ], $contentType, $multipart ); @@ -6162,37 +3322,37 @@ public function restorePreviousVersionToDraftRequest($object_id, $revision_id, s } /** - * Operation schedule + * Operation resetDraft * - * Schedule a Blog Post to be Published + * Reset post draft to the live version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to reset. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return void */ - public function schedule($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) + public function resetDraft($object_id, string $contentType = self::contentTypes['resetDraft'][0]) { - $this->scheduleWithHttpInfo($content_schedule_request_v_next, $contentType); + $this->resetDraftWithHttpInfo($object_id, $contentType); } /** - * Operation scheduleWithHttpInfo + * Operation resetDraftWithHttpInfo * - * Schedule a Blog Post to be Published + * Reset post draft to the live version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to reset. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function scheduleWithHttpInfo($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) + public function resetDraftWithHttpInfo($object_id, string $contentType = self::contentTypes['resetDraft'][0]) { - $request = $this->scheduleRequest($content_schedule_request_v_next, $contentType); + $request = $this->resetDraftRequest($object_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -6247,19 +3407,19 @@ public function scheduleWithHttpInfo($content_schedule_request_v_next, string $c } /** - * Operation scheduleAsync + * Operation resetDraftAsync * - * Schedule a Blog Post to be Published + * Reset post draft to the live version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to reset. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function scheduleAsync($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) + public function resetDraftAsync($object_id, string $contentType = self::contentTypes['resetDraft'][0]) { - return $this->scheduleAsyncWithHttpInfo($content_schedule_request_v_next, $contentType) + return $this->resetDraftAsyncWithHttpInfo($object_id, $contentType) ->then( function ($response) { return $response[0]; @@ -6268,20 +3428,20 @@ function ($response) { } /** - * Operation scheduleAsyncWithHttpInfo + * Operation resetDraftAsyncWithHttpInfo * - * Schedule a Blog Post to be Published + * Reset post draft to the live version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to reset. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function scheduleAsyncWithHttpInfo($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) + public function resetDraftAsyncWithHttpInfo($object_id, string $contentType = self::contentTypes['resetDraft'][0]) { $returnType = ''; - $request = $this->scheduleRequest($content_schedule_request_v_next, $contentType); + $request = $this->resetDraftRequest($object_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -6307,26 +3467,26 @@ function ($exception) { } /** - * Create request for operation 'schedule' + * Create request for operation 'resetDraft' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to reset. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['resetDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function scheduleRequest($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) + public function resetDraftRequest($object_id, string $contentType = self::contentTypes['resetDraft'][0]) { - // verify the required parameter 'content_schedule_request_v_next' is set - if ($content_schedule_request_v_next === null || (is_array($content_schedule_request_v_next) && count($content_schedule_request_v_next) === 0)) { + // verify the required parameter 'object_id' is set + if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $content_schedule_request_v_next when calling schedule' + 'Missing the required parameter $object_id when calling resetDraft' ); } - $resourcePath = '/cms/v3/blogs/posts/schedule'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft/reset'; $formParams = []; $queryParams = []; $headerParams = []; @@ -6335,6 +3495,14 @@ public function scheduleRequest($content_schedule_request_v_next, string $conten + // path params + if ($object_id !== null) { + $resourcePath = str_replace( + '{' . 'objectId' . '}', + ObjectSerializer::toPathValue($object_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -6344,14 +3512,7 @@ public function scheduleRequest($content_schedule_request_v_next, string $conten ); // for model (json/xml) - if (isset($content_schedule_request_v_next)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($content_schedule_request_v_next)); - } else { - $httpBody = $content_schedule_request_v_next; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -6402,37 +3563,40 @@ public function scheduleRequest($content_schedule_request_v_next, string $conten } /** - * Operation setLangPrimary + * Operation restorePreviousVersion * - * Set a new primary language + * Restore a previous version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return void + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function setLangPrimary($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + public function restorePreviousVersion($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) { - $this->setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_next, $contentType); + list($response) = $this->restorePreviousVersionWithHttpInfo($object_id, $revision_id, $contentType); + return $response; } /** - * Operation setLangPrimaryWithHttpInfo + * Operation restorePreviousVersionWithHttpInfo * - * Set a new primary language + * Restore a previous version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + public function restorePreviousVersionWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) { - $request = $this->setLangPrimaryRequest($set_new_language_primary_request_v_next, $contentType); + $request = $this->restorePreviousVersionRequest($object_id, $revision_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -6469,10 +3633,101 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n ); } - return [null, $statusCode, $response->getHeaders()]; + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + 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() + ]; } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -6487,19 +3742,20 @@ public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_n } /** - * Operation setLangPrimaryAsync + * Operation restorePreviousVersionAsync * - * Set a new primary language + * Restore a previous version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function setLangPrimaryAsync($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + public function restorePreviousVersionAsync($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) { - return $this->setLangPrimaryAsyncWithHttpInfo($set_new_language_primary_request_v_next, $contentType) + return $this->restorePreviousVersionAsyncWithHttpInfo($object_id, $revision_id, $contentType) ->then( function ($response) { return $response[0]; @@ -6508,26 +3764,40 @@ function ($response) { } /** - * Operation setLangPrimaryAsyncWithHttpInfo + * Operation restorePreviousVersionAsyncWithHttpInfo * - * Set a new primary language + * Restore a previous version * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function setLangPrimaryAsyncWithHttpInfo($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + public function restorePreviousVersionAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) { - $returnType = ''; - $request = $this->setLangPrimaryRequest($set_new_language_primary_request_v_next, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $request = $this->restorePreviousVersionRequest($object_id, $revision_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; + 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(); @@ -6547,26 +3817,34 @@ function ($exception) { } /** - * Create request for operation 'setLangPrimary' + * Create request for operation 'restorePreviousVersion' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param string $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersion'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function setLangPrimaryRequest($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + public function restorePreviousVersionRequest($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersion'][0]) { - // verify the required parameter 'set_new_language_primary_request_v_next' is set - if ($set_new_language_primary_request_v_next === null || (is_array($set_new_language_primary_request_v_next) && count($set_new_language_primary_request_v_next) === 0)) { + // verify the required parameter 'object_id' is set + if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $object_id when calling restorePreviousVersion' + ); + } + + // verify the required parameter 'revision_id' is set + if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $set_new_language_primary_request_v_next when calling setLangPrimary' + 'Missing the required parameter $revision_id when calling restorePreviousVersion' ); } - $resourcePath = '/cms/v3/blogs/posts/multi-language/set-new-lang-primary'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}/restore'; $formParams = []; $queryParams = []; $headerParams = []; @@ -6575,23 +3853,32 @@ public function setLangPrimaryRequest($set_new_language_primary_request_v_next, + // path params + if ($object_id !== null) { + $resourcePath = str_replace( + '{' . 'objectId' . '}', + ObjectSerializer::toPathValue($object_id), + $resourcePath + ); + } + // path params + if ($revision_id !== null) { + $resourcePath = str_replace( + '{' . 'revisionId' . '}', + ObjectSerializer::toPathValue($revision_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', '*/*', ], $contentType, $multipart ); // for model (json/xml) - if (isset($set_new_language_primary_request_v_next)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_new_language_primary_request_v_next)); - } else { - $httpBody = $set_new_language_primary_request_v_next; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -6634,7 +3921,7 @@ public function setLangPrimaryRequest($set_new_language_primary_request_v_next, $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'PUT', + 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -6642,42 +3929,40 @@ public function setLangPrimaryRequest($set_new_language_primary_request_v_next, } /** - * Operation update + * Operation restorePreviousVersionToDraft * - * Update a Blog Post + * Restore a draft to a previous version * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param int $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function update($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) + public function restorePreviousVersionToDraft($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) { - list($response) = $this->updateWithHttpInfo($object_id, $blog_post, $archived, $contentType); + list($response) = $this->restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_id, $contentType); return $response; } /** - * Operation updateWithHttpInfo + * Operation restorePreviousVersionToDraftWithHttpInfo * - * Update a Blog Post + * Restore a draft to a previous version * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param int $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function updateWithHttpInfo($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) + public function restorePreviousVersionToDraftWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) { - $request = $this->updateRequest($object_id, $blog_post, $archived, $contentType); + $request = $this->restorePreviousVersionToDraftRequest($object_id, $revision_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -6823,21 +4108,20 @@ public function updateWithHttpInfo($object_id, $blog_post, $archived = null, str } /** - * Operation updateAsync + * Operation restorePreviousVersionToDraftAsync * - * Update a Blog Post + * Restore a draft to a previous version * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param int $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateAsync($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) + public function restorePreviousVersionToDraftAsync($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) { - return $this->updateAsyncWithHttpInfo($object_id, $blog_post, $archived, $contentType) + return $this->restorePreviousVersionToDraftAsyncWithHttpInfo($object_id, $revision_id, $contentType) ->then( function ($response) { return $response[0]; @@ -6846,22 +4130,21 @@ function ($response) { } /** - * Operation updateAsyncWithHttpInfo + * Operation restorePreviousVersionToDraftAsyncWithHttpInfo * - * Update a Blog Post + * Restore a draft to a previous version * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param int $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateAsyncWithHttpInfo($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) + public function restorePreviousVersionToDraftAsyncWithHttpInfo($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) { $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->updateRequest($object_id, $blog_post, $archived, $contentType); + $request = $this->restorePreviousVersionToDraftRequest($object_id, $revision_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -6900,51 +4183,40 @@ function ($exception) { } /** - * Create request for operation 'update' + * Create request for operation 'restorePreviousVersionToDraft' * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * @param string $object_id The ID of the blog post. (required) + * @param int $revision_id The ID of the version to restore the blog post to. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['restorePreviousVersionToDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updateRequest($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) + public function restorePreviousVersionToDraftRequest($object_id, $revision_id, string $contentType = self::contentTypes['restorePreviousVersionToDraft'][0]) { // verify the required parameter 'object_id' is set if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling update' + 'Missing the required parameter $object_id when calling restorePreviousVersionToDraft' ); } - // verify the required parameter 'blog_post' is set - if ($blog_post === null || (is_array($blog_post) && count($blog_post) === 0)) { + // verify the required parameter 'revision_id' is set + if ($revision_id === null || (is_array($revision_id) && count($revision_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $blog_post when calling update' + 'Missing the required parameter $revision_id when calling restorePreviousVersionToDraft' ); } - - $resourcePath = '/cms/v3/blogs/posts/{objectId}'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/revisions/{revisionId}/restore-to-draft'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $archived, - 'archived', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); // path params @@ -6955,6 +4227,14 @@ public function updateRequest($object_id, $blog_post, $archived = null, string $ $resourcePath ); } + // path params + if ($revision_id !== null) { + $resourcePath = str_replace( + '{' . 'revisionId' . '}', + ObjectSerializer::toPathValue($revision_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( @@ -6964,14 +4244,7 @@ public function updateRequest($object_id, $blog_post, $archived = null, string $ ); // for model (json/xml) - if (isset($blog_post)) { - if (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post)); - } else { - $httpBody = $blog_post; - } - } elseif (count($formParams) > 0) { + if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { @@ -7014,7 +4287,7 @@ public function updateRequest($object_id, $blog_post, $archived = null, string $ $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'PATCH', + 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody @@ -7022,40 +4295,37 @@ public function updateRequest($object_id, $blog_post, $archived = null, string $ } /** - * Operation updateBatch + * Operation schedule * - * Update a batch of Blog Posts + * Schedule a post to be published * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + * @return void */ - public function updateBatch($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['updateBatch'][0]) + public function schedule($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) { - list($response) = $this->updateBatchWithHttpInfo($batch_input_json_node, $archived, $contentType); - return $response; + $this->scheduleWithHttpInfo($content_schedule_request_v_next, $contentType); } /** - * Operation updateBatchWithHttpInfo + * Operation scheduleWithHttpInfo * - * Update a batch of Blog Posts + * Schedule a post to be published * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['updateBatch'][0]) + public function scheduleWithHttpInfo($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) { - $request = $this->updateBatchRequest($batch_input_json_node, $archived, $contentType); + $request = $this->scheduleRequest($content_schedule_request_v_next, $contentType); try { $options = $this->createHttpClientOption(); @@ -7092,136 +4362,10 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null ); } - switch($statusCode) { - case 200: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - case 207: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - default: - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; - 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 [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - case 207: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7236,20 +4380,19 @@ public function updateBatchWithHttpInfo($batch_input_json_node, $archived = null } /** - * Operation updateBatchAsync + * Operation scheduleAsync * - * Update a batch of Blog Posts + * Schedule a post to be published * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateBatchAsync($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['updateBatch'][0]) + public function scheduleAsync($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) { - return $this->updateBatchAsyncWithHttpInfo($batch_input_json_node, $archived, $contentType) + return $this->scheduleAsyncWithHttpInfo($content_schedule_request_v_next, $contentType) ->then( function ($response) { return $response[0]; @@ -7258,40 +4401,26 @@ function ($response) { } /** - * Operation updateBatchAsyncWithHttpInfo + * Operation scheduleAsyncWithHttpInfo * - * Update a batch of Blog Posts + * Schedule a post to be published * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateBatchAsyncWithHttpInfo($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['updateBatch'][0]) + public function scheduleAsyncWithHttpInfo($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) { - $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; - $request = $this->updateBatchRequest($batch_input_json_node, $archived, $contentType); + $returnType = ''; + $request = $this->scheduleRequest($content_schedule_request_v_next, $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() - ]; + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { $response = $exception->getResponse(); @@ -7311,60 +4440,49 @@ function ($exception) { } /** - * Create request for operation 'updateBatch' + * Create request for operation 'schedule' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) - * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBatch'] to see the possible values for this operation + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\ContentScheduleRequestVNext $content_schedule_request_v_next The JSON representation of the ContentScheduleRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['schedule'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updateBatchRequest($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['updateBatch'][0]) + public function scheduleRequest($content_schedule_request_v_next, string $contentType = self::contentTypes['schedule'][0]) { - // verify the required parameter 'batch_input_json_node' is set - if ($batch_input_json_node === null || (is_array($batch_input_json_node) && count($batch_input_json_node) === 0)) { + // verify the required parameter 'content_schedule_request_v_next' is set + if ($content_schedule_request_v_next === null || (is_array($content_schedule_request_v_next) && count($content_schedule_request_v_next) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $batch_input_json_node when calling updateBatch' + 'Missing the required parameter $content_schedule_request_v_next when calling schedule' ); } - - $resourcePath = '/cms/v3/blogs/posts/batch/update'; + $resourcePath = '/cms/v3/blogs/posts/schedule'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $archived, - 'archived', // param base name - 'boolean', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); $headers = $this->headerSelector->selectHeaders( - ['application/json', '*/*', ], + ['*/*', ], $contentType, $multipart ); // for model (json/xml) - if (isset($batch_input_json_node)) { + if (isset($content_schedule_request_v_next)) { 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_json_node)); + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($content_schedule_request_v_next)); } else { - $httpBody = $batch_input_json_node; + $httpBody = $content_schedule_request_v_next; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -7417,40 +4535,42 @@ public function updateBatchRequest($batch_input_json_node, $archived = null, str } /** - * Operation updateDraft + * Operation update * - * Update a Blog Post draft + * Update a post * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) + * @param bool $archived Specifies whether to update deleted blog posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function updateDraft($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) + public function update($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) { - list($response) = $this->updateDraftWithHttpInfo($object_id, $blog_post, $contentType); + list($response) = $this->updateWithHttpInfo($object_id, $blog_post, $archived, $contentType); return $response; } /** - * Operation updateDraftWithHttpInfo + * Operation updateWithHttpInfo * - * Update a Blog Post draft + * Update a post * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) + * @param bool $archived Specifies whether to update deleted blog posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function updateDraftWithHttpInfo($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) + public function updateWithHttpInfo($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) { - $request = $this->updateDraftRequest($object_id, $blog_post, $contentType); + $request = $this->updateRequest($object_id, $blog_post, $archived, $contentType); try { $options = $this->createHttpClientOption(); @@ -7596,20 +4716,21 @@ public function updateDraftWithHttpInfo($object_id, $blog_post, string $contentT } /** - * Operation updateDraftAsync + * Operation updateAsync * - * Update a Blog Post draft + * Update a post * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) + * @param bool $archived Specifies whether to update deleted blog posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateDraftAsync($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) + public function updateAsync($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) { - return $this->updateDraftAsyncWithHttpInfo($object_id, $blog_post, $contentType) + return $this->updateAsyncWithHttpInfo($object_id, $blog_post, $archived, $contentType) ->then( function ($response) { return $response[0]; @@ -7618,21 +4739,22 @@ function ($response) { } /** - * Operation updateDraftAsyncWithHttpInfo + * Operation updateAsyncWithHttpInfo * - * Update a Blog Post draft + * Update a post * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) + * @param bool $archived Specifies whether to update deleted blog posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateDraftAsyncWithHttpInfo($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) + public function updateAsyncWithHttpInfo($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) { $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; - $request = $this->updateDraftRequest($object_id, $blog_post, $contentType); + $request = $this->updateRequest($object_id, $blog_post, $archived, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -7671,40 +4793,51 @@ function ($exception) { } /** - * Create request for operation 'updateDraft' + * Create request for operation 'update' * - * @param string $object_id The Blog Post id. (required) - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post. (required) + * @param bool $archived Specifies whether to update deleted blog posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updateDraftRequest($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) + public function updateRequest($object_id, $blog_post, $archived = null, string $contentType = self::contentTypes['update'][0]) { // verify the required parameter 'object_id' is set if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $object_id when calling updateDraft' + 'Missing the required parameter $object_id when calling update' ); } // verify the required parameter 'blog_post' is set if ($blog_post === null || (is_array($blog_post) && count($blog_post) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $blog_post when calling updateDraft' + 'Missing the required parameter $blog_post when calling update' ); } - $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft'; + + $resourcePath = '/cms/v3/blogs/posts/{objectId}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); // path params @@ -7782,37 +4915,40 @@ public function updateDraftRequest($object_id, $blog_post, string $contentType = } /** - * Operation updateLangs + * Operation updateDraft * - * Update languages of multi-language group + * Update the draft of a post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update the draft of. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return void + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error */ - public function updateLangs($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + public function updateDraft($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) { - $this->updateLangsWithHttpInfo($update_languages_request_v_next, $contentType); + list($response) = $this->updateDraftWithHttpInfo($object_id, $blog_post, $contentType); + return $response; } /** - * Operation updateLangsWithHttpInfo + * Operation updateDraftWithHttpInfo * - * Update languages of multi-language group + * Update the draft of a post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update the draft of. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) */ - public function updateLangsWithHttpInfo($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + public function updateDraftWithHttpInfo($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) { - $request = $this->updateLangsRequest($update_languages_request_v_next, $contentType); + $request = $this->updateDraftRequest($object_id, $blog_post, $contentType); try { $options = $this->createHttpClientOption(); @@ -7849,10 +4985,101 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string ); } - return [null, $statusCode, $response->getHeaders()]; + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + 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() + ]; } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; default: $data = ObjectSerializer::deserialize( $e->getResponseBody(), @@ -7867,19 +5094,20 @@ public function updateLangsWithHttpInfo($update_languages_request_v_next, string } /** - * Operation updateLangsAsync + * Operation updateDraftAsync * - * Update languages of multi-language group + * Update the draft of a post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update the draft of. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateLangsAsync($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + public function updateDraftAsync($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) { - return $this->updateLangsAsyncWithHttpInfo($update_languages_request_v_next, $contentType) + return $this->updateDraftAsyncWithHttpInfo($object_id, $blog_post, $contentType) ->then( function ($response) { return $response[0]; @@ -7888,26 +5116,40 @@ function ($response) { } /** - * Operation updateLangsAsyncWithHttpInfo + * Operation updateDraftAsyncWithHttpInfo * - * Update languages of multi-language group + * Update the draft of a post * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update the draft of. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateLangsAsyncWithHttpInfo($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + public function updateDraftAsyncWithHttpInfo($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) { - $returnType = ''; - $request = $this->updateLangsRequest($update_languages_request_v_next, $contentType); + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $request = $this->updateDraftRequest($object_id, $blog_post, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; + 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(); @@ -7927,26 +5169,34 @@ function ($exception) { } /** - * Create request for operation 'updateLangs' + * Create request for operation 'updateDraft' * - * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * @param string $object_id The ID of the blog post to update the draft of. (required) + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost $blog_post The JSON representation of the updated Blog Post to be applied to the draft. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDraft'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updateLangsRequest($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + public function updateDraftRequest($object_id, $blog_post, string $contentType = self::contentTypes['updateDraft'][0]) { - // verify the required parameter 'update_languages_request_v_next' is set - if ($update_languages_request_v_next === null || (is_array($update_languages_request_v_next) && count($update_languages_request_v_next) === 0)) { + // verify the required parameter 'object_id' is set + if ($object_id === null || (is_array($object_id) && count($object_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $object_id when calling updateDraft' + ); + } + + // verify the required parameter 'blog_post' is set + if ($blog_post === null || (is_array($blog_post) && count($blog_post) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $update_languages_request_v_next when calling updateLangs' + 'Missing the required parameter $blog_post when calling updateDraft' ); } - $resourcePath = '/cms/v3/blogs/posts/multi-language/update-languages'; + $resourcePath = '/cms/v3/blogs/posts/{objectId}/draft'; $formParams = []; $queryParams = []; $headerParams = []; @@ -7955,21 +5205,29 @@ public function updateLangsRequest($update_languages_request_v_next, string $con + // path params + if ($object_id !== null) { + $resourcePath = str_replace( + '{' . 'objectId' . '}', + ObjectSerializer::toPathValue($object_id), + $resourcePath + ); + } $headers = $this->headerSelector->selectHeaders( - ['*/*', ], + ['application/json', '*/*', ], $contentType, $multipart ); // for model (json/xml) - if (isset($update_languages_request_v_next)) { + if (isset($blog_post)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_languages_request_v_next)); + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post)); } else { - $httpBody = $update_languages_request_v_next; + $httpBody = $blog_post; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -8014,7 +5272,7 @@ public function updateLangsRequest($update_languages_request_v_next, string $con $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( - 'POST', + 'PATCH', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody diff --git a/codegen/Cms/Blogs/BlogPosts/Api/BatchApi.php b/codegen/Cms/Blogs/BlogPosts/Api/BatchApi.php new file mode 100644 index 000000000..9b0ed1421 --- /dev/null +++ b/codegen/Cms/Blogs/BlogPosts/Api/BatchApi.php @@ -0,0 +1,1562 @@ + [ + 'application/json', + ], + 'create' => [ + 'application/json', + ], + 'read' => [ + 'application/json', + ], + 'update' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation archive + * + * Delete a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function archive($batch_input_string, string $contentType = self::contentTypes['archive'][0]) + { + $this->archiveWithHttpInfo($batch_input_string, $contentType); + } + + /** + * Operation archiveWithHttpInfo + * + * Delete a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function archiveWithHttpInfo($batch_input_string, string $contentType = self::contentTypes['archive'][0]) + { + $request = $this->archiveRequest($batch_input_string, $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(); + + 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 [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation archiveAsync + * + * Delete a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function archiveAsync($batch_input_string, string $contentType = self::contentTypes['archive'][0]) + { + return $this->archiveAsyncWithHttpInfo($batch_input_string, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation archiveAsyncWithHttpInfo + * + * Delete a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function archiveAsyncWithHttpInfo($batch_input_string, string $contentType = self::contentTypes['archive'][0]) + { + $returnType = ''; + $request = $this->archiveRequest($batch_input_string, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'archive' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function archiveRequest($batch_input_string, string $contentType = self::contentTypes['archive'][0]) + { + + // verify the required parameter 'batch_input_string' is set + if ($batch_input_string === null || (is_array($batch_input_string) && count($batch_input_string) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $batch_input_string when calling archive' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/batch/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($batch_input_string)) { + 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_string)); + } else { + $httpBody = $batch_input_string; + } + } 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 + ); + } + + /** + * Operation create + * + * Create a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + */ + public function create($batch_input_blog_post, string $contentType = self::contentTypes['create'][0]) + { + list($response) = $this->createWithHttpInfo($batch_input_blog_post, $contentType); + return $response; + } + + /** + * Operation createWithHttpInfo + * + * Create a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function createWithHttpInfo($batch_input_blog_post, string $contentType = self::contentTypes['create'][0]) + { + $request = $this->createRequest($batch_input_blog_post, $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(); + + 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() + ); + } + + switch($statusCode) { + case 201: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 207: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 201: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 207: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createAsync + * + * Create a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createAsync($batch_input_blog_post, string $contentType = self::contentTypes['create'][0]) + { + return $this->createAsyncWithHttpInfo($batch_input_blog_post, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createAsyncWithHttpInfo + * + * Create a batch of blog posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createAsyncWithHttpInfo($batch_input_blog_post, string $contentType = self::contentTypes['create'][0]) + { + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + $request = $this->createRequest($batch_input_blog_post, $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 'create' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputBlogPost $batch_input_blog_post The JSON array of new Blog Posts to create. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createRequest($batch_input_blog_post, string $contentType = self::contentTypes['create'][0]) + { + + // verify the required parameter 'batch_input_blog_post' is set + if ($batch_input_blog_post === null || (is_array($batch_input_blog_post) && count($batch_input_blog_post) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $batch_input_blog_post when calling create' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/batch/create'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($batch_input_blog_post)) { + 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_blog_post)); + } else { + $httpBody = $batch_input_blog_post; + } + } 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 + ); + } + + /** + * Operation read + * + * Retrieve a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param bool $archived Specifies whether to return deleted blog posts Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['read'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + */ + public function read($batch_input_string, $archived = null, string $contentType = self::contentTypes['read'][0]) + { + list($response) = $this->readWithHttpInfo($batch_input_string, $archived, $contentType); + return $response; + } + + /** + * Operation readWithHttpInfo + * + * Retrieve a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param bool $archived Specifies whether to return deleted blog posts Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['read'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function readWithHttpInfo($batch_input_string, $archived = null, string $contentType = self::contentTypes['read'][0]) + { + $request = $this->readRequest($batch_input_string, $archived, $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(); + + 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() + ); + } + + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 207: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 207: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation readAsync + * + * Retrieve a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param bool $archived Specifies whether to return deleted blog posts Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['read'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function readAsync($batch_input_string, $archived = null, string $contentType = self::contentTypes['read'][0]) + { + return $this->readAsyncWithHttpInfo($batch_input_string, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation readAsyncWithHttpInfo + * + * Retrieve a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param bool $archived Specifies whether to return deleted blog posts Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['read'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function readAsyncWithHttpInfo($batch_input_string, $archived = null, string $contentType = self::contentTypes['read'][0]) + { + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + $request = $this->readRequest($batch_input_string, $archived, $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 'read' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputString $batch_input_string The JSON array of Blog Post ids. (required) + * @param bool $archived Specifies whether to return deleted blog posts Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['read'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function readRequest($batch_input_string, $archived = null, string $contentType = self::contentTypes['read'][0]) + { + + // verify the required parameter 'batch_input_string' is set + if ($batch_input_string === null || (is_array($batch_input_string) && count($batch_input_string) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $batch_input_string when calling read' + ); + } + + + + $resourcePath = '/cms/v3/blogs/posts/batch/read'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($batch_input_string)) { + 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_string)); + } else { + $httpBody = $batch_input_string; + } + } 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 + ); + } + + /** + * Operation update + * + * Update a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) + * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + */ + public function update($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['update'][0]) + { + list($response) = $this->updateWithHttpInfo($batch_input_json_node, $archived, $contentType); + return $response; + } + + /** + * Operation updateWithHttpInfo + * + * Update a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) + * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function updateWithHttpInfo($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['update'][0]) + { + $request = $this->updateRequest($batch_input_json_node, $archived, $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(); + + 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() + ); + } + + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 207: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors' !== '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\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 207: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPostWithErrors', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateAsync + * + * Update a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) + * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAsync($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['update'][0]) + { + return $this->updateAsyncWithHttpInfo($batch_input_json_node, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateAsyncWithHttpInfo + * + * Update a batch of Blog Posts + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) + * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateAsyncWithHttpInfo($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['update'][0]) + { + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchResponseBlogPost'; + $request = $this->updateRequest($batch_input_json_node, $archived, $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 'update' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BatchInputJsonNode $batch_input_json_node A JSON array of the JSON representations of the updated Blog Posts. (required) + * @param bool $archived Specifies whether to update deleted Blog Posts. Defaults to `false`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['update'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateRequest($batch_input_json_node, $archived = null, string $contentType = self::contentTypes['update'][0]) + { + + // verify the required parameter 'batch_input_json_node' is set + if ($batch_input_json_node === null || (is_array($batch_input_json_node) && count($batch_input_json_node) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $batch_input_json_node when calling update' + ); + } + + + + $resourcePath = '/cms/v3/blogs/posts/batch/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($batch_input_json_node)) { + 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_json_node)); + } else { + $httpBody = $batch_input_json_node; + } + } 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 + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/codegen/Cms/Blogs/BlogPosts/Api/MultiLanguageApi.php b/codegen/Cms/Blogs/BlogPosts/Api/MultiLanguageApi.php new file mode 100644 index 000000000..2029311dc --- /dev/null +++ b/codegen/Cms/Blogs/BlogPosts/Api/MultiLanguageApi.php @@ -0,0 +1,1460 @@ + [ + 'application/json', + ], + 'createLangVariation' => [ + 'application/json', + ], + 'detachFromLangGroup' => [ + 'application/json', + ], + 'setLangPrimary' => [ + 'application/json', + ], + 'updateLangs' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation attachToLangGroup + * + * Attach post to a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function attachToLangGroup($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + { + $this->attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_next, $contentType); + } + + /** + * Operation attachToLangGroupWithHttpInfo + * + * Attach post to a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function attachToLangGroupWithHttpInfo($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + { + $request = $this->attachToLangGroupRequest($attach_to_lang_primary_request_v_next, $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(); + + 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 [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation attachToLangGroupAsync + * + * Attach post to a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function attachToLangGroupAsync($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + { + return $this->attachToLangGroupAsyncWithHttpInfo($attach_to_lang_primary_request_v_next, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation attachToLangGroupAsyncWithHttpInfo + * + * Attach post to a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function attachToLangGroupAsyncWithHttpInfo($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + { + $returnType = ''; + $request = $this->attachToLangGroupRequest($attach_to_lang_primary_request_v_next, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'attachToLangGroup' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\AttachToLangPrimaryRequestVNext $attach_to_lang_primary_request_v_next The JSON representation of the AttachToLangPrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['attachToLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function attachToLangGroupRequest($attach_to_lang_primary_request_v_next, string $contentType = self::contentTypes['attachToLangGroup'][0]) + { + + // verify the required parameter 'attach_to_lang_primary_request_v_next' is set + if ($attach_to_lang_primary_request_v_next === null || (is_array($attach_to_lang_primary_request_v_next) && count($attach_to_lang_primary_request_v_next) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $attach_to_lang_primary_request_v_next when calling attachToLangGroup' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/multi-language/attach-to-lang-group'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($attach_to_lang_primary_request_v_next)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($attach_to_lang_primary_request_v_next)); + } else { + $httpBody = $attach_to_lang_primary_request_v_next; + } + } 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 + ); + } + + /** + * Operation createLangVariation + * + * Create a language variation + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error + */ + public function createLangVariation($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + { + list($response) = $this->createLangVariationWithHttpInfo($blog_post_language_clone_request_v_next, $contentType); + return $response; + } + + /** + * Operation createLangVariationWithHttpInfo + * + * Create a language variation + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost|\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error, HTTP status code, HTTP response headers (array of strings) + */ + public function createLangVariationWithHttpInfo($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + { + $request = $this->createLangVariationRequest($blog_post_language_clone_request_v_next, $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(); + + 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() + ); + } + + switch($statusCode) { + case 200: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost' !== '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\Cms\Blogs\BlogPosts\Model\BlogPost', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + default: + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\HubSpot\Client\Cms\Blogs\BlogPosts\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\Cms\Blogs\BlogPosts\Model\Error', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createLangVariationAsync + * + * Create a language variation + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createLangVariationAsync($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + { + return $this->createLangVariationAsyncWithHttpInfo($blog_post_language_clone_request_v_next, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createLangVariationAsyncWithHttpInfo + * + * Create a language variation + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createLangVariationAsyncWithHttpInfo($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + { + $returnType = '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost'; + $request = $this->createLangVariationRequest($blog_post_language_clone_request_v_next, $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 'createLangVariation' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPostLanguageCloneRequestVNext $blog_post_language_clone_request_v_next The JSON representation of the BlogPostLanguageCloneRequestVNext object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createLangVariation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createLangVariationRequest($blog_post_language_clone_request_v_next, string $contentType = self::contentTypes['createLangVariation'][0]) + { + + // verify the required parameter 'blog_post_language_clone_request_v_next' is set + if ($blog_post_language_clone_request_v_next === null || (is_array($blog_post_language_clone_request_v_next) && count($blog_post_language_clone_request_v_next) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $blog_post_language_clone_request_v_next when calling createLangVariation' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/multi-language/create-language-variation'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', '*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($blog_post_language_clone_request_v_next)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($blog_post_language_clone_request_v_next)); + } else { + $httpBody = $blog_post_language_clone_request_v_next; + } + } 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 + ); + } + + /** + * Operation detachFromLangGroup + * + * Detach post from a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function detachFromLangGroup($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) + { + $this->detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_v_next, $contentType); + } + + /** + * Operation detachFromLangGroupWithHttpInfo + * + * Detach post from a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function detachFromLangGroupWithHttpInfo($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) + { + $request = $this->detachFromLangGroupRequest($detach_from_lang_group_request_v_next, $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(); + + 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 [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation detachFromLangGroupAsync + * + * Detach post from a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function detachFromLangGroupAsync($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) + { + return $this->detachFromLangGroupAsyncWithHttpInfo($detach_from_lang_group_request_v_next, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation detachFromLangGroupAsyncWithHttpInfo + * + * Detach post from a multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function detachFromLangGroupAsyncWithHttpInfo($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) + { + $returnType = ''; + $request = $this->detachFromLangGroupRequest($detach_from_lang_group_request_v_next, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'detachFromLangGroup' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\DetachFromLangGroupRequestVNext $detach_from_lang_group_request_v_next The JSON representation of the DetachFromLangGroupRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['detachFromLangGroup'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function detachFromLangGroupRequest($detach_from_lang_group_request_v_next, string $contentType = self::contentTypes['detachFromLangGroup'][0]) + { + + // verify the required parameter 'detach_from_lang_group_request_v_next' is set + if ($detach_from_lang_group_request_v_next === null || (is_array($detach_from_lang_group_request_v_next) && count($detach_from_lang_group_request_v_next) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $detach_from_lang_group_request_v_next when calling detachFromLangGroup' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/multi-language/detach-from-lang-group'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($detach_from_lang_group_request_v_next)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($detach_from_lang_group_request_v_next)); + } else { + $httpBody = $detach_from_lang_group_request_v_next; + } + } 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 + ); + } + + /** + * Operation setLangPrimary + * + * Set a new primary language + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function setLangPrimary($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + { + $this->setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_next, $contentType); + } + + /** + * Operation setLangPrimaryWithHttpInfo + * + * Set a new primary language + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function setLangPrimaryWithHttpInfo($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + { + $request = $this->setLangPrimaryRequest($set_new_language_primary_request_v_next, $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(); + + 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 [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setLangPrimaryAsync + * + * Set a new primary language + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setLangPrimaryAsync($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + { + return $this->setLangPrimaryAsyncWithHttpInfo($set_new_language_primary_request_v_next, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setLangPrimaryAsyncWithHttpInfo + * + * Set a new primary language + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setLangPrimaryAsyncWithHttpInfo($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + { + $returnType = ''; + $request = $this->setLangPrimaryRequest($set_new_language_primary_request_v_next, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'setLangPrimary' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\SetNewLanguagePrimaryRequestVNext $set_new_language_primary_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setLangPrimary'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setLangPrimaryRequest($set_new_language_primary_request_v_next, string $contentType = self::contentTypes['setLangPrimary'][0]) + { + + // verify the required parameter 'set_new_language_primary_request_v_next' is set + if ($set_new_language_primary_request_v_next === null || (is_array($set_new_language_primary_request_v_next) && count($set_new_language_primary_request_v_next) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_new_language_primary_request_v_next when calling setLangPrimary' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/multi-language/set-new-lang-primary'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_new_language_primary_request_v_next)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_new_language_primary_request_v_next)); + } else { + $httpBody = $set_new_language_primary_request_v_next; + } + } 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( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateLangs + * + * Update languages of multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function updateLangs($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + { + $this->updateLangsWithHttpInfo($update_languages_request_v_next, $contentType); + } + + /** + * Operation updateLangsWithHttpInfo + * + * Update languages of multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * + * @throws \HubSpot\Client\Cms\Blogs\BlogPosts\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateLangsWithHttpInfo($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + { + $request = $this->updateLangsRequest($update_languages_request_v_next, $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(); + + 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 [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Cms\Blogs\BlogPosts\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateLangsAsync + * + * Update languages of multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateLangsAsync($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + { + return $this->updateLangsAsyncWithHttpInfo($update_languages_request_v_next, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateLangsAsyncWithHttpInfo + * + * Update languages of multi-language group + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateLangsAsyncWithHttpInfo($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + { + $returnType = ''; + $request = $this->updateLangsRequest($update_languages_request_v_next, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $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 'updateLangs' + * + * @param \HubSpot\Client\Cms\Blogs\BlogPosts\Model\UpdateLanguagesRequestVNext $update_languages_request_v_next The JSON representation of the SetNewLanguagePrimaryRequest object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateLangs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateLangsRequest($update_languages_request_v_next, string $contentType = self::contentTypes['updateLangs'][0]) + { + + // verify the required parameter 'update_languages_request_v_next' is set + if ($update_languages_request_v_next === null || (is_array($update_languages_request_v_next) && count($update_languages_request_v_next) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_languages_request_v_next when calling updateLangs' + ); + } + + + $resourcePath = '/cms/v3/blogs/posts/multi-language/update-languages'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_languages_request_v_next)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_languages_request_v_next)); + } else { + $httpBody = $update_languages_request_v_next; + } + } 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 + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/codegen/Cms/Blogs/BlogPosts/Model/BlogPost.php b/codegen/Cms/Blogs/BlogPosts/Model/BlogPost.php index 61ab91bfa..caddc1464 100644 --- a/codegen/Cms/Blogs/BlogPosts/Model/BlogPost.php +++ b/codegen/Cms/Blogs/BlogPosts/Model/BlogPost.php @@ -2639,7 +2639,7 @@ public function getLanguage() /** * Sets language * - * @param string $language The explicitly defined ISO 639 language code of the Blog Post. If null, the Blog Post will default to the language of the ParentBlog. + * @param string $language The explicitly defined ISO 639 language code of the post. If null, the post will default to the language of the parent blog. * * @return self */ @@ -2784,7 +2784,7 @@ public function getHtmlTitle() /** * Sets html_title * - * @param string $html_title The html title of this Blog Post. + * @param string $html_title The HTML title of the post. * * @return self */ @@ -2865,7 +2865,7 @@ public function getId() /** * Sets id * - * @param string $id The unique ID of the Blog Post. + * @param string $id The unique ID of the blog post. * * @return self */ @@ -2892,7 +2892,7 @@ public function getState() /** * Sets state * - * @param string $state An ENUM descibing the current state of this Blog Post. + * @param string $state An enumeration describing the current publish state of the post. * * @return self */ @@ -2923,7 +2923,7 @@ public function getSlug() /** * Sets slug * - * @param string $slug The path of the this blog post. This field is appended to the domain to construct the url of this post. + * @param string $slug The URL slug of the blog post. This field is appended to the domain to construct the url of this post. * * @return self */ @@ -2950,7 +2950,7 @@ public function getCreatedById() /** * Sets created_by_id * - * @param string $created_by_id The ID of the user that created this Blog Post. + * @param string $created_by_id The ID of the user that created the post. * * @return self */ @@ -3149,7 +3149,7 @@ public function getUpdatedById() /** * Sets updated_by_id * - * @param string $updated_by_id The ID of the user that updated this Blog Post. + * @param string $updated_by_id The ID of the user that updated the post. * * @return self */ @@ -3176,7 +3176,7 @@ public function getTranslatedFromId() /** * Sets translated_from_id * - * @param string $translated_from_id ID of the primary blog post this object was translated from. + * @param string $translated_from_id ID of the primary blog post that this post was translated from. * * @return self */ @@ -3338,7 +3338,7 @@ public function getAuthorName() /** * Sets author_name * - * @param string $author_name The name of the user that updated this Blog Post. + * @param string $author_name The name of the blog author associated with the post. * * @return self */ @@ -3365,7 +3365,7 @@ public function getDomain() /** * Sets domain * - * @param string $domain The domain this Blog Post will resolve to. If null, the Blog Post will default to the domain of the ParentBlog. + * @param string $domain The domain that the post lives on. If null, the post will default to the domain of the parent blog. * * @return self */ @@ -3392,7 +3392,7 @@ public function getName() /** * Sets name * - * @param string $name The internal name of the Blog Post. + * @param string $name The internal name of the post. * * @return self */ @@ -3419,7 +3419,7 @@ public function getDynamicPageHubDbTableId() /** * Sets dynamic_page_hub_db_table_id * - * @param string $dynamic_page_hub_db_table_id The ID of the HubDB table this Blog Post references, if applicable + * @param string $dynamic_page_hub_db_table_id For dynamic HubDB pages, the ID of the HubDB table this post references. * * @return self */ @@ -3446,7 +3446,7 @@ public function getCampaign() /** * Sets campaign * - * @param string $campaign The GUID of the marketing campaign this Blog Post is a part of. + * @param string $campaign The GUID of the marketing campaign the post is associated with. * * @return self */ @@ -3635,7 +3635,7 @@ public function getTagIds() /** * Sets tag_ids * - * @param int[] $tag_ids List of IDs for the tags associated with this Blog Post. + * @param int[] $tag_ids The IDs of the tags associated with this post. * * @return self */ @@ -3807,7 +3807,7 @@ public function getUseFeaturedImage() /** * Sets use_featured_image * - * @param bool $use_featured_image Boolean to determine if this post should use a featuredImage. + * @param bool $use_featured_image Boolean to determine if this post should use a featured image. * * @return self */ @@ -3888,7 +3888,7 @@ public function getBlogAuthorId() /** * Sets blog_author_id * - * @param string $blog_author_id The ID of the Blog Author associated with this Blog Post. + * @param string $blog_author_id The ID of the blog author associated with this post. * * @return self */ @@ -3915,7 +3915,7 @@ public function getContentGroupId() /** * Sets content_group_id * - * @param string $content_group_id The ID of the parent Blog this Blog Post is associated with. + * @param string $content_group_id The ID of the post's parent blog. * * @return self */ @@ -4249,7 +4249,7 @@ public function getCategoryId() /** * Sets category_id * - * @param int $category_id ID of the type of object this is. + * @param int $category_id ID of the object type. * * @return self */ From 310e538e908dff22a5f4726ce12e814e7cfd65fd Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 10 Apr 2025 18:36:14 +0300 Subject: [PATCH 2/2] Update CMS Blog Posts discovery --- lib/Discovery/Cms/Blogs/BlogPosts/Discovery.php | 8 ++++++-- .../spec/Discovery/Cms/Blogs/BlogPosts/DiscoverySpec.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Discovery/Cms/Blogs/BlogPosts/Discovery.php b/lib/Discovery/Cms/Blogs/BlogPosts/Discovery.php index 6ab1555f7..5f97ddb5b 100644 --- a/lib/Discovery/Cms/Blogs/BlogPosts/Discovery.php +++ b/lib/Discovery/Cms/Blogs/BlogPosts/Discovery.php @@ -2,10 +2,14 @@ namespace HubSpot\Discovery\Cms\Blogs\BlogPosts; -use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BlogPostsApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BasicApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BatchApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\MultiLanguageApi; use HubSpot\Discovery\DiscoveryBase; /** - * @method BlogPostsApi blogPostsApi() + * @method BasicApi basicApi() + * @method BatchApi batchApi() + * @method MultiLanguageApi multiLanguageApi() */ class Discovery extends DiscoveryBase {} diff --git a/tests/spec/Discovery/Cms/Blogs/BlogPosts/DiscoverySpec.php b/tests/spec/Discovery/Cms/Blogs/BlogPosts/DiscoverySpec.php index 82ff245ca..9dcdf7aa1 100644 --- a/tests/spec/Discovery/Cms/Blogs/BlogPosts/DiscoverySpec.php +++ b/tests/spec/Discovery/Cms/Blogs/BlogPosts/DiscoverySpec.php @@ -3,7 +3,9 @@ namespace spec\HubSpot\Discovery\Cms\Blogs\BlogPosts; use GuzzleHttp\Client; -use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BlogPostsApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BasicApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\BatchApi; +use HubSpot\Client\Cms\Blogs\BlogPosts\Api\MultiLanguageApi; use HubSpot\Config; use HubSpot\Discovery\Cms\Blogs\BlogPosts\Discovery; use PhpSpec\ObjectBehavior; @@ -22,6 +24,8 @@ public function it_is_initializable() public function it_creates_clients() { - $this->blogPostsApi()->shouldHaveType(BlogPostsApi::class); + $this->basicApi()->shouldHaveType(BasicApi::class); + $this->batchApi()->shouldHaveType(BatchApi::class); + $this->multiLanguageApi()->shouldHaveType(MultiLanguageApi::class); } }