@@ -45,9 +45,6 @@ class ApiClient
4545 const DELETE_PROJECT_VIDEOS_API_PATH_PREFIX = '/api/v1 ' ;
4646 const DELETE_PROJECT_VIDEOS_API_PATH = self ::DELETE_PROJECT_VIDEOS_API_PATH_PREFIX . '/projects/%d/videos/%d ' ;
4747
48- const APPLY_TEMPLATE_PRESET_PROJECT_API_PATH_PREFIX = '/api/v1 ' ;
49- const APPLY_TEMPLATE_PRESET_PROJECT_API_PATH = self ::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH_PREFIX . '/projects/%d/apply-template-preset ' ;
50-
5148 const RENDER_PROJECT_API_PATH_PREFIX = '/api/v1 ' ;
5249 const RENDER_PROJECT_API_PATH = self ::RENDER_PROJECT_API_PATH_PREFIX . '/projects/%d/render ' ;
5350
@@ -353,49 +350,48 @@ public function deleteSpecificProjectVideos(int $projectId, int $quality = null)
353350
354351 /**
355352 * @param int $projectId
356- * @param int $templatePresetId
353+ * @param int $templateId
354+ * @param int $presetId
357355 * @return int
358356 * @throws GuzzleException
359357 */
360- public function applyTemplatePresetOnProject (int $ projectId , int $ templatePresetId ): int
358+ public function applyTemplatePresetOnProject (int $ projectId , int $ templateId , int $ presetId ): int
361359 {
362- $ endpoint = self ::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH ;
363-
364- $ applyTemplatePresetOnProjectApiPath = sprintf (
365- self ::APPLY_TEMPLATE_PRESET_PROJECT_API_PATH ,
366- $ projectId
367- );
368- $ uri = self ::API_ENDPOINT . $ applyTemplatePresetOnProjectApiPath ;
369-
370- $ postData = [
371- 'presetId ' => $ templatePresetId ,
360+ $ endpoint = self ::TRIAL_PROJECT_API_PATH ;
361+ $ uri = self ::API_ENDPOINT . self ::TRIAL_PROJECT_API_PATH ;
362+
363+ $ queryParams = [
364+ 'templateId ' => $ templateId ,
365+ 'presetId ' => $ presetId
372366 ];
373-
367+
368+ $ queryString = http_build_query ($ queryParams );
369+ $ uri .= '? ' . $ queryString ;
370+
374371 $ options = [
375- 'method ' => 'POST ' ,
372+ 'method ' => 'GET ' ,
376373 'headers ' => [
377374 'Accept ' => 'application/json ' ,
378375 'User-Agent ' => self ::USER_AGENT ,
379376 ],
380377 'endpoint ' => $ endpoint ,
381378 'uri ' => $ uri ,
382- 'json ' => $ postData ,
383379 ];
384-
385- $ options = $ this -> setAuthorization ( $ options );
386-
387- $ response = $ this -> httpClient ->request (
380+
381+ $ httpClient = new Client ( );
382+
383+ $ response = $ httpClient ->request (
388384 $ options ['method ' ],
389385 $ options ['uri ' ],
390386 $ options
391387 );
388+
389+ $ json = $ response ->getBody ()->getContents ();
392390
393- $ jsonResponse = $ response ->getBody ()->getContents ();
394- $ arrayResponse = \GuzzleHttp \json_decode ($ jsonResponse , true );
395-
396- $ data = $ arrayResponse ['data ' ];
397- $ projectId = intval ($ data ['projectId ' ]);
391+ $ projectData = new ProjectData ();
392+ $ projectData ->exchangeJson ($ json );
398393
394+ $ projectId = $ this ->updateProjectData ($ projectId , $ projectData );
399395 return $ projectId ;
400396 }
401397
0 commit comments