VoximplantApi
Voximplant HTTP API wraper http://voximplant.com/docs/references/httpapi/
Installation
Add this line to your application's Gemfile:
gem 'voximplant_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install voximplant_api
Usage
client = VoximplantApi::Client.new account_id: 123, api_key: 'apikey-trololo'
client.get_account_info # request command "GetAccountInfo"
client.get_phone_number_categories(country_code: 'ru')
=> {"result"=>
[{"country_code"=>"RU",
"can_list_phone_numbers"=>true,
"phone_categories"=>
[{"phone_installation_price"=>0.0, "phone_period"=>"0-1-0 0:0:0", "phone_category_name"=>"GEOGRAPHIC", "country_has_states"=>false, "phone_price"=>300.0},
{"phone_installation_price"=>0.0, "phone_period"=>"0-1-0 0:0:0", "phone_category_name"=>"MOBILE", "country_has_states"=>false, "phone_price"=>300.0},
{"phone_installation_price"=>0.0, "phone_period"=>"0-1-0 0:0:0", "phone_category_name"=>"MOSCOW495", "country_has_states"=>false, "phone_price"=>500.0},
{"phone_installation_price"=>3000.0, "phone_period"=>"0-1-0 0:0:0", "phone_category_name"=>"TOLLFREE", "country_has_states"=>false, "phone_price"=>1500.0}],
"phone_prefix"=>"7"}],
"count"=>1}
Pagination and each
Just add 'each_' prefix to method
client.each_get_transaction_history(from_date: Time.now - 1592000).to_a
#or
client.each_get_transaction_history(from_date: Time.now - 1592000) do |obj|
# do something
end
Errors
begin
client.get_account_info
rescue VoximplantApi::Error => e
puts e
end
begin
client.not_existing_method
rescue NoMethodError => e
puts e
end
Contributing
- Fork it ( https://github.com/[my-github-username]/voximplant_api/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request