|
3 | 3 | namespace Renderforest; |
4 | 4 |
|
5 | 5 | use GuzzleHttp\Client; |
| 6 | +use GuzzleHttp\Exception\GuzzleException; |
6 | 7 | use Renderforest\Font\Collection\FontCollection; |
7 | 8 | use Renderforest\Project\Collection\ProjectCollection; |
8 | 9 | use Renderforest\Project\Project; |
@@ -161,7 +162,7 @@ public function updateProjectData( |
161 | 162 | /** |
162 | 163 | * @param int $templateId |
163 | 164 | * @return int |
164 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 165 | + * @throws GuzzleException |
165 | 166 | */ |
166 | 167 | public function addProject(int $templateId): int |
167 | 168 | { |
@@ -202,7 +203,7 @@ public function addProject(int $templateId): int |
202 | 203 | * @param int $projectId |
203 | 204 | * @param string|null $customTitle |
204 | 205 | * @return int |
205 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 206 | + * @throws GuzzleException |
206 | 207 | */ |
207 | 208 | public function updateProject( |
208 | 209 | int $projectId, |
@@ -248,7 +249,7 @@ public function updateProject( |
248 | 249 | /** |
249 | 250 | * @param int $projectId |
250 | 251 | * @return int |
251 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 252 | + * @throws GuzzleException |
252 | 253 | */ |
253 | 254 | public function deleteSpecificProject(int $projectId): int |
254 | 255 | { |
@@ -286,7 +287,7 @@ public function deleteSpecificProject(int $projectId): int |
286 | 287 | * @param int $projectId |
287 | 288 | * @param int|null $quality |
288 | 289 | * @return int |
289 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 290 | + * @throws GuzzleException |
290 | 291 | */ |
291 | 292 | public function deleteSpecificProjectVideos(int $projectId, int $quality = null): int |
292 | 293 | { |
@@ -334,7 +335,7 @@ public function deleteSpecificProjectVideos(int $projectId, int $quality = null) |
334 | 335 | * @param int $projectId |
335 | 336 | * @param int $templatePresetId |
336 | 337 | * @return int |
337 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 338 | + * @throws GuzzleException |
338 | 339 | */ |
339 | 340 | public function applyTemplatePresetOnProject(int $projectId, int $templatePresetId): int |
340 | 341 | { |
@@ -381,7 +382,7 @@ public function applyTemplatePresetOnProject(int $projectId, int $templatePreset |
381 | 382 | /** |
382 | 383 | * @param int $projectId |
383 | 384 | * @return int |
384 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 385 | + * @throws GuzzleException |
385 | 386 | */ |
386 | 387 | public function duplicateProject(int $projectId): int |
387 | 388 | { |
@@ -425,7 +426,7 @@ public function duplicateProject(int $projectId): int |
425 | 426 | * @param int $quality |
426 | 427 | * @param string|null $watermarkImageUrl |
427 | 428 | * @return int |
428 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 429 | + * @throws GuzzleException |
429 | 430 | */ |
430 | 431 | public function renderProject( |
431 | 432 | int $projectId, |
@@ -481,7 +482,7 @@ public function renderProject( |
481 | 482 | * |
482 | 483 | * @param string|null $languageIsoCode |
483 | 484 | * @return CategoryCollection |
484 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 485 | + * @throws GuzzleException |
485 | 486 | */ |
486 | 487 | public static function getTemplatesCategories(string $languageIsoCode = null): CategoryCollection |
487 | 488 | { |
@@ -526,7 +527,7 @@ public static function getTemplatesCategories(string $languageIsoCode = null): C |
526 | 527 | /** |
527 | 528 | * @param int $templateId |
528 | 529 | * @return CustomColorCollection |
529 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 530 | + * @throws GuzzleException |
530 | 531 | */ |
531 | 532 | public static function getTemplateRecommendedCustomColors(int $templateId): CustomColorCollection |
532 | 533 | { |
@@ -567,7 +568,7 @@ public static function getTemplateRecommendedCustomColors(int $templateId): Cust |
567 | 568 | /** |
568 | 569 | * @param int $templateId |
569 | 570 | * @return TemplatePresetCollection |
570 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 571 | + * @throws GuzzleException |
571 | 572 | */ |
572 | 573 | public static function getTemplatePresets(int $templateId): TemplatePresetCollection |
573 | 574 | { |
@@ -608,7 +609,7 @@ public static function getTemplatePresets(int $templateId): TemplatePresetCollec |
608 | 609 | /** |
609 | 610 | * @param int $templateId |
610 | 611 | * @return TemplateTheme |
611 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 612 | + * @throws GuzzleException |
612 | 613 | */ |
613 | 614 | public static function getTemplateTheme(int $templateId): TemplateTheme |
614 | 615 | { |
@@ -649,7 +650,7 @@ public static function getTemplateTheme(int $templateId): TemplateTheme |
649 | 650 | /** |
650 | 651 | * @param int $templateId |
651 | 652 | * @return PluggableScreensGroupCollection |
652 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 653 | + * @throws GuzzleException |
653 | 654 | */ |
654 | 655 | public static function getTemplatePluggableScreens(int $templateId): PluggableScreensGroupCollection |
655 | 656 | { |
@@ -690,7 +691,7 @@ public static function getTemplatePluggableScreens(int $templateId): PluggableSc |
690 | 691 | /** |
691 | 692 | * @param int $templateId |
692 | 693 | * @return TemplateTransitions |
693 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 694 | + * @throws GuzzleException |
694 | 695 | */ |
695 | 696 | public static function getTemplateTransitions(int $templateId): TemplateTransitions |
696 | 697 | { |
@@ -731,7 +732,7 @@ public static function getTemplateTransitions(int $templateId): TemplateTransiti |
731 | 732 | /** |
732 | 733 | * @param int $templateId |
733 | 734 | * @return ColorPresetCollection |
734 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 735 | + * @throws GuzzleException |
735 | 736 | */ |
736 | 737 | public static function getTemplateColorPresets(int $templateId): ColorPresetCollection |
737 | 738 | { |
@@ -770,17 +771,45 @@ public static function getTemplateColorPresets(int $templateId): ColorPresetColl |
770 | 771 | } |
771 | 772 |
|
772 | 773 | /** |
| 774 | + * @param int|null $categoryId |
| 775 | + * @param bool|null $isEqualizer |
| 776 | + * @param int|null $limit |
| 777 | + * @param int|null $offset |
773 | 778 | * @return TemplateCollection |
774 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 779 | + * @throws GuzzleException |
775 | 780 | */ |
776 | | - public static function getAllTemplates(): TemplateCollection |
777 | | - { |
778 | | - // @todo query params |
779 | | - // ?categoryId=3&equalizer=false&limit=4&offset=10 |
| 781 | + public static function getAllTemplates( |
| 782 | + ?int $categoryId = null, |
| 783 | + ?bool $isEqualizer = null, |
| 784 | + ?int $limit = null, |
| 785 | + ?int $offset = null |
| 786 | + ): TemplateCollection { |
| 787 | + $queryParams = []; |
| 788 | + if (false === is_null($categoryId)) { |
| 789 | + $queryParams['categoryId'] = $categoryId; |
| 790 | + } |
| 791 | + |
| 792 | + if (false === is_null($isEqualizer)) { |
| 793 | + $queryParams['equalizer'] = $isEqualizer ? 'true' : 'false'; |
| 794 | + } |
| 795 | + |
| 796 | + if (false === is_null($limit)) { |
| 797 | + $queryParams['limit'] = $limit; |
| 798 | + } |
| 799 | + |
| 800 | + if (false === is_null($offset)) { |
| 801 | + $queryParams['offset'] = $offset; |
| 802 | + } |
780 | 803 |
|
781 | 804 | $endpoint = self::TEMPLATES_API_PATH_PREFIX; |
782 | 805 | $uri = self::API_ENDPOINT . self::TEMPLATES_API_PATH; |
783 | 806 |
|
| 807 | + if (count($queryParams)) { |
| 808 | + $queryString = http_build_query($queryParams); |
| 809 | + |
| 810 | + $uri = $uri . '?' . $queryString; |
| 811 | + } |
| 812 | + |
784 | 813 | $options = [ |
785 | 814 | 'method' => 'GET', |
786 | 815 | 'headers' => [ |
@@ -811,7 +840,7 @@ public static function getAllTemplates(): TemplateCollection |
811 | 840 | * @param int $templateId |
812 | 841 | * @param string|null $languageIsoCode |
813 | 842 | * @return TemplateExtended |
814 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 843 | + * @throws GuzzleException |
815 | 844 | */ |
816 | 845 | public static function getTemplate( |
817 | 846 | int $templateId, |
@@ -858,7 +887,7 @@ public static function getTemplate( |
858 | 887 |
|
859 | 888 | /** |
860 | 889 | * @return User |
861 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 890 | + * @throws GuzzleException |
862 | 891 | */ |
863 | 892 | public function getCurrentUser(): User |
864 | 893 | { |
@@ -894,7 +923,7 @@ public function getCurrentUser(): User |
894 | 923 | /** |
895 | 924 | * @param int $templateId |
896 | 925 | * @return FontCollection |
897 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 926 | + * @throws GuzzleException |
898 | 927 | */ |
899 | 928 | public function getTemplateAvailableFonts(int $templateId): FontCollection |
900 | 929 | { |
@@ -937,7 +966,7 @@ public function getTemplateAvailableFonts(int $templateId): FontCollection |
937 | 966 | /** |
938 | 967 | * @param int $duration |
939 | 968 | * @return SoundCollection |
940 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 969 | + * @throws GuzzleException |
941 | 970 | */ |
942 | 971 | public function getAllSounds(int $duration = null): SoundCollection |
943 | 972 | { |
@@ -982,7 +1011,7 @@ public function getAllSounds(int $duration = null): SoundCollection |
982 | 1011 | /** |
983 | 1012 | * @param int $duration |
984 | 1013 | * @return SoundCollection |
985 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1014 | + * @throws GuzzleException |
986 | 1015 | */ |
987 | 1016 | public static function getCompanySoundsLimited(int $duration = null): SoundCollection |
988 | 1017 | { |
@@ -1027,7 +1056,7 @@ public static function getCompanySoundsLimited(int $duration = null): SoundColle |
1027 | 1056 | /** |
1028 | 1057 | * @param int $duration |
1029 | 1058 | * @return SoundCollection |
1030 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1059 | + * @throws GuzzleException |
1031 | 1060 | */ |
1032 | 1061 | public function getCompanySounds(int $duration = null): SoundCollection |
1033 | 1062 | { |
@@ -1072,7 +1101,7 @@ public function getCompanySounds(int $duration = null): SoundCollection |
1072 | 1101 | /** |
1073 | 1102 | * @param int $duration |
1074 | 1103 | * @return SoundCollection |
1075 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1104 | + * @throws GuzzleException |
1076 | 1105 | */ |
1077 | 1106 | public static function getRecommendedSoundsLimited(int $templateId, int $duration): SoundCollection |
1078 | 1107 | { |
@@ -1116,7 +1145,7 @@ public static function getRecommendedSoundsLimited(int $templateId, int $duratio |
1116 | 1145 | /** |
1117 | 1146 | * @param int $duration |
1118 | 1147 | * @return SoundCollection |
1119 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1148 | + * @throws GuzzleException |
1120 | 1149 | */ |
1121 | 1150 | public function getRecommendedSounds(int $templateId, int $duration): SoundCollection |
1122 | 1151 | { |
@@ -1160,7 +1189,7 @@ public function getRecommendedSounds(int $templateId, int $duration): SoundColle |
1160 | 1189 | /** |
1161 | 1190 | * @param SupportTicket $supportTicket |
1162 | 1191 | * @return SupportTicketResponse |
1163 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1192 | + * @throws GuzzleException |
1164 | 1193 | */ |
1165 | 1194 | public function createSupportTicket(SupportTicket $supportTicket): SupportTicketResponse |
1166 | 1195 | { |
@@ -1197,7 +1226,7 @@ public function createSupportTicket(SupportTicket $supportTicket): SupportTicket |
1197 | 1226 | /** |
1198 | 1227 | * @param int $projectId |
1199 | 1228 | * @return ProjectData |
1200 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1229 | + * @throws GuzzleException |
1201 | 1230 | */ |
1202 | 1231 | public function getProjectData(int $projectId): ProjectData |
1203 | 1232 | { |
@@ -1233,7 +1262,7 @@ public function getProjectData(int $projectId): ProjectData |
1233 | 1262 | /** |
1234 | 1263 | * @param ProjectData $projectData |
1235 | 1264 | * @return str |
1236 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1265 | + * @throws GuzzleException |
1237 | 1266 | */ |
1238 | 1267 | public function getScreenSnapshot(ProjectData $projectData): string { |
1239 | 1268 | $endpoint = self::PREVIEW_API_PATH; |
@@ -1271,7 +1300,7 @@ public function getScreenSnapshot(ProjectData $projectData): string { |
1271 | 1300 | /** |
1272 | 1301 | * @param int $templateId |
1273 | 1302 | * @return ProjectData |
1274 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1303 | + * @throws GuzzleException |
1275 | 1304 | */ |
1276 | 1305 | public static function getTrialProject(int $templateId): ProjectData |
1277 | 1306 | { |
@@ -1319,7 +1348,7 @@ public static function getTrialProject(int $templateId): ProjectData |
1319 | 1348 | * @param string $orderBy |
1320 | 1349 | * @param string|null $search |
1321 | 1350 | * @return ProjectCollection |
1322 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1351 | + * @throws GuzzleException |
1323 | 1352 | */ |
1324 | 1353 | public function getAllProjects( |
1325 | 1354 | int $limit = null, |
@@ -1385,7 +1414,7 @@ public function getAllProjects( |
1385 | 1414 | /** |
1386 | 1415 | * @param int $projectId |
1387 | 1416 | * @return Project |
1388 | | - * @throws \GuzzleHttp\Exception\GuzzleException |
| 1417 | + * @throws GuzzleException |
1389 | 1418 | */ |
1390 | 1419 | public function getProject(int $projectId): Project |
1391 | 1420 | { |
|
0 commit comments