voxbone 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "savon"
4
+
5
+ group :development do
6
+ gem "rspec", "~> 2.3.0"
7
+ gem "yard", "~> 0.6.0"
8
+ gem "bundler", "~> 1.0.0"
9
+ gem "jeweler", "~> 1.5.2"
10
+ gem "rcov", ">= 0"
11
+ gem "bluecloth"
12
+ end
@@ -0,0 +1,47 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bluecloth (2.1.0)
5
+ builder (2.1.2)
6
+ crack (0.1.8)
7
+ diff-lcs (1.1.2)
8
+ git (1.2.5)
9
+ gyoku (0.3.1)
10
+ builder (>= 2.1.2)
11
+ httpi (0.9.0)
12
+ ntlm-http (>= 0.1.1)
13
+ rack
14
+ jeweler (1.5.2)
15
+ bundler (~> 1.0.0)
16
+ git (>= 1.2.5)
17
+ rake
18
+ ntlm-http (0.1.1)
19
+ rack (1.2.1)
20
+ rake (0.8.7)
21
+ rcov (0.9.9)
22
+ rspec (2.3.0)
23
+ rspec-core (~> 2.3.0)
24
+ rspec-expectations (~> 2.3.0)
25
+ rspec-mocks (~> 2.3.0)
26
+ rspec-core (2.3.1)
27
+ rspec-expectations (2.3.0)
28
+ diff-lcs (~> 1.1.2)
29
+ rspec-mocks (2.3.0)
30
+ savon (0.8.6)
31
+ builder (>= 2.1.2)
32
+ crack (~> 0.1.8)
33
+ gyoku (>= 0.3.0)
34
+ httpi (>= 0.7.8)
35
+ yard (0.6.4)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bluecloth
42
+ bundler (~> 1.0.0)
43
+ jeweler (~> 1.5.2)
44
+ rcov
45
+ rspec (~> 2.3.0)
46
+ savon
47
+ yard (~> 0.6.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jason Goecke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,99 @@
1
+ Voxbone
2
+ =======
3
+
4
+ Ruby gem for consuming the [Voxbone SOAP API](http://voxbone.com/APIGettingStarted.jsf).
5
+
6
+ Installation
7
+ ------------
8
+
9
+ gem install voxbone
10
+
11
+ Example
12
+ -------
13
+
14
+ [API Docs](http://jsgoecke.github.com/voxbone)
15
+
16
+ require 'rubygems'
17
+ require 'voxbone'
18
+ voxbone = Voxbone.new(:username => 'test',
19
+ :password => 'test')
20
+ voxbone.get_countries_list(:type => 'GEOGRAPHIC')
21
+
22
+ Returns (using awesome_print gem):
23
+
24
+ {
25
+ :get_countries_list_response => {
26
+ :array_of_countries => {
27
+ :country => [
28
+ [ 0] {
29
+ :country_name => "ARGENTINA",
30
+ :country_code => "54",
31
+ :country_id => "10",
32
+ :has_states => false,
33
+ :code_a2 => "AR"
34
+ },
35
+ [ 1] {
36
+ :country_name => "AUSTRALIA",
37
+ :country_code => "61",
38
+ :country_id => "13",
39
+ :has_states => false,
40
+ :code_a2 => "AU"
41
+ }
42
+ ]
43
+ },
44
+ :xmlns => "http://www.voxbone.com/VoxAPI"
45
+ }
46
+ }
47
+
48
+ Available Methods
49
+ -----------------
50
+
51
+ Full details of available methods [here](http://sourceforge.net/apps/mediawiki/voxbone-client/index.php?title=VoxAPI.Methods).
52
+
53
+ [ 0] :place_order_for_lock
54
+ [ 1] :remove_did_from_capacity_group
55
+ [ 2] :create_address_for_regulation
56
+ [ 3] :configure_dnis
57
+ [ 4] :configure_cpc
58
+ [ 5] :remove_di_ds_from_trunk
59
+ [ 6] :link_dids_to_address
60
+ [ 7] :get_purchase_info_data
61
+ [ 8] :get_trunk_list
62
+ [ 9] :map_did_to_capacity_group
63
+ [10] :get_order_status
64
+ [11] :cancel_did
65
+ [12] :get_regulation_address_list
66
+ [13] :get_did_group_purchase_lock
67
+ [14] :place_di_ds_on_trunk
68
+ [15] :configure_codecs
69
+ [16] :create_capacity_group
70
+ [17] :get_capacity_group_list
71
+ [18] :place_di_ds_order
72
+ [19] :get_di_ds_info
73
+ [20] :map_did
74
+ [21] :delete_capacity_group
75
+ [22] :get_features_list
76
+ [23] :configure_dtmf_mode
77
+ [24] :get_did_group_list
78
+ [25] :is_purchase_info_valid
79
+ [26] :purchase_tollfree_credit
80
+ [27] :get_did_group_pricing
81
+ [28] :get_pop_list
82
+ [29] :request_address_verification
83
+ [30] :limit_did_channels
84
+ [31] :get_states_list
85
+ [32] :configure_t38
86
+ [33] :delete_regulation_address
87
+ [34] :get_countries_list
88
+ [35] :get_did_group_info
89
+ [36] :update_capacity_group
90
+ [37] :get_tollfree_credit_package_list
91
+ [38] :map_did_checking_status
92
+ [39] :update_delivery
93
+ [40] :get_account_balance
94
+
95
+ Copyright
96
+ ---------
97
+
98
+ Copyright (c) 2011 Jason Goecke. See LICENSE.txt for
99
+ further details.
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "voxbone"
15
+ gem.homepage = "http://github.com/jsgoecke/voxbone"
16
+ gem.license = "MIT"
17
+ gem.summary = "Library for the Voxbone API"
18
+ gem.description = "Ruby library wrapping the Voxbone SOAP API"
19
+ gem.email = "jason@goecke.net"
20
+ gem.authors = ["Jason Goecke"]
21
+ gem.add_runtime_dependency 'savon'
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ require 'rspec/core'
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:spec) do |spec|
28
+ spec.pattern = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :default => :spec
37
+
38
+ require 'yard'
39
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'awesome_print'
3
+ require 'lib/voxbone'
4
+
5
+ voxbone = Voxbone.new(:username => 'test',
6
+ :password => 'test',
7
+ :base_uri => 'http://sandbox.voxbone.com/VoxAPI/services/VoxAPI?wsdl',
8
+ :log_level => :debug)
9
+
10
+ ap voxbone.get_countries_list(:type => 'GEOGRAPHIC')
@@ -0,0 +1,2 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+ %w(savon digest/sha1 voxbone/voxbone).each { |lib| require lib }
@@ -0,0 +1,106 @@
1
+ class Voxbone
2
+ attr_reader :methods
3
+
4
+ ##
5
+ # Instantiate a Voxbone object
6
+ #
7
+ # @param [required, Hash] params
8
+ # @option params [required, String] :username for your Voxbone account
9
+ # @option params [required, String] :password for your Voxbone password
10
+ # @option params [optional, String] :base_uri for using an alternative URI, such as the Voxbone sandbox
11
+ # @option params [optional, String] :log_level for changing the Savon log levels
12
+ # @return [Object] the instantiated Voxbone object
13
+ # @raise ArgumentError when the :username or :password is not present
14
+ # @example Instantiate a Voxbone object
15
+ # require 'rubygems'
16
+ # require 'voxbone'
17
+ # voxbone = Voxbone.new(:username => 'test',
18
+ # :password => 'test')
19
+ def initialize(params)
20
+ raise ArgumentError, ":username required" if params[:username].nil?
21
+ raise ArgumentError, ":password required" if params[:password].nil?
22
+
23
+ config_savon(params)
24
+ @user_token = create_user_token(params)
25
+
26
+ @client = Savon::Client.new do
27
+ wsdl.document = params[:base_uri] || 'http://www.voxbone.com/VoxAPI/services/VoxAPI?WSDL'
28
+ wsdl.namespace = 'http://www.voxbone.com/VoxAPI'
29
+ end
30
+
31
+ @methods = @client.wsdl.soap_actions
32
+ end
33
+
34
+ ##
35
+ # Provides the dispatcher to the available SOAP methods defined in the WSDL
36
+ #
37
+ # @param [required, Symbol] the method name to invoke on the SOAP API
38
+ # @param [optional, Hash] the parameters to pass to the method, should be symbols and may be all lowercase with underscores
39
+ # @return [Hash] containing the results of the SOAP call
40
+ # @raise NoMethodError if the method requested is not defined in the WSDL
41
+ # @example Retrieve a country list
42
+ # voxbone.get_countries_list(:type => 'GEOGRAPHIC')
43
+ def method_missing(method_name, params={})
44
+ if @methods.include? method_name
45
+ response = @client.request :vox, method_name do
46
+ prepare_soap(soap, capitalize_params(params))
47
+ end
48
+ response.to_hash
49
+ else
50
+ raise NoMethodError, "The method #{method_name.to_s} does not exist."
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ ##
57
+ # Configures Savon
58
+ #
59
+ # @param [required, Hash] params
60
+ # @option params [optional, String] :log_level to set for Savon
61
+ def config_savon(params)
62
+ Savon.configure do |config|
63
+ if params[:log_level]
64
+ config.log = true
65
+ config.log_level = params[:log_level]
66
+ else
67
+ config.log = false
68
+ end
69
+ end
70
+ end
71
+
72
+ ##
73
+ # Builds the user token required by the Voxbone SOAP API
74
+ #
75
+ # @param [required, Hash] params
76
+ # @option params [required, String] :username for your Voxbone account
77
+ # @option params [required, String] :password for your Voxbone password
78
+ # @return [Hash] the user token
79
+ def create_user_token(params)
80
+ key = Time.now.strftime("%Y-%m-%d %H:%M:%S:") + '%012d' % rand(10_000_000_000)
81
+ { :User_token => { :Username => params[:username],
82
+ :Key => key,
83
+ :Hash => Digest::SHA1.hexdigest(params[:password] + key) } }
84
+ end
85
+
86
+ ##
87
+ # Builds the SOAP body for Savon
88
+ #
89
+ #
90
+ # @param [required, Object] the Savon SOAP object
91
+ # @param [required, Hash] params used to invoke the SOAP method
92
+ def prepare_soap(soap, params)
93
+ soap.body = params.merge(@user_token)
94
+ end
95
+
96
+ ##
97
+ # Capitalize all of the attributes in a hash
98
+ #
99
+ # @param [required, Hash] params
100
+ # @return [Hash] with keys capitalized
101
+ def capitalize_params(params)
102
+ new_params= {}
103
+ params.each { |k,v| new_params[k.to_s.capitalize.to_sym] = v }
104
+ new_params
105
+ end
106
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'voxbone'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Voxbone" do
4
+ before(:each) do
5
+ # You will need to set the username/password to valid ones in order to run a test
6
+ @voxbone = Voxbone.new({ :username => 'test',
7
+ :password => 'test',
8
+ :log_level => :debug,
9
+ :base_uri => 'http://sandbox.voxbone.com/VoxAPI/services/VoxAPI?wsdl' })
10
+ end
11
+
12
+ it "should instantiate a Voxbone class" do
13
+ @voxbone.instance_of?(Voxbone).should == true
14
+ end
15
+
16
+ it "should raise a no method error if an unknown method is called" do
17
+ begin
18
+ @voxbone.foobar
19
+ rescue => error
20
+ error.class.should == NoMethodError
21
+ error.to_s.should == "The method foobar does not exist."
22
+ end
23
+ end
24
+
25
+ it "should get the trunk list" do
26
+ trunks = @voxbone.get_trunk_list
27
+ trunks[:get_trunk_list_response].nil?.should == false
28
+ end
29
+
30
+ it "should return a list of countries based on geography" do
31
+ countries = @voxbone.get_countries_list(:type => 'GEOGRAPHIC')
32
+ countries[:get_countries_list_response][:array_of_countries][:country].nil?.should == false
33
+ end
34
+
35
+ it "should create a capacity group" do
36
+ result = @voxbone.create_capacity_group(:name_capacity_group => 'Foobar', :capacity => '100')
37
+ result[:create_capacity_group_response][:capacity_group][:name].should == 'Foobar'
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voxbone
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jason Goecke
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-16 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ name: savon
33
+ version_requirements: *id001
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 2
45
+ - 3
46
+ - 0
47
+ version: 2.3.0
48
+ name: rspec
49
+ version_requirements: *id002
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 7
59
+ segments:
60
+ - 0
61
+ - 6
62
+ - 0
63
+ version: 0.6.0
64
+ name: yard
65
+ version_requirements: *id003
66
+ prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 0
79
+ version: 1.0.0
80
+ name: bundler
81
+ version_requirements: *id004
82
+ prerelease: false
83
+ - !ruby/object:Gem::Dependency
84
+ type: :development
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 7
91
+ segments:
92
+ - 1
93
+ - 5
94
+ - 2
95
+ version: 1.5.2
96
+ name: jeweler
97
+ version_requirements: *id005
98
+ prerelease: false
99
+ - !ruby/object:Gem::Dependency
100
+ type: :development
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ name: rcov
111
+ version_requirements: *id006
112
+ prerelease: false
113
+ - !ruby/object:Gem::Dependency
114
+ type: :development
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ name: bluecloth
125
+ version_requirements: *id007
126
+ prerelease: false
127
+ - !ruby/object:Gem::Dependency
128
+ type: :runtime
129
+ requirement: &id008 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ name: savon
139
+ version_requirements: *id008
140
+ prerelease: false
141
+ description: Ruby library wrapping the Voxbone SOAP API
142
+ email: jason@goecke.net
143
+ executables: []
144
+
145
+ extensions: []
146
+
147
+ extra_rdoc_files:
148
+ - LICENSE.txt
149
+ - README.md
150
+ files:
151
+ - .document
152
+ - .rspec
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - LICENSE.txt
156
+ - README.md
157
+ - Rakefile
158
+ - VERSION
159
+ - examples/example.rb
160
+ - lib/voxbone.rb
161
+ - lib/voxbone/voxbone.rb
162
+ - spec/spec_helper.rb
163
+ - spec/voxbone_spec.rb
164
+ has_rdoc: true
165
+ homepage: http://github.com/jsgoecke/voxbone
166
+ licenses:
167
+ - MIT
168
+ post_install_message:
169
+ rdoc_options: []
170
+
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ hash: 3
179
+ segments:
180
+ - 0
181
+ version: "0"
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ requirements: []
192
+
193
+ rubyforge_project:
194
+ rubygems_version: 1.5.0
195
+ signing_key:
196
+ specification_version: 3
197
+ summary: Library for the Voxbone API
198
+ test_files:
199
+ - examples/example.rb
200
+ - spec/spec_helper.rb
201
+ - spec/voxbone_spec.rb