Permalink
Browse files

Merge pull request #13 from mattgoldman/master

Support added for Page and PageSize query params
  • Loading branch information...
2 parents da95b5c + 28f46e4 commit 81f532b573e0e6ac632b47793ffca841c9fb1655 @philm committed Apr 22, 2012
Showing with 10 additions and 3 deletions.
  1. +8 −1 lib/twilio/available_phone_numbers.rb
  2. +2 −2 spec/twilio/available_phone_numbers_spec.rb
@@ -22,7 +22,9 @@ def search(opts={})
:NearNumber => opts[:near_number],
:InLata => opts[:in_lata],
:InRateCenter => opts[:in_rate_center],
- :Distance => opts[:distance]
+ :Distance => opts[:distance],
+ :Page => opts[:page],
+ :PageSize => opts[:page_size]
}.reject {|k,v| v == nil} unless opts.empty?
Twilio.get("/AvailablePhoneNumbers/#{iso_country_code}/#{resource}", :query => params)
@@ -39,14 +41,19 @@ def search(opts={})
# :in_lata
# :in_rate_center
# :distance
+ # :page
+ # :page_size
def search_local(opts ={})
opts = {:resource => 'Local'}.merge(opts)
search(opts)
end
# The search_toll_free method searches for available toll-free numbers
# Search Options
+ # :area_code
# :contains
+ # :page
+ # :page_size
def search_toll_free(opts ={})
opts = {:resource => 'TollFree'}.merge(opts)
search(opts)
@@ -28,9 +28,9 @@
end
it "is searchable using multiple parameters" do
- response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?NearLatLong=37.806940%2C-122.270360&InRateCenter=OKLD0349T&NearNumber=15105551213&Distance=50&InRegion=CA&InLata=722&Contains=510555****')
+ response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?NearLatLong=37.806940%2C-122.270360&InRateCenter=OKLD0349T&NearNumber=15105551213&Distance=50&InRegion=CA&InLata=722&Contains=510555****&Page=2&PageSize=30')
- Twilio::AvailablePhoneNumbers.search_local(:in_region => 'CA', :contains => '510555****', :near_lat_long => '37.806940,-122.270360', :near_number => '15105551213', :in_lata => 722, :in_rate_center => 'OKLD0349T', :distance => 50).should == response
+ Twilio::AvailablePhoneNumbers.search_local(:in_region => 'CA', :contains => '510555****', :near_lat_long => '37.806940,-122.270360', :near_number => '15105551213', :in_lata => 722, :in_rate_center => 'OKLD0349T', :distance => 50, :page => 2, :page_size => 30).should == response
WebMock.should have_requested(:get, url)
end
end

0 comments on commit 81f532b

Please sign in to comment.