ruby-bandwidth-iris 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +13 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +20 -0
- data/README.md +571 -0
- data/Rakefile +5 -0
- data/examples/account.rb +15 -0
- data/examples/available_npa_nxx.rb +17 -0
- data/examples/available_number.rb +17 -0
- data/examples/city.rb +16 -0
- data/examples/config.yml.example +4 -0
- data/examples/covered-rate-center.rb +19 -0
- data/examples/loa.pdf +0 -0
- data/examples/order.rb +51 -0
- data/examples/port-in.rb +95 -0
- data/examples/sip_peer.rb +60 -0
- data/examples/site.rb +29 -0
- data/examples/tn.rb +20 -0
- data/lib/bandwidth-iris/account.rb +10 -0
- data/lib/bandwidth-iris/api_item.rb +36 -0
- data/lib/bandwidth-iris/available_npa_nxx.rb +15 -0
- data/lib/bandwidth-iris/available_number.rb +15 -0
- data/lib/bandwidth-iris/city.rb +15 -0
- data/lib/bandwidth-iris/client.rb +232 -0
- data/lib/bandwidth-iris/client_wrapper.rb +28 -0
- data/lib/bandwidth-iris/covered_rate_center.rb +17 -0
- data/lib/bandwidth-iris/disc_number.rb +19 -0
- data/lib/bandwidth-iris/disconnect.rb +36 -0
- data/lib/bandwidth-iris/dlda.rb +39 -0
- data/lib/bandwidth-iris/errors.rb +31 -0
- data/lib/bandwidth-iris/import_to_account.rb +24 -0
- data/lib/bandwidth-iris/in_service_number.rb +24 -0
- data/lib/bandwidth-iris/lidb.rb +24 -0
- data/lib/bandwidth-iris/lnp_checker.rb +18 -0
- data/lib/bandwidth-iris/lsr_order.rb +58 -0
- data/lib/bandwidth-iris/order.rb +76 -0
- data/lib/bandwidth-iris/port_in.rb +80 -0
- data/lib/bandwidth-iris/port_out.rb +24 -0
- data/lib/bandwidth-iris/rate_center.rb +19 -0
- data/lib/bandwidth-iris/sip_peer.rb +47 -0
- data/lib/bandwidth-iris/site.rb +83 -0
- data/lib/bandwidth-iris/subscription.rb +42 -0
- data/lib/bandwidth-iris/tn.rb +41 -0
- data/lib/bandwidth-iris/tn_reservation.rb +26 -0
- data/lib/bandwidth-iris/user.rb +20 -0
- data/lib/bandwidth-iris/version.rb +4 -0
- data/lib/ruby-bandwidth-iris.rb +29 -0
- data/ruby-bandwidth-iris.gemspec +26 -0
- data/spec/bandwidth-iris/account_spec.rb +19 -0
- data/spec/bandwidth-iris/available_npa_nxx_spec.rb +22 -0
- data/spec/bandwidth-iris/available_number_spec.rb +19 -0
- data/spec/bandwidth-iris/city_spec.rb +22 -0
- data/spec/bandwidth-iris/client_spec.rb +125 -0
- data/spec/bandwidth-iris/covered_rate_center_spec.rb +22 -0
- data/spec/bandwidth-iris/disconnect_spec.rb +52 -0
- data/spec/bandwidth-iris/dlda_spec.rb +47 -0
- data/spec/bandwidth-iris/import_to_account_spec.rb +36 -0
- data/spec/bandwidth-iris/in_service_number_spec.rb +33 -0
- data/spec/bandwidth-iris/lidb_spec.rb +44 -0
- data/spec/bandwidth-iris/lnp_checker_spec.rb +24 -0
- data/spec/bandwidth-iris/lsr_order_spec.rb +96 -0
- data/spec/bandwidth-iris/order_spec.rb +124 -0
- data/spec/bandwidth-iris/port_in_spec.rb +135 -0
- data/spec/bandwidth-iris/port_out_spec.rb +36 -0
- data/spec/bandwidth-iris/rate_center_spec.rb +29 -0
- data/spec/bandwidth-iris/sip_peer_spec.rb +86 -0
- data/spec/bandwidth-iris/site_spec.rb +95 -0
- data/spec/bandwidth-iris/subscription_spec.rb +58 -0
- data/spec/bandwidth-iris/tn_reservation_spec.rb +39 -0
- data/spec/bandwidth-iris/tn_spec.rb +68 -0
- data/spec/bandwidth-iris/user_spec.rb +21 -0
- data/spec/helper.rb +75 -0
- data/spec/xml.yml +46 -0
- metadata +256 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
TN_PATH = 'tns'
|
3
|
+
|
4
|
+
class Tn
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.get(client, number)
|
9
|
+
data = client.make_request(:get, "#{TN_PATH}/#{URI.escape(number)}")[0]
|
10
|
+
Tn.new(data, client)
|
11
|
+
end
|
12
|
+
wrap_client_arg :get
|
13
|
+
|
14
|
+
|
15
|
+
def self.list(client, query = nil)
|
16
|
+
list = client.make_request(:get, TN_PATH, query)[0][:telephone_numbers][:telephone_number]
|
17
|
+
return [] if !list
|
18
|
+
list = if list.is_a?(Array) then list else [list] end
|
19
|
+
list.map do |i|
|
20
|
+
Tn.new(i, client)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
wrap_client_arg :list
|
24
|
+
|
25
|
+
def get_sites()
|
26
|
+
@client.make_request(:get, "#{TN_PATH}/#{URI.escape(telephone_number)}/sites")[0]
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_sip_peers()
|
30
|
+
@client.make_request(:get, "#{TN_PATH}/#{URI.escape(telephone_number)}/sippeers")[0]
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_rate_center()
|
34
|
+
@client.make_request(:get, "#{TN_PATH}/#{URI.escape(telephone_number)}/ratecenter")[0][:telephone_number_details]
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_details()
|
38
|
+
@client.make_request(:get, "#{TN_PATH}/#{URI.escape(telephone_number)}/tndetails")[0][:telephone_number_details]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
TN_RESERVATION_PATH = 'tnreservation'
|
3
|
+
|
4
|
+
class TnReservation
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
|
9
|
+
def self.get(client, id)
|
10
|
+
data = client.make_request(:get, "#{client.concat_account_path(TN_RESERVATION_PATH)}/#{id}")[0][:reservation]
|
11
|
+
TnReservation.new(data, client)
|
12
|
+
end
|
13
|
+
wrap_client_arg :get
|
14
|
+
|
15
|
+
def self.create(client, item)
|
16
|
+
location = client.make_request(:post, client.concat_account_path(TN_RESERVATION_PATH), {:tn_reservation => item})[1][:location]
|
17
|
+
id = Client.get_id_from_location_header(location)
|
18
|
+
self.get(client, id)
|
19
|
+
end
|
20
|
+
wrap_client_arg :create
|
21
|
+
|
22
|
+
def delete()
|
23
|
+
@client.make_request(:delete,"#{@client.concat_account_path(TN_RESERVATION_PATH)}/#{id}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
USER_PATH = 'users'
|
3
|
+
|
4
|
+
class User
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client)
|
9
|
+
list = client.make_request(:get, USER_PATH)[0][:users][:user]
|
10
|
+
return [] if !list
|
11
|
+
list = if list.is_a?(Array) then list else [list] end
|
12
|
+
list.map do |i|
|
13
|
+
User.new(i, client)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
wrap_client_arg :list
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'bandwidth-iris/api_item'
|
2
|
+
require 'bandwidth-iris/errors'
|
3
|
+
require 'bandwidth-iris/client'
|
4
|
+
require 'bandwidth-iris/client_wrapper'
|
5
|
+
|
6
|
+
require 'bandwidth-iris/account'
|
7
|
+
require 'bandwidth-iris/available_number'
|
8
|
+
require 'bandwidth-iris/available_npa_nxx'
|
9
|
+
require 'bandwidth-iris/city'
|
10
|
+
require 'bandwidth-iris/covered_rate_center'
|
11
|
+
require 'bandwidth-iris/disconnect'
|
12
|
+
require 'bandwidth-iris/dlda'
|
13
|
+
require 'bandwidth-iris/import_to_account'
|
14
|
+
require 'bandwidth-iris/in_service_number'
|
15
|
+
require 'bandwidth-iris/lidb'
|
16
|
+
require 'bandwidth-iris/lnp_checker'
|
17
|
+
require 'bandwidth-iris/lsr_order'
|
18
|
+
require 'bandwidth-iris/order'
|
19
|
+
require 'bandwidth-iris/port_in'
|
20
|
+
require 'bandwidth-iris/port_out'
|
21
|
+
require 'bandwidth-iris/rate_center'
|
22
|
+
require 'bandwidth-iris/sip_peer'
|
23
|
+
require 'bandwidth-iris/site'
|
24
|
+
require 'bandwidth-iris/subscription'
|
25
|
+
require 'bandwidth-iris/tn'
|
26
|
+
require 'bandwidth-iris/tn_reservation'
|
27
|
+
require 'bandwidth-iris/user'
|
28
|
+
|
29
|
+
require 'bandwidth-iris/version'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bandwidth-iris/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruby-bandwidth-iris"
|
7
|
+
spec.version = BandwidthIris::VERSION
|
8
|
+
spec.authors = ["Andrey Belchikov"]
|
9
|
+
spec.description = "Gem for integrating to Bandwidth's Iris API"
|
10
|
+
spec.summary = spec.description
|
11
|
+
spec.homepage = "https://github.com/bandwidthcom/ruby-bandwidth-iris"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.add_dependency "builder"
|
18
|
+
spec.add_dependency "faraday"
|
19
|
+
spec.add_dependency "nori"
|
20
|
+
spec.add_dependency "activesupport"
|
21
|
+
spec.add_dependency "certified"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "yard"
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe BandwidthIris::Account do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#get' do
|
13
|
+
it 'should return an account' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId') {|env| [200, {}, Helper.xml['account']]}
|
15
|
+
item = Account.get(client)
|
16
|
+
expect(item[:account_id]).to eql(14)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe BandwidthIris::AvailableNpaNxx do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return data' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/availableNpaNxx?areaCode=919') {|env| [200, {}, Helper.xml['available_npa_nxx']]}
|
15
|
+
expect(AvailableNpaNxx.list(client, {:area_code => 919})).to eql([
|
16
|
+
{ :city => "City1", :state => "State1", :npa => "Npa1", :nxx => "Nxx1", :quantity => 10 },
|
17
|
+
{ :city => "City2", :state => "State2", :npa => "Npa2", :nxx => "Nxx2", :quantity => 20 }
|
18
|
+
])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe BandwidthIris::AvailableNumber do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return numbers' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/availableNumbers?areaCode=866&quantity=5') {|env| [200, {}, Helper.xml['available_numbers']]}
|
15
|
+
expect(AvailableNumber.list(client, {:area_code => 866, :quantity => 5}).length).to eql(2)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe BandwidthIris::City do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return cities' do
|
14
|
+
client.stubs.get('/v1.0/cities?state=NC') {|env| [200, {}, Helper.xml['cities']]}
|
15
|
+
expect(City.list(client, {:state => 'NC'})).to eql([
|
16
|
+
{ :rc_abbreviation => "SOUTHEPINS", :name => "ABERDEEN" },
|
17
|
+
{ :rc_abbreviation => "JULIAN", :name => "ADVANCE" }
|
18
|
+
])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
describe BandwidthIris::Client do
|
2
|
+
describe '#initialize' do
|
3
|
+
it 'should create instance of Client' do
|
4
|
+
expect(Client.new()).to be_a(Client)
|
5
|
+
expect(Client.new('accountId', 'user', 'password')).to be_a(Client)
|
6
|
+
expect(Client.new('accountId', 'user', 'password', {})).to be_a(Client)
|
7
|
+
expect(Client.new({:account_id => 'accountId', :username => 'user', :password => 'password'})).to be_a(Client)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#global_options' do
|
12
|
+
it 'should return and change @@global_options of Client' do
|
13
|
+
Client.global_options = {:account_id => 'accountId', :username => 'username', :password => 'password'}
|
14
|
+
expect(Client.global_options).to eql({:account_id => 'accountId', :username => 'username', :password => 'password'})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#get_id_from_location_header' do
|
19
|
+
it 'should return last url path item as id' do
|
20
|
+
expect(Client.get_id_from_location_header('http://localhost/path1/path2/id')).to eql('id')
|
21
|
+
end
|
22
|
+
it 'should raise error if location is missing or nil' do
|
23
|
+
expect{Client.get_id_from_location_header('')}.to raise_error
|
24
|
+
expect{Client.get_id_from_location_header(nil)}.to raise_error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#concat_account_path' do
|
29
|
+
client = nil
|
30
|
+
before :each do
|
31
|
+
client = Helper.get_client()
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should add user id to path' do
|
35
|
+
expect(client.concat_account_path('test')).to eql('/accounts/accountId/test')
|
36
|
+
expect(client.concat_account_path('/test1')).to eql('/accounts/accountId/test1')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#create_connection' do
|
41
|
+
client = nil
|
42
|
+
before :each do
|
43
|
+
client = Helper.get_client()
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should create new faraday connection' do
|
47
|
+
connection = client.create_connection()
|
48
|
+
expect(connection).to be_a(Faraday::Connection)
|
49
|
+
expect(connection.headers['Authorization']).to eql("Basic #{Base64.strict_encode64('username:password')}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#make_request' do
|
54
|
+
client = nil
|
55
|
+
before :each do
|
56
|
+
client = Helper.get_client()
|
57
|
+
end
|
58
|
+
|
59
|
+
after :each do
|
60
|
+
client.stubs.verify_stubbed_calls()
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should make GET request and return xml data' do
|
64
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<Result><Test>data</Test></Result>'] }
|
65
|
+
client.stubs.get('/v1.0/path2?testField=10') { |env| [200, {'Location'=>'url'}, '<Root><TestValue>10</TestValue><DataArray>1</DataArray><DataArray>2</DataArray><BoolValue>true</BoolValue><BoolValue2>false</BoolValue2><DateTimeValue>2015-05-29T01:02:03Z</DateTimeValue></Root>'] }
|
66
|
+
expect(client.make_request(:get, '/path1')).to eql([{:test => 'data'}, {}])
|
67
|
+
expect(client.make_request(:get, '/path2', {:test_field => 10})).to eql([{:test_value => 10, :data_array => [1, 2], :bool_value => true, :bool_value2 => false, :date_time_value => DateTime.new(2015,5,29,1,2,3)}, {:location=>'url'}])
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should make POST request and return xml data' do
|
71
|
+
client.stubs.post('/v1.0/path1', '<?xml version="1.0" encoding="UTF-8"?><Request><TestField1>test</TestField1><TestField2>10</TestField2><TestField3>false</TestField3><TestFieldd4>2015-05-29T01:02:03+00:00</TestFieldd4></Request>') { |env| [200, {}, '<Response><Success>true</Success></Response>'] }
|
72
|
+
expect(client.make_request(:post, '/path1', {:request => {:test_field1 => "test", :test_field2 => 10, :test_field3 => false, :test_fieldd4 => DateTime.new(2015, 5, 29, 1,2,3)}})[0]).to eql(:success => true)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should make PUT request and return xml data' do
|
76
|
+
client.stubs.put('/v1.0/path1', '<?xml version="1.0" encoding="UTF-8"?><Request><TestField1>test</TestField1></Request>') { |env| [200, {}, '<Response><Success>true</Success></Response>'] }
|
77
|
+
expect(client.make_request(:put, '/path1', {:request => {:test_field1 => "test"}})[0]).to eql(:success => true)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should make DELETE request and return xml data' do
|
81
|
+
client.stubs.delete('/v1.0/path1') { |env| [200, {}, '<Result><Test>data</Test></Result>'] }
|
82
|
+
expect(client.make_request(:delete, '/path1')).to eql([{:test => 'data'}, {}])
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should raise error if http status >= 400' do
|
86
|
+
client.stubs.get('/v1.0/path1') { |env| [400, {}, ''] }
|
87
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Http code 400")
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should fail if output contains ErrorCode and Description' do
|
91
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><ErrorCode>400</ErrorCode><Description>Error</Description></Test></Response>'] }
|
92
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Error")
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should fail if output contains element Error with Code and Description' do
|
96
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><Error><Code>400</Code><Description>Error</Description></Error></Test></Response>'] }
|
97
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Error")
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should fail if output contains elements Errors with Code and Description' do
|
101
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><Errors><Code>400</Code><Description>Error</Description></Errors><Errors><Code>401</Code><Description>Error1</Description></Errors></Test></Response>'] }
|
102
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::AgregateError)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should fail if output contains elements Errors with Code and Description (for 1 element)' do
|
106
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><Errors><Code>400</Code><Description>Error</Description></Errors></Test></Response>'] }
|
107
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::AgregateError)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should fail if output contains elements resultCode and resultMessage' do
|
111
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><resultCode>400</resultCode><resultMessage>Error</resultMessage></Test></Response>'] }
|
112
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Error")
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should fail if output contains elements resultCode and resultMessage (more deep)' do
|
116
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Tests><Test></Test><Test><resultCode>400</resultCode><resultMessage>Error</resultMessage></Test></Tests></Response>'] }
|
117
|
+
expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Error")
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should not fail if resultCode == 0' do
|
121
|
+
client.stubs.get('/v1.0/path1') { |env| [200, {}, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><Test><resultCode>0</resultCode><resultMessage>Completed</resultMessage></Test></Response>'] }
|
122
|
+
client.make_request(:get, '/path1')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe BandwidthIris::CoveredRateCenter do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return centers' do
|
14
|
+
client.stubs.get('/v1.0/coveredRateCenters') {|env| [200, {}, Helper.xml['covered_rate_centers']]}
|
15
|
+
list = CoveredRateCenter.list(client)
|
16
|
+
expect(list.length).to eql(1)
|
17
|
+
expect(list[0][:abbreviation]).to eql("ACME")
|
18
|
+
expect(list[0][:name]).to eql("ACME")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe BandwidthIris::Disconnect do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#create' do
|
13
|
+
it 'should disconnect numbers' do
|
14
|
+
data = {
|
15
|
+
:disconnect_telephone_number_order => {
|
16
|
+
:name => 'test',
|
17
|
+
'_nameXmlElement' => 'name',
|
18
|
+
:disconnect_telephone_number_order_type => {
|
19
|
+
:telephone_number => ['111', '222']
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
client.stubs.post('/v1.0/accounts/accountId/disconnects', client.build_xml(data)) {|env| [200, {}, '']}
|
24
|
+
Disconnect.create(client, 'test', ['111', '222'])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#get_notes' do
|
29
|
+
it 'should return notes' do
|
30
|
+
client.stubs.get('/v1.0/accounts/accountId/disconnects/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
31
|
+
order = Disconnect.new({:id => 1}, client)
|
32
|
+
|
33
|
+
list = order.get_notes()
|
34
|
+
expect(list[0][:id]).to eql(11299)
|
35
|
+
expect(list[0][:user_id]).to eql('customer')
|
36
|
+
expect(list[0][:description]).to eql('Test')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#add_notes' do
|
41
|
+
it 'should add a note and return it' do
|
42
|
+
data = {:user_id => 'customer', :description => 'Test'}
|
43
|
+
client.stubs.post('/v1.0/accounts/accountId/disconnects/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/FakeAccountId/disconnects/1/notes/11299'}, '']}
|
44
|
+
client.stubs.get('/v1.0/accounts/accountId/disconnects/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
45
|
+
order = Disconnect.new({:id => 1}, client)
|
46
|
+
item = order.add_notes(data)
|
47
|
+
expect(item[:id]).to eql(11299)
|
48
|
+
expect(item[:user_id]).to eql('customer')
|
49
|
+
expect(item[:description]).to eql('Test')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe BandwidthIris::Dlda do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return orders' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/dldas') {|env| [200, {}, Helper.xml['dldas']]}
|
15
|
+
list = Dlda.list(client)
|
16
|
+
expect(list.length).to eql(3)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#get' do
|
21
|
+
it 'should return an order' do
|
22
|
+
client.stubs.get('/v1.0/accounts/accountId/dldas/1') {|env| [200, {}, Helper.xml['dlda']]}
|
23
|
+
item = Dlda.get(client, 1)
|
24
|
+
expect(item[:id]).to eql('ea9e90c2-77a4-4f82-ac47-e1c5bb1311f4')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#create' do
|
29
|
+
it 'should create a subscription' do
|
30
|
+
data = {}
|
31
|
+
client.stubs.post('/v1.0/accounts/accountId/dldas', client.build_xml({:dlda_order => data})) {|env| [201, {'Location' => '/v1.0/accounts/accountId/dldas/1'}, '']}
|
32
|
+
client.stubs.get('/v1.0/accounts/accountId/dldas/1') {|env| [200, {}, Helper.xml['dlda']]}
|
33
|
+
item = Dlda.create(client, data)
|
34
|
+
expect(item[:id]).to eql('ea9e90c2-77a4-4f82-ac47-e1c5bb1311f4')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#get_history' do
|
39
|
+
it 'should return history' do
|
40
|
+
client.stubs.get('/v1.0/accounts/accountId/dldas/1/history') {|env| [200, {}, Helper.xml['order_history']]}
|
41
|
+
item = Dlda.new({:id => 1}, client)
|
42
|
+
list = item.get_history()
|
43
|
+
expect(list.length > 0).to eql(true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe BandwidthIris::ImportToAccount do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#get_notes' do
|
13
|
+
it 'should return notes' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/importToAccounts/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
15
|
+
order = ImportToAccount.new({:id => 1}, client)
|
16
|
+
|
17
|
+
list = order.get_notes()
|
18
|
+
expect(list[0][:id]).to eql(11299)
|
19
|
+
expect(list[0][:user_id]).to eql('customer')
|
20
|
+
expect(list[0][:description]).to eql('Test')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#add_notes' do
|
25
|
+
it 'should add a note and return it' do
|
26
|
+
data = {:user_id => 'customer', :description => 'Test'}
|
27
|
+
client.stubs.post('/v1.0/accounts/accountId/importToAccounts/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/FakeAccountId/importToAccounts/1/notes/11299'}, '']}
|
28
|
+
client.stubs.get('/v1.0/accounts/accountId/importToAccounts/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
29
|
+
order = ImportToAccount.new({:id => 1}, client)
|
30
|
+
item = order.add_notes(data)
|
31
|
+
expect(item[:id]).to eql(11299)
|
32
|
+
expect(item[:user_id]).to eql('customer')
|
33
|
+
expect(item[:description]).to eql('Test')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
describe BandwidthIris::InServiceNumber do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return numbers' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/inserviceNumbers') {|env| [200, {}, Helper.xml['in_service_numbers']]}
|
15
|
+
list = InServiceNumber.list(client)
|
16
|
+
expect(list.length).to eql(15)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#get' do
|
20
|
+
it 'should return a number' do
|
21
|
+
client.stubs.get('/v1.0/accounts/accountId/inserviceNumbers/12345') {|env| [200, {}, '']}
|
22
|
+
InServiceNumber.get(client, '12345')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe '#totals' do
|
26
|
+
it 'should return totals' do
|
27
|
+
client.stubs.get('/v1.0/accounts/accountId/inserviceNumbers/totals') {|env| [200, {}, Helper.xml['in_service_numbers_totals']]}
|
28
|
+
r = InServiceNumber.totals(client)
|
29
|
+
expect(r[:count]).to eql(3)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
describe BandwidthIris::Lidb do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
it 'should return orders' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/lidbs') {|env| [200, {}, Helper.xml['lidbs']]}
|
15
|
+
Lidb.list(client)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#get' do
|
20
|
+
it 'should return an order' do
|
21
|
+
client.stubs.get('/v1.0/accounts/accountId/lidbs/1') {|env| [200, {}, Helper.xml['lidb']]}
|
22
|
+
Lidb.get(client, 1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#create' do
|
27
|
+
it 'should create a subscription' do
|
28
|
+
data = {
|
29
|
+
:customer_order_id =>"A Test order",
|
30
|
+
:lidb_tn_groups => {
|
31
|
+
:lidb_tn_group => {
|
32
|
+
:telephone_numbers => ["8048030097", "8045030098"],
|
33
|
+
:subscriber_information =>"Joes Grarage",
|
34
|
+
:use_type => "RESIDENTIAL",
|
35
|
+
:visibility => "PUBLIC"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
client.stubs.post('/v1.0/accounts/accountId/lidbs', client.build_xml({:lidb_order => data})) {|env| [201, {'Location' => '/v1.0/accounts/accountId/lidbs/1'}, '']}
|
40
|
+
client.stubs.get('/v1.0/accounts/accountId/lidbs/1') {|env| [200, {}, Helper.xml['lidb']]}
|
41
|
+
Lidb.create(client, data)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe BandwidthIris::LnpChecker do
|
2
|
+
client = nil
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
client = Helper.get_client()
|
6
|
+
end
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
client.stubs.verify_stubbed_calls()
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#check' do
|
13
|
+
it 'should check numbers' do
|
14
|
+
numbers = ['1111', '2222']
|
15
|
+
data = {:number_portability_request => {:tn_list => {:tn => numbers}}}
|
16
|
+
client.stubs.post('/v1.0/accounts/accountId/lnpchecker?fullCheck=true', client.build_xml(data)) {|env| [200, {}, Helper.xml['lnp_check']]}
|
17
|
+
result = LnpChecker.check(client, numbers, true)
|
18
|
+
expect(result[:supported_rate_centers][:rate_center_group][:rate_center]).to eql("Center1")
|
19
|
+
expect(result[:supported_rate_centers][:rate_center_group][:city]).to eql("City1")
|
20
|
+
expect(result[:supported_rate_centers][:rate_center_group][:state]).to eql("State1")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|