Skip to content

Commit 563dc04

Browse files
committed
add region setting
1 parent 3db1163 commit 563dc04

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,22 @@ $url = $cloudConvert->signedUrlBuilder()->createFromJob($signedUrlBase, $signing
204204
```
205205

206206

207+
208+
Setting a Region
209+
-----------------
210+
211+
By default, the region in your [account settings](https://cloudconvert.com/dashboard/region) is used. Alternatively, you can set a fixed region:
212+
213+
```php
214+
// Pass the region to the constructor
215+
$cloudconvert = new CloudConvert([
216+
'api_key' => 'API_KEY',
217+
'sandbox' => false,
218+
'region' => 'us-east'
219+
]);
220+
```
221+
222+
207223
Unit Tests
208224
-----------------
209225

src/CloudConvert.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function configureOptions(OptionsResolver $resolver): void
5959
$resolver->setDefined('http_client');
6060
$resolver->setAllowedTypes('http_client', [ClientInterface::class]);
6161

62+
$resolver->setDefined('region');
63+
$resolver->setAllowedTypes('region', 'string');
64+
6265
}
6366

6467

src/Transport/HttpTransport.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,21 @@ protected function createHttpClientInstance(): PluginClient
6565
*/
6666
public function getBaseUri(): string
6767
{
68-
return $this->options['sandbox'] ? 'https://api.sandbox.cloudconvert.com/v2' : 'https://api.cloudconvert.com/v2';
68+
if ($this->options['sandbox']) {
69+
return 'https://api.sandbox.cloudconvert.com/v2';
70+
}
71+
return isset($this->options['region']) ? 'https://' . $this->options['region'] . '.api.cloudconvert.com/v2' : 'https://api.cloudconvert.com/v2';
6972
}
7073

7174
/**
7275
* @return string
7376
*/
7477
public function getSyncBaseUri(): string
7578
{
76-
return $this->options['sandbox'] ? 'https://sync.api.sandbox.cloudconvert.com/v2' : 'https://sync.api.cloudconvert.com/v2';
79+
if ($this->options['sandbox']) {
80+
return 'https://sync.api.sandbox.cloudconvert.com/v2';
81+
}
82+
return isset($this->options['region']) ? 'https://' . $this->options['region'] . '.sync.api.cloudconvert.com/v2' : 'https://sync.api.cloudconvert.com/v2';
7783
}
7884

7985
/**

0 commit comments

Comments
 (0)