From c6a723d6719ba572c94db6636f0c602fbcb2bad2 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 4 May 2021 19:18:33 +0400 Subject: [PATCH 1/3] src(ApiClient): change endpoint in applyTemplatePresetOnProject. --- src/ApiClient.php | 50 ++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/ApiClient.php b/src/ApiClient.php index f34db76..273b08e 100644 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -45,9 +45,6 @@ class ApiClient const DELETE_PROJECT_VIDEOS_API_PATH_PREFIX = '/api/v1'; const DELETE_PROJECT_VIDEOS_API_PATH = self::DELETE_PROJECT_VIDEOS_API_PATH_PREFIX . '/projects/%d/videos/%d'; - const APPLY_TEMPLATE_PRESET_PROJECT_API_PATH_PREFIX = '/api/v1'; - const APPLY_TEMPLATE_PRESET_PROJECT_API_PATH = self::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH_PREFIX . '/projects/%d/apply-template-preset'; - const RENDER_PROJECT_API_PATH_PREFIX = '/api/v1'; const RENDER_PROJECT_API_PATH = self::RENDER_PROJECT_API_PATH_PREFIX . '/projects/%d/render'; @@ -353,49 +350,48 @@ public function deleteSpecificProjectVideos(int $projectId, int $quality = null) /** * @param int $projectId - * @param int $templatePresetId + * @param int $templateId + * @param int $presetId * @return int * @throws GuzzleException */ - public function applyTemplatePresetOnProject(int $projectId, int $templatePresetId): int + public function applyTemplatePresetOnProject(int $projectId, int $templateId, int $presetId): int { - $endpoint = self::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH; - - $applyTemplatePresetOnProjectApiPath = sprintf( - self::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH, - $projectId - ); - $uri = self::API_ENDPOINT . $applyTemplatePresetOnProjectApiPath; - - $postData = [ - 'presetId' => $templatePresetId, + $endpoint = self::TRIAL_PROJECT_API_PATH; + $uri = self::API_ENDPOINT . self::TRIAL_PROJECT_API_PATH; + + $queryParams = [ + 'templateId' => $templateId, + 'presetId' => $presetId ]; - + + $queryString = http_build_query($queryParams); + $uri .= '?' . $queryString; + $options = [ - 'method' => 'POST', + 'method' => 'GET', 'headers' => [ 'Accept' => 'application/json', 'User-Agent' => self::USER_AGENT, ], 'endpoint' => $endpoint, 'uri' => $uri, - 'json' => $postData, ]; - - $options = $this->setAuthorization($options); - - $response = $this->httpClient->request( + + $httpClient = new Client(); + + $response = $httpClient->request( $options['method'], $options['uri'], $options ); + + $json = $response->getBody()->getContents(); - $jsonResponse = $response->getBody()->getContents(); - $arrayResponse = \GuzzleHttp\json_decode($jsonResponse, true); - - $data = $arrayResponse['data']; - $projectId = intval($data['projectId']); + $projectData = new ProjectData(); + $projectData->exchangeJson($json); + $projectId = $this->updateProjectData($projectId, $projectData); return $projectId; } From b5d04f8da8e3d89e7fcbc54a8e0e49b912fff325 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 4 May 2021 19:20:02 +0400 Subject: [PATCH 2/3] examples(projects): refactor apply-template-preset example. --- examples/projects/apply-template-preset-on-the-project.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/projects/apply-template-preset-on-the-project.php b/examples/projects/apply-template-preset-on-the-project.php index 8c70f27..549874a 100644 --- a/examples/projects/apply-template-preset-on-the-project.php +++ b/examples/projects/apply-template-preset-on-the-project.php @@ -7,9 +7,10 @@ 'your-client-id' ); -$projectId = $renderforestClient->applyTemplatePresetOnProject( - 16297523, - 294 +$projectData = $renderforestClient->applyTemplatePresetOnProject( + 15990207, + 701, + 3 ); echo 'Project ID - ' . $projectId . PHP_EOL; From 446ad6551cb23091bf0555fccf2e3101bfce8bf9 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 4 May 2021 19:20:26 +0400 Subject: [PATCH 3/3] release 0.5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a996cd8..09e20a8 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "renderforest/sdk-php", "description": "Renderforest SDK for PHP", - "version": "0.5.4", + "version": "0.5.5", "homepage": "https://github.com/renderforest/renderforest-sdk-php", "keywords": [ "animation maker",