Skip to content

Commit 1126073

Browse files
committed
fix: Regional API domain processing
1 parent 99123d9 commit 1126073

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

lib/twilio-ruby/base/client_base.rb

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ class ClientBase
44
# rubocop:disable Style/ClassVars
55
@@default_region = 'us1'
66
# rubocop:enable Style/ClassVars
7-
8-
attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region, :edge, :logger,
7+
@@region_mappings = {
8+
"au1" => "sydney",
9+
"br1" => "sao-paulo",
10+
"de1" => "frankfurt",
11+
"ie1" => "dublin",
12+
"jp1" => "tokyo",
13+
"jp2" => "osaka",
14+
"sg1" => "singapore",
15+
"us1" => "ashburn",
16+
"us2" => "umatilla"
17+
}
18+
attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region , :logger,
919
:user_agent_extensions, :credentials
1020

1121
# rubocop:disable Metrics/ParameterLists
@@ -14,7 +24,7 @@ def initialize(username = nil, password = nil, account_sid = nil, region = nil,
1424
@username = username || Twilio.account_sid
1525
@password = password || Twilio.auth_token
1626
@region = region || Twilio.region
17-
@edge = Twilio.edge
27+
@edge = !region.nil? ? @@region_mappings[region] : nil
1828
@account_sid = account_sid || @username
1929
@auth_token = @password
2030
@auth = [@username, @password]
@@ -23,6 +33,16 @@ def initialize(username = nil, password = nil, account_sid = nil, region = nil,
2333
@user_agent_extensions = user_agent_extensions || []
2434
end
2535

36+
def edge=(value)
37+
warn "[DEPRECATION] `edge` is deprecated and will be removed in a future version. Use `region` instead."
38+
@edge = value
39+
end
40+
41+
def edge
42+
warn "[DEPRECATION] `edge` is deprecated and will be removed in a future version. Use `region` instead."
43+
@edge
44+
end
45+
2646
def credential_provider(credential_provider = nil)
2747
@credentials = credential_provider
2848
self

0 commit comments

Comments
 (0)