Sha256: a01836f463baca790df46137282ba5a97ffb6cc750afc48e43cecb578005ea9e

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

$:.unshift(File.expand_path(File.join(File.dirname(__FILE__),"..", "lib")))
require 'ctm'

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.each do|num|
  puts "#{num.friendly_name} -> #{num.phone_number}"
end
number_to_buy = availble_numbers.first

# look for local numbers
availble_numbers = account.numbers.search("US", :area_code => "410")
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}"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ctm-0.5.0 examples/buy_numbers.rb
ctm-0.4.4 examples/buy_numbers.rb
ctm-0.4.2 examples/buy_numbers.rb