File tree Expand file tree Collapse file tree
lib/twilio-ruby/rest/lookups Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class PhoneNumbers < Twilio::REST::NextGenListResource;
66 include Twilio ::REST ::Utils
77
88 def get ( number , query = { } )
9- full_path = "#{ @path } /#{ number } "
9+ full_path = "#{ @path } /#{ URI . encode ( number ) } "
1010 full_path << "?#{ url_encode ( twilify ( query ) ) } " if !query . empty?
1111 @instance_class . new full_path , @client
1212 end
Original file line number Diff line number Diff line change 55 client = Twilio ::REST ::LookupsClient . new 'otherSid' , 'otherToken'
66 expect ( client ) . to respond_to ( :phone_numbers )
77 end
8+
9+ it 'gets phone numbers without special encoding' do
10+ number = '+13123131434'
11+ client = Twilio ::REST ::LookupsClient . new 'otherSid' , 'otherToken'
12+ expect ( client ) . to receive ( :get ) . once
13+ . with ( '/v1/PhoneNumbers/+13123131434' )
14+ . and_return ( { phone_number : number } )
15+ phone_number = client . phone_numbers . get ( '+13123131434' ) . phone_number
16+ expect ( phone_number ) . to be ( number )
17+ end
18+
19+ it 'URI encodes phone number path parameters' do
20+ number = '+13123131434'
21+ client = Twilio ::REST ::LookupsClient . new 'otherSid' , 'otherToken'
22+ expect ( client ) . to receive ( :get ) . once
23+ . with ( '/v1/PhoneNumbers/+1%20312%20313%201434' )
24+ . and_return ( { phone_number : number } )
25+ phone_number = client . phone_numbers . get ( '+1 312 313 1434' ) . phone_number
26+ expect ( phone_number ) . to be ( number )
27+ end
828end
You can’t perform that action at this time.
0 commit comments