<commit_before>require 'rubygems'
require 'textmagic-ruby'
require './auth_helper'

puts ' *** Running number examples *** '
# This is the preferred method to pass your API credentials
# set the environment variables TEXTMAGIC_USERNAME and TEXTMAGIC_API_KEY in your shell
username, api_key = tm_credentials

# If you must, you can uncomment and assign the credential variables here
# username = 'your_text_magic_username'
# api_key = 'your_text_magic_api_key'

interval = 0.5

client = Textmagic::REST::Client.new username, api_key

sleep interval
available = client.numbers.available({:country => 'US'})

puts available.respond_to? :numbers
puts available.numbers.kind_of? Array
puts !available.numbers.empty?
puts available.numbers.length > 0
puts available.respond_to? :price
puts available.price > 0

sleep interval
user = client.users.get

puts user.instance_of? Textmagic::REST::User
puts user.respond_to? :first_name
puts user.respond_to? :last_name
puts user.respond_to? :company
puts user.respond_to? :timezone
puts user.timezone.kind_of? Hash
puts user.respond_to? :id
puts user.respond_to? :username
puts user.respond_to? :status
puts user.respond_to? :balance
puts user.respond_to? :currency
puts user.currency.kind_of? Hash
puts user.respond_to? :subaccount_type

# sleep interval
# number = client.numbers.buy({:userId => user.id, :country => 'US', :phone => available.numbers.first})
#
# puts number.instance_of? Textmagic::REST::Number
# puts number.respond_to? :id
# puts number.respond_to? :href

# sleep interval
# number = client.numbers.get number.id
#
# puts number.respond_to? :id
# puts number.respond_to? :user
# puts number.user.kind_of? Hash
# puts number.respond_to? :purchased_at
# puts number.respond_to? :expire_at
# puts number.respond_to? :phone
# puts number.respond_to? :country
# puts number.country.kind_of? Hash
# puts number.respond_to? :status

sleep interval
numbers = client.numbers.list()

puts numbers.respond_to? :page
puts numbers.respond_to? :limit
puts numbers.respond_to? :page_count
puts numbers.resources.length > 0
puts numbers.resources.first.instance_of? Textmagic::REST::Number

# sleep interval
# r = client.numbers.delete(number.id)
#
# puts r

puts ' *** Finish number examples *** '<commit_msg>Updated the numbers example<commit_after>require 'rubygems'
require 'textmagic-ruby'
require './auth_helper'

# This is the preferred method to pass your API credentials
# set the environment variables TEXTMAGIC_USERNAME and TEXTMAGIC_API_KEY in your shell
username, api_key = tm_credentials

# If you must, you can uncomment and assign the credential variables here
# username = 'your_text_magic_username'
# api_key = 'your_text_magic_api_key'

interval = 0.5

client = Textmagic::REST::Client.new username, api_key

sleep interval
available = client.numbers.available({:country => 'US'})

puts "The price for a number is #{available.price}"
puts 'The following numbers are available for purchase:'
available.numbers.each do |a|
  puts a
end

# NOTE: if you uncomment and run this code, it will purchase a new number for your TextMagic account
# You will still be charged for one month of usage even if you run the delete code below.
=begin
sleep interval
user = client.users.get

sleep interval
number = client.numbers.buy({:userId => user.id, :country => 'US', :phone => available.numbers.first})

sleep interval
number = client.numbers.get number.id
puts "The new phone number is #{number.phone}"
puts "The new number was purchased at: #{number.purchased_at}"
puts "It will expire at #{number.expire_at}"
puts "The country ISO code for this number: #{number.country}"
puts "The number's current status: #{number.status}"
=end

sleep interval
numbers = client.numbers.list()
puts "This account has a total of #{numbers.resources.length} numbers."

# Delete example
# sleep interval
# if client.numbers.delete(number.id)
#  puts "We just deleted the number #{number.phone}"
# end


{'fraction_non_alphanumeric': 0.10289634146341463, 'fraction_numerical': 0.0017784552845528454, 'mean_word_length': 5.454098360655737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7178012', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1218, 'n_words': 399}