Skip to content

Commit f8b734f

Browse files
authored
Revert "fix: Regional API domain processing (#894)"
This reverts commit 21bb2ae.
1 parent 269db8e commit f8b734f

File tree

2 files changed

+2
-62
lines changed

2 files changed

+2
-62
lines changed

src/Twilio/Base/BaseClient.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function __construct(
6767
$this->edge = $this->getArg(null, self::ENV_EDGE);
6868
$this->logLevel = $this->getArg(null, self::ENV_LOG);
6969
$this->userAgentExtensions = $userAgentExtensions ?: [];
70+
7071
$this->invalidateOAuth();
7172
$this->setAccountSid($accountSid ?: $this->username);
7273

@@ -161,30 +162,6 @@ public function request(
161162
$authStrategy = $this->credentialProvider->toAuthStrategy();
162163
}
163164

164-
if( ($this->edge === null && $this->region !== null) || ($this->edge !== null && $this->region === null) )
165-
{
166-
trigger_error(' For regional processing, DNS is of format product.city.region.twilio.com; otherwise use product.twilio.com.', E_USER_DEPRECATED);
167-
}
168-
if ($this->edge === null && $this->region !== null) {
169-
$regionMap = [
170-
'au1' => 'sydney',
171-
'br1' => 'sao-paulo',
172-
'de1' => 'frankfurt',
173-
'ie1' => 'dublin',
174-
'jp1' => 'tokyo',
175-
'jp2' => 'osaka',
176-
'sg1' => 'singapore',
177-
'us1' => 'ashburn',
178-
'us2' => 'umatilla'
179-
];
180-
if (array_key_exists($this->region, $regionMap)) {
181-
trigger_error(' Setting default `Edge` for the provided `region`.', E_USER_DEPRECATED);
182-
$this->edge = $regionMap[$this->region];
183-
}
184-
if( $this->edge === null )
185-
$this->edge = '';
186-
}
187-
188165
if (!$authStrategy) {
189166
if (!$username) {
190167
throw new ConfigurationException('username is required');

tests/Twilio/Unit/Rest/ClientTest.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ public function testRegionInjectedWhenSet(): void {
128128
$network = new Holodeck();
129129
$client = new Client('username', 'password', null, 'ie1', $network);
130130
$client->request('POST', 'https://test.twilio.com/v1/Resources');
131-
// $this->expectException();
132-
$expected = new Request('POST', 'https://test.dublin.ie1.twilio.com/v1/Resources');
131+
$expected = new Request('POST', 'https://test.ie1.twilio.com/v1/Resources');
133132
$this->assertTrue($network->hasRequest($expected));
134133
}
135134

@@ -283,40 +282,4 @@ public function testUserAgentExtensionsWhenSet(): void {
283282
$this->assertEquals($userAgentExtensions,$expectedExtensions);
284283
}
285284

286-
287-
public function testEdgeIsSetFromRegionWhenEdgeIsNull(): void {
288-
$client = new Client('username', 'password', null, 'au1');
289-
$client->request('GET', 'https://api.twilio.com');
290-
$this->assertEquals('sydney', $client->getEdge());
291-
}
292-
293-
public function testEdgeIsSetFromRegionWhenRegionIsXyz(): void {
294-
// Create a mock of the CurlClient
295-
$mockHttpClient = $this->createMock(CurlClient::class);
296-
297-
// Define the expected behavior
298-
$mockHttpClient->expects($this->once())
299-
->method('request')
300-
->with('GET', 'https://api.xyz.twilio.com', [], [])
301-
->willReturn(new Response(200, 'Mocked response'));
302-
$client = new Client('username', 'password', null, 'xyz');
303-
$client->setHttpClient($mockHttpClient);
304-
$client->request('GET', 'https://api.twilio.com');
305-
$this->assertEquals('',$client->getEdge());
306-
$this->assertEquals('xyz', $client->getRegion());
307-
}
308-
309-
public function testEdgeRemainsWhenBothEdgeAndRegionAreSet(): void {
310-
$client = new Client('username', 'password', null, 'au1');
311-
$client->request('GET', 'https://api.twilio.com');
312-
$client->setEdge('custom-edge');
313-
$this->assertEquals('custom-edge', $client->getEdge());
314-
}
315-
316-
public function testEdgeRemainsWhenBothEdgeAndRegionAreSetInConstructor(): void {
317-
$client = new Client('username', 'password', null, 'au1', null, ['TWILIO_EDGE' => 'custom-edge']);
318-
$this->assertEquals('custom-edge', $client->getEdge());
319-
$this->assertEquals('au1', $client->getRegion());
320-
321-
}
322285
}

0 commit comments

Comments
 (0)