Skip to content

Commit e5e456b

Browse files
authored
fix: bug fix (#770)
* chore: URL query percent encoded * chore: URL query percent encoded * chore: URL query percent encoded * chore: URL query percent encoded * chore: URL query percent encoded
1 parent 02504d9 commit e5e456b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/twilio-ruby/base/client_base.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@ def initialize(username = nil, password = nil, account_sid = nil, region = nil,
2727
@username = username || Twilio.account_sid
2828
@password = password || Twilio.auth_token
2929
@region = region || Twilio.region
30-
if (region.nil? && !Twilio.edge.nil?) || (!region.nil? && Twilio.edge.nil?)
31-
# rubocop:disable Layout/LineLength
32-
warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com;otherwise use product.twilio.com.'
33-
end
3430
if Twilio.edge
3531
@edge = Twilio.edge
3632
elsif @region && @@region_mappings[region]
3733
warn '[DEPRECATION] Setting default `Edge` for the provided `region`.'
38-
# rubocop:enable Layout/LineLength
3934
@edge = @@region_mappings[region]
4035
end
4136
@account_sid = account_sid || @username
@@ -101,6 +96,11 @@ def request(host, port, method, uri, params = {}, data = {}, headers = {}, auth
10196
##
10297
# Build the final request uri
10398
def build_uri(uri)
99+
if (@region.nil? && !@edge.nil?) || (!@region.nil? && @edge.nil?)
100+
# rubocop:disable Layout/LineLength
101+
warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com;otherwise use product.twilio.com.'
102+
# rubocop:enable Layout/LineLength
103+
end
104104
if @edge.nil? && @region && @@region_mappings[@region]
105105
warn '[DEPRECATION] Setting default `Edge` for the provided `region`.'
106106
@edge = @@region_mappings[@region]

spec/rest/client_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
expect(@client.edge).to eq('ashburn')
3232
end
3333

34-
it 'catches warning when setting region' do
34+
it 'catches warning when setting region in constructor' do
3535
original_stderr = $stderr
3636
$stderr = StringIO.new
3737
begin
@@ -46,6 +46,22 @@
4646
end
4747
end
4848

49+
it 'catches warning when setting region' do
50+
original_stderr = $stderr
51+
$stderr = StringIO.new
52+
begin
53+
@client = Twilio::REST::Client.new('myUser', 'myPassword', 'someSid')
54+
@client.region = 'myRegion'
55+
warn '[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.'
56+
warn '[DEPRECATION] Setting default `Edge` for the provided `region`.'
57+
warnings = $stderr.string
58+
expect(warnings).to include('[DEPRECATION] For regional processing, DNS is of format product.<edge>.<region>.twilio.com; otherwise use product.twilio.com.')
59+
expect(warnings).to include('[DEPRECATION] Setting default `Edge` for the provided `region`.')
60+
ensure
61+
$stderr = original_stderr
62+
end
63+
end
64+
4965
it 'catches warning when setting edge' do
5066
Twilio.configure do |config|
5167
config.account_sid = 'someSid'

0 commit comments

Comments
 (0)