From 0862c459e1cd959cc2e8f38a48f3ac3f22427135 Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Thu, 22 Sep 2022 09:12:21 +0300 Subject: [PATCH 1/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a58947..ea9628a 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ ConvertApi::setApiSecret('your-api-secret'); ### File conversion Convert file to PDF example. All supported formats and options can be found -[here](https://www.convertapi.com). +[here](https://www.convertapi.com/conversions). ```php $result = ConvertApi::convert('pdf', ['File' => '/path/to/my_file.docx']); From 9dbe5c4365ca7225058eabb92477e046e4a62ea2 Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Thu, 25 May 2023 09:29:14 +0300 Subject: [PATCH 2/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea9628a..02f78a0 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ $result = ConvertApi::convert( #### Additional conversion parameters ConvertAPI accepts additional conversion parameters depending on selected formats. All conversion -parameters and explanations can be found [here](https://www.convertapi.com). +parameters and explanations can be found [here](https://www.convertapi.com/conversions). ```php $result = ConvertApi::convert( From 70fc9ffadb8e188c45b8d5238fb364373c93a9f2 Mon Sep 17 00:00:00 2001 From: Jonas Jasas Date: Tue, 4 Jul 2023 13:51:29 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 02f78a0..7c75549 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,14 @@ $info = ConvertApi::getUser(); echo $info['SecondsLeft']; ``` +### Alternative domain + +Use `setApiBase` method to set alternative service domain. Dedicated to the region [domain list](https://www.convertapi.com/doc/servers-location). + +```php +ConvertApi::setApiBase('https://eu-v2.convertapi.com/'); +``` + ### More examples Find more advanced examples in the [examples/](https://github.com/ConvertAPI/convertapi-php/tree/master/examples) folder. From 71cc743e4b740d51862692b36688afb5400b203c Mon Sep 17 00:00:00 2001 From: laurynas-baltsoft <38224044+laurynas-baltsoft@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:03:38 +0300 Subject: [PATCH 4/5] Make converter param name case insensitive (#43) --- lib/ConvertApi/Task.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ConvertApi/Task.php b/lib/ConvertApi/Task.php index 6aa07e5..cd9b8d7 100644 --- a/lib/ConvertApi/Task.php +++ b/lib/ConvertApi/Task.php @@ -31,8 +31,9 @@ function run() } $fromFormat = $this->fromFormat ?: $this->detectFormat($params); - $converter = isset($params['converter']) ? "/converter/{$params['converter']}" : ''; - $path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converter; + $converter = $this->detectConverter($params); + $converterPath = $converter ? "/converter/{$converter}" : ''; + $path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converterPath; $response = ConvertApi::client()->post($path, $params, $readTimeout); @@ -91,4 +92,15 @@ private function detectFormat($params) return $detector->run(); } + + private function detectConverter($params) + { + $keys = array_keys($params); + + foreach ($keys as $key) + if (strtolower($key) == 'converter') + return $params[$key]; + + return; + } } From 72dc773a1c840e7e33ced8cece6e751a9d38ba1e Mon Sep 17 00:00:00 2001 From: laurynas-baltsoft <38224044+laurynas-baltsoft@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:30:59 +0300 Subject: [PATCH 5/5] Handle multiple file params (#44) --- lib/ConvertApi/Task.php | 6 +++--- tests/ConvertApi/ConvertApiTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/ConvertApi/Task.php b/lib/ConvertApi/Task.php index cd9b8d7..fca394e 100644 --- a/lib/ConvertApi/Task.php +++ b/lib/ConvertApi/Task.php @@ -46,12 +46,12 @@ private function normalizedParams() foreach ($this->params as $key => $val) { - switch($key) { - case 'File': + switch(true) { + case $key != 'StoreFile' && preg_match('/File$/', $key): $result[$key] = FileParam::build($val); break; - case 'Files': + case $key == 'Files': $result[$key] = $this->filesBatch($val); break; diff --git a/tests/ConvertApi/ConvertApiTest.php b/tests/ConvertApi/ConvertApiTest.php index 4429f40..3cb76f5 100644 --- a/tests/ConvertApi/ConvertApiTest.php +++ b/tests/ConvertApi/ConvertApiTest.php @@ -159,6 +159,18 @@ public function testChainedConversion() $this->assertEquals('test.zip', $result->getFile()->getFileName()); } + public function testCompare() + { + $params = [ + 'File' => 'examples/files/test.docx', + 'CompareFile' => 'examples/files/test.docx' + ]; + + $result = ConvertApi::convert('compare', $params); + + $this->assertEquals('test.docx', $result->getFile()->getFileName()); + } + public function testApiError() { $params = ['Url' => 'https://www.w3.org/TR/PNG/iso_8859-1.txt'];