examples/buy_numbers.rb in ctm-0.5.0 vs examples/buy_numbers.rb in ctm-0.5.1

- old
+ new

@@ -1,13 +1,17 @@ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__),"..", "lib"))) require 'ctm' +#$:.unshift(File.expand_path(File.join(File.dirname(__FILE__),"..", "examples"))) +#require 'dev' +puts "send authentication: #{ENV['CTM_TOKEN']}" + access_token = CTM::Auth.authenticate(ENV['CTM_TOKEN'], ENV['CTM_SECRET']) account = access_token.accounts.first # look for toll free numbers -availble_numbers = account.numbers.search("US", :area_code => "888", :searchby => "tollfree") +availble_numbers = account.numbers.search("US", :area_code => "844", :searchby => "tollfree") availble_numbers.each do|num| puts "#{num.friendly_name} -> #{num.phone_number}" end number_to_buy = availble_numbers.first @@ -16,7 +20,15 @@ availble_numbers.each do|num| puts "#{num.friendly_name} -> #{num.phone_number}" end number_to_buy = availble_numbers.first -number = account.numbers.buy("+15005550006") -puts "purchased: #{number.formatted} #{number.number}" +#number = account.numbers.buy("+15005550006") +#puts "purchased: #{number.formatted} #{number.number}" + + +# look for a UK local number +availble_numbers = account.numbers.search("GB", :area_code => "20", :searchby => "area") +availble_numbers.each do|num| + puts "#{num.friendly_name} -> #{num.phone_number}" +end +number_to_buy = availble_numbers.first