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,96 @@
|
|
1
|
+
describe BandwidthIris::LsrOrder 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 create an order' do
|
14
|
+
data = {
|
15
|
+
:pon =>"Some Pon",
|
16
|
+
:customer_order_id => "MyId5",
|
17
|
+
'sPID' => "123C",
|
18
|
+
'_sPIDXmlElement' => 'sPID',
|
19
|
+
:billing_telephone_number => "9192381468",
|
20
|
+
:requested_foc_date => "2015-11-15",
|
21
|
+
:authorizing_person => "Jim Hopkins",
|
22
|
+
:subscriber => {
|
23
|
+
:subscriber_type => "BUSINESS",
|
24
|
+
:business_name => "BusinessName",
|
25
|
+
:service_address => {
|
26
|
+
:house_number =>"11",
|
27
|
+
:street_name => "Park",
|
28
|
+
:street_suffix => "Ave",
|
29
|
+
:city => "New York",
|
30
|
+
:state_code => "NY",
|
31
|
+
:zip => "90025"
|
32
|
+
},
|
33
|
+
:account_number => "123463",
|
34
|
+
:pin_number => "1231"
|
35
|
+
},
|
36
|
+
:list_of_telephone_numbers => {
|
37
|
+
:telephone_number => ["9192381848", "9192381467"]
|
38
|
+
}
|
39
|
+
}
|
40
|
+
client.stubs.post('/v1.0/accounts/accountId/lsrorders', client.build_xml({:lsr_order => data})) {|env| [200, {'Location' => '/v1.0/accounts/accountId/lsrorders/1'}, '']}
|
41
|
+
client.stubs.get('/v1.0/accounts/accountId/lsrorders/1') {|env| [200, {}, Helper.xml['lsr_order']]}
|
42
|
+
order = LsrOrder.create(client, data)
|
43
|
+
expect(order[:id]).to eql("00cf7e08-cab0-4515-9a77-2d0a7da09415")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#get' do
|
48
|
+
it 'should return an order' do
|
49
|
+
client.stubs.get('/v1.0/accounts/accountId/lsrorders/1') {|env| [200, {}, Helper.xml['lsr_order']]}
|
50
|
+
order = LsrOrder.get(client, "1")
|
51
|
+
expect(order.account_id).to eql(9999999)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#list' do
|
56
|
+
it 'should return orders' do
|
57
|
+
client.stubs.get('/v1.0/accounts/accountId/lsrorders') {|env| [200, {}, Helper.xml['lsr_orders']]}
|
58
|
+
list = LsrOrder.list(client)
|
59
|
+
expect(list.length).to eql(2)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#update' do
|
64
|
+
it 'should update an order' do
|
65
|
+
data = { :name => "Test", :close_order => true }
|
66
|
+
client.stubs.put('/v1.0/accounts/accountId/lsrorders/1', client.build_xml({:lsr_order => data})) {|env| [200, {}, '']}
|
67
|
+
item = LsrOrder.new({:id => 1}, client)
|
68
|
+
item.update(data)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#get_notes' do
|
73
|
+
it 'should return notes' do
|
74
|
+
client.stubs.get('/v1.0/accounts/accountId/lsrorders/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
75
|
+
order = LsrOrder.new({:id => 1}, client)
|
76
|
+
|
77
|
+
list = order.get_notes()
|
78
|
+
expect(list[0][:id]).to eql(11299)
|
79
|
+
expect(list[0][:user_id]).to eql('customer')
|
80
|
+
expect(list[0][:description]).to eql('Test')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#add_notes' do
|
85
|
+
it 'should add a note and return it' do
|
86
|
+
data = {:user_id => 'customer', :description => 'Test'}
|
87
|
+
client.stubs.post('/v1.0/accounts/accountId/lsrorders/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/accountId/lsrorders/1/notes/11299'}, '']}
|
88
|
+
client.stubs.get('/v1.0/accounts/accountId/lsrorders/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
89
|
+
order = LsrOrder.new({:id => 1}, client)
|
90
|
+
item = order.add_notes(data)
|
91
|
+
expect(item[:id]).to eql(11299)
|
92
|
+
expect(item[:user_id]).to eql('customer')
|
93
|
+
expect(item[:description]).to eql('Test')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
describe BandwidthIris::Order 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 create an order' do
|
14
|
+
data = {
|
15
|
+
:name => "Test",
|
16
|
+
:siteId => "10",
|
17
|
+
:customerOrderId => "11",
|
18
|
+
:lataSearchAndOrderType => {
|
19
|
+
:lata => "224",
|
20
|
+
:quantity => 1
|
21
|
+
}
|
22
|
+
}
|
23
|
+
client.stubs.post("/v1.0/accounts/accountId/orders", client.build_xml({:order => data})){|env| [200, {}, Helper.xml['order']]}
|
24
|
+
order = Order.create(client, data)
|
25
|
+
expect(order.id).to eql(101)
|
26
|
+
expect(order.name).to eql("Test")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#get' do
|
31
|
+
it 'should return an order' do
|
32
|
+
client.stubs.get("/v1.0/accounts/accountId/orders/101"){|env| [200, {}, Helper.xml['order']]}
|
33
|
+
order = Order.get(client, "101")
|
34
|
+
expect(order.id).to eql(101)
|
35
|
+
expect(order.name).to eql("Test")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#list' do
|
40
|
+
it 'should return orders' do
|
41
|
+
client.stubs.get("/v1.0/accounts/accountId/orders"){|env| [200, {}, Helper.xml['orders']]}
|
42
|
+
list = Order.list(client)
|
43
|
+
expect(list.length).to eql(1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#update' do
|
48
|
+
it 'should update an order' do
|
49
|
+
data = { :name => "Test", :close_order => true }
|
50
|
+
client.stubs.put("/v1.0/accounts/accountId/orders/101", client.build_xml(:order => data)){|env| [200, {}, '']}
|
51
|
+
item = Order.new({:id => 101}, client)
|
52
|
+
item.update(data)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#get_notes' do
|
57
|
+
it 'should return notes' do
|
58
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
59
|
+
order = Order.new({:id => 1}, client)
|
60
|
+
|
61
|
+
list = order.get_notes()
|
62
|
+
expect(list[0][:id]).to eql(11299)
|
63
|
+
expect(list[0][:user_id]).to eql('customer')
|
64
|
+
expect(list[0][:description]).to eql('Test')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#add_notes' do
|
69
|
+
it 'should add a note and return it' do
|
70
|
+
data = {:user_id => 'customer', :description => 'Test'}
|
71
|
+
client.stubs.post('/v1.0/accounts/accountId/orders/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/FakeAccountId/orders/1/notes/11299'}, '']}
|
72
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
73
|
+
order = Order.new({:id => 1}, client)
|
74
|
+
item = order.add_notes(data)
|
75
|
+
expect(item[:id]).to eql(11299)
|
76
|
+
expect(item[:user_id]).to eql('customer')
|
77
|
+
expect(item[:description]).to eql('Test')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#get_area_codes' do
|
82
|
+
it 'should return codes' do
|
83
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/areaCodes') {|env| [200, {}, Helper.xml['order_area_codes']]}
|
84
|
+
order = Order.new({:id => 1}, client)
|
85
|
+
list = order.get_area_codes()
|
86
|
+
expect(list.length).to eql(1)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#get_npa_nxx' do
|
91
|
+
it 'should return codes' do
|
92
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/npaNxx') {|env| [200, {}, Helper.xml['order_npa_nxx']]}
|
93
|
+
order = Order.new({:id => 1}, client)
|
94
|
+
list = order.get_npa_npx()
|
95
|
+
expect(list.length).to eql(1)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#get_totals' do
|
100
|
+
it 'should return totals' do
|
101
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/totals') {|env| [200, {}, Helper.xml['order_totals']]}
|
102
|
+
order = Order.new({:id => 1}, client)
|
103
|
+
list = order.get_totals()
|
104
|
+
expect(list.length).to eql(1)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#get_history' do
|
109
|
+
it 'should return history' do
|
110
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/history') {|env| [200, {}, Helper.xml['order_history']]}
|
111
|
+
order = Order.new({:id => 1}, client)
|
112
|
+
list = order.get_history()
|
113
|
+
expect(list.length).to eql(2)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#get_tns' do
|
118
|
+
it 'should return tns' do
|
119
|
+
client.stubs.get('/v1.0/accounts/accountId/orders/1/tns') {|env| [200, {}, Helper.xml['order_tns']]}
|
120
|
+
order = Order.new({:id => 1}, client)
|
121
|
+
order.get_tns()
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
describe BandwidthIris::PortIn 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 create an order' do
|
14
|
+
data = {
|
15
|
+
:billing_telephone_number => "1111",
|
16
|
+
:subscriber => {
|
17
|
+
:subscriber_type => "BUSINESS",
|
18
|
+
:business_name => "Company",
|
19
|
+
:service_address => {
|
20
|
+
:city => "City",
|
21
|
+
:country => "Country"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
client.stubs.post('/v1.0/accounts/accountId/portins', client.build_xml({:lnp_order => data})) {|env| [200, {}, Helper.xml['port_in']]}
|
26
|
+
item = PortIn.create(client, data)
|
27
|
+
expect(item[:id]).to eql("d28b36f7-fa96-49eb-9556-a40fca49f7c6")
|
28
|
+
expect(item[:billing_type]).to eql('PORTIN')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#update' do
|
33
|
+
it 'should update an order' do
|
34
|
+
data = {
|
35
|
+
:requested_foc_date => "2014-11-18T00:00:00.000Z",
|
36
|
+
:wireless_info => {
|
37
|
+
:account_number => "77129766500001",
|
38
|
+
:pin_number => "0000"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
client.stubs.put('/v1.0/accounts/accountId/portins/1', client.build_xml({:lnp_order_supp => data})) {|env| [200, {}, '']}
|
42
|
+
item = PortIn.new({:id => 1}, client)
|
43
|
+
item.update(data)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#delete' do
|
48
|
+
it 'should remove an order' do
|
49
|
+
client.stubs.delete('/v1.0/accounts/accountId/portins/1') {|env| [200, {}, '']}
|
50
|
+
item = PortIn.new({:id => 1}, client)
|
51
|
+
item.delete()
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe '#get_notes' do
|
57
|
+
it 'should return notes' do
|
58
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
59
|
+
order = PortIn.new({:id => 1}, client)
|
60
|
+
|
61
|
+
list = order.get_notes()
|
62
|
+
expect(list[0][:id]).to eql(11299)
|
63
|
+
expect(list[0][:user_id]).to eql('customer')
|
64
|
+
expect(list[0][:description]).to eql('Test')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#add_notes' do
|
69
|
+
it 'should add a note and return it' do
|
70
|
+
data = {:user_id => 'customer', :description => 'Test'}
|
71
|
+
client.stubs.post('/v1.0/accounts/accountId/portins/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/accountId/portins/1/notes/11299'}, '']}
|
72
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
73
|
+
order = PortIn.new({:id => 1}, client)
|
74
|
+
item = order.add_notes(data)
|
75
|
+
expect(item[:id]).to eql(11299)
|
76
|
+
expect(item[:user_id]).to eql('customer')
|
77
|
+
expect(item[:description]).to eql('Test')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#get_files' do
|
82
|
+
it 'should return list of files' do
|
83
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/loas?metadata=true') {|env| [200, {}, Helper.xml['files']]}
|
84
|
+
item = PortIn.new({:id => 1}, client)
|
85
|
+
list = item.get_files(true)
|
86
|
+
expect(list.length).to eql(6)
|
87
|
+
expect(list[0][:file_name]).to eql("d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231534986.txt")
|
88
|
+
end
|
89
|
+
it 'should return list of files (without metadata)' do
|
90
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/loas?metadata=false') {|env| [200, {}, Helper.xml['files']]}
|
91
|
+
item = PortIn.new({:id => 1}, client)
|
92
|
+
list = item.get_files()
|
93
|
+
expect(list.length).to eql(6)
|
94
|
+
expect(list[0][:file_name]).to eql("d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231534986.txt")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#get_file_metadata' do
|
99
|
+
it 'should return metadata of a file' do
|
100
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/loas/file.txt/metadata') {|env| [200, {}, Helper.xml['file_metadata']]}
|
101
|
+
item = PortIn.new({:id => 1}, client)
|
102
|
+
meta = item.get_file_metadata('file.txt')
|
103
|
+
expect(meta[:document_type]).to eql("LOA")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#get_file' do
|
108
|
+
it 'should return file context and media type' do
|
109
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/loas/file.txt') {|env| [200, {'Content-Type' => 'text/plain'}, '123']}
|
110
|
+
item = PortIn.new({:id => 1}, client)
|
111
|
+
r = item.get_file('file.txt')
|
112
|
+
expect(r[0]).to eql("123")
|
113
|
+
expect(r[1]).to eql("text/plain")
|
114
|
+
end
|
115
|
+
it 'should return file context and media type (if media type is missing)' do
|
116
|
+
client.stubs.get('/v1.0/accounts/accountId/portins/1/loas/file.txt') {|env| [200, {}, '123']}
|
117
|
+
item = PortIn.new({:id => 1}, client)
|
118
|
+
r = item.get_file('file.txt')
|
119
|
+
expect(r[0]).to eql("123")
|
120
|
+
expect(r[1]).to eql("application/octet-stream")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#create_file' do
|
125
|
+
it 'should upload file context' do
|
126
|
+
client.stubs.post('/v1.0/accounts/accountId/portins/1/loas', '123', {'Content-Type' => 'text/plain', 'Content-Length' => '3'}) {|env| [200, {}, Helper.xml['file_created']]}
|
127
|
+
client.stubs.post('/v1.0/accounts/accountId/portins/1/loas', '123', {'Content-Type' => 'application/octet-stream', 'Content-Length' => '3'}) {|env| [200, {}, Helper.xml['file_created']]}
|
128
|
+
item = PortIn.new({:id => 1}, client)
|
129
|
+
r = item.create_file(StringIO.new('123'), 'text/plain')
|
130
|
+
expect(r).to eql("test.txt")
|
131
|
+
r = item.create_file(StringIO.new('123'))
|
132
|
+
expect(r).to eql("test.txt")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe BandwidthIris::PortOut 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/portouts/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
15
|
+
order = PortOut.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/portouts/1/notes', client.build_xml({note: data})) {|env| [200, {:location => '/v1.0/accounts/FakeAccountId/portouts/1/notes/11299'}, '']}
|
28
|
+
client.stubs.get('/v1.0/accounts/accountId/portouts/1/notes') {|env| [200, {}, Helper.xml['notes']]}
|
29
|
+
order = PortOut.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,29 @@
|
|
1
|
+
describe BandwidthIris::RateCenter 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 rate centes' do
|
14
|
+
client.stubs.get('/v1.0/rateCenters') {|env| [200, {}, Helper.xml['rate_centers']]}
|
15
|
+
list = RateCenter.list(client)
|
16
|
+
expect(list.length).to eql(3)
|
17
|
+
expect(list[0][:abbreviation]).to eql("ACME")
|
18
|
+
expect(list[0][:name]).to eql("ACME")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return rate centes (with 1 element)' do
|
23
|
+
client.stubs.get('/v1.0/rateCenters') {|env| [200, {}, Helper.xml['rate_centers1']]}
|
24
|
+
list = RateCenter.list(client)
|
25
|
+
expect(list.length).to eql(1)
|
26
|
+
expect(list[0][:abbreviation]).to eql("ACME")
|
27
|
+
expect(list[0][:name]).to eql("ACME")
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
describe BandwidthIris::SipPeer 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 peers' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers') {|env| [200, {}, Helper.xml['sip_peers']]}
|
15
|
+
list = SipPeer.list(client, 1)
|
16
|
+
expect(list.length).to eql(1)
|
17
|
+
expect(list[0][:id]).to eql(12345)
|
18
|
+
expect(list[0][:peer_name]).to eql("SIP Peer 1")
|
19
|
+
expect(list[0][:description]).to eql("Sip Peer 1 description")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#get' do
|
24
|
+
it 'should return a peer' do
|
25
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/11') {|env| [200, {}, Helper.xml['sip_peer']]}
|
26
|
+
item = SipPeer.get(client, 1, 11)
|
27
|
+
expect(item[:id]).to eql(10)
|
28
|
+
expect(item[:peer_name]).to eql("SIP Peer 1")
|
29
|
+
expect(item[:description]).to eql("Sip Peer 1 description")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#create' do
|
34
|
+
it 'should create a peer' do
|
35
|
+
data = {:peer_name => "SIP Peer 1", :description => "Sip Peer 1 description"}
|
36
|
+
client.stubs.post('/v1.0/accounts/accountId/sites/1/sippeers', client.build_xml({:sip_peer => data})) {|env| [201, {'Location' => '/v1.0/accounts/accountId/sites/1/sippeers/11'}, '']}
|
37
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/11') {|env| [200, {}, Helper.xml['sip_peer']]}
|
38
|
+
item = SipPeer.create(client, 1, data)
|
39
|
+
expect(item[:id]).to eql(10)
|
40
|
+
expect(item[:peer_name]).to eql("SIP Peer 1")
|
41
|
+
expect(item[:description]).to eql("Sip Peer 1 description")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#delete' do
|
46
|
+
it 'should remove a peer' do
|
47
|
+
client.stubs.delete('/v1.0/accounts/accountId/sites/1/sippeers/11') {|env| [200, {}, '']}
|
48
|
+
item = SipPeer.new({:site_id => 1, :id => 11}, client)
|
49
|
+
item.delete()
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#get_tns' do
|
54
|
+
it 'should return list of numbers' do
|
55
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/10/tns') {|env| [200, {}, Helper.xml['sip_peer_tns']]}
|
56
|
+
item = SipPeer.new({:site_id => 1, :id => 10}, client)
|
57
|
+
list = item.get_tns()
|
58
|
+
expect(list.length).to eql(17)
|
59
|
+
expect(list[0][:full_number]).to eql("3034162216")
|
60
|
+
end
|
61
|
+
it 'should return a number' do
|
62
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/10/tns/12345') {|env| [200, {}, Helper.xml['sip_peer_tn']]}
|
63
|
+
item = SipPeer.new({:site_id => 1, :id => 10}, client)
|
64
|
+
item = item.get_tns('12345')
|
65
|
+
expect(item[:full_number]).to eql("9195551212")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#update_tns' do
|
70
|
+
it 'should update a number' do
|
71
|
+
data = {:full_number => "123456", :rewrite_user => "test"}
|
72
|
+
client.stubs.put('/v1.0/accounts/accountId/sites/1/sippeers/10/tns/123456', client.build_xml({:sip_peer_telephone_number => data})) {|env| [200, {}, '']}
|
73
|
+
item = SipPeer.new({:site_id => 1, :id => 10}, client)
|
74
|
+
item.update_tns('123456', data)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#move_tns' do
|
79
|
+
it 'should move numbers' do
|
80
|
+
data = ["11111", "22222"]
|
81
|
+
client.stubs.post('/v1.0/accounts/accountId/sites/1/sippeers/10/movetns', client.build_xml({:sip_peer_telephone_numbers => {:full_number => data}})) {|env| [200, {}, '']}
|
82
|
+
item = SipPeer.new({:site_id => 1, :id => 10}, client)
|
83
|
+
item.move_tns(data)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
describe BandwidthIris::Site 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 sites' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/sites') {|env| [200, {}, Helper.xml['sites']]}
|
15
|
+
list = Site.list(client)
|
16
|
+
expect(list.length).to eql(1)
|
17
|
+
expect(list[0][:id]).to eql(1)
|
18
|
+
expect(list[0][:name]).to eql('Test Site')
|
19
|
+
expect(list[0][:description]).to eql('A site description')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#get' do
|
24
|
+
it 'should return a site' do
|
25
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1') {|env| [200, {}, Helper.xml['site']]}
|
26
|
+
item = Site.get(client, 1)
|
27
|
+
expect(item[:id]).to eql(1)
|
28
|
+
expect(item[:name]).to eql('Test Site')
|
29
|
+
expect(item[:description]).to eql('A Site Description')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#create' do
|
34
|
+
it 'should create a site' do
|
35
|
+
data = {:name => "test", :description => "test"}
|
36
|
+
client.stubs.post('/v1.0/accounts/accountId/sites', client.build_xml({:site => data})) {|env| [200, {'Location' => '/v1.0/accounts/accountId/sites/1'}, '']}
|
37
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1') {|env| [200, {}, Helper.xml['site']]}
|
38
|
+
item = Site.create(client, data)
|
39
|
+
expect(item[:id]).to eql(1)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#update' do
|
44
|
+
it 'should update a site' do
|
45
|
+
data = {:description => "test"}
|
46
|
+
client.stubs.put('/v1.0/accounts/accountId/sites/1', client.build_xml({:site => data})) {|env| [200, {}, '']}
|
47
|
+
item = Site.new({:id => 1}, client)
|
48
|
+
item.update(data)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#delete' do
|
53
|
+
it 'should remove a site' do
|
54
|
+
client.stubs.delete('/v1.0/accounts/accountId/sites/1') {|env| [200, {}, '']}
|
55
|
+
item = Site.new({:id => 1}, client)
|
56
|
+
item.delete()
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#get_sip_peers' do
|
61
|
+
it 'should return peers' do
|
62
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers') {|env| [200, {}, Helper.xml['sip_peers']]}
|
63
|
+
site = Site.new({:id => 1}, client)
|
64
|
+
list = site.get_sip_peers()
|
65
|
+
expect(list.length).to eql(1)
|
66
|
+
expect(list[0][:id]).to eql(12345)
|
67
|
+
expect(list[0][:peer_name]).to eql("SIP Peer 1")
|
68
|
+
expect(list[0][:description]).to eql("Sip Peer 1 description")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#get_sip_peer' do
|
73
|
+
it 'should return a peer' do
|
74
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/11') {|env| [200, {}, Helper.xml['sip_peer']]}
|
75
|
+
site = Site.new({:id => 1}, client)
|
76
|
+
item = site.get_sip_peer(11)
|
77
|
+
expect(item[:id]).to eql(10)
|
78
|
+
expect(item[:peer_name]).to eql("SIP Peer 1")
|
79
|
+
expect(item[:description]).to eql("Sip Peer 1 description")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#create_sip_peer' do
|
84
|
+
it 'should create a peer' do
|
85
|
+
data = {:peer_name => "SIP Peer 1", :description => "Sip Peer 1 description"}
|
86
|
+
client.stubs.post('/v1.0/accounts/accountId/sites/1/sippeers', client.build_xml({:sip_peer => data})) {|env| [201, {'Location' => '/v1.0/accounts/accountId/sites/1/sippeers/11'}, '']}
|
87
|
+
client.stubs.get('/v1.0/accounts/accountId/sites/1/sippeers/11') {|env| [200, {}, Helper.xml['sip_peer']]}
|
88
|
+
site = Site.new({:id => 1}, client)
|
89
|
+
item = site.create_sip_peer(data)
|
90
|
+
expect(item[:id]).to eql(10)
|
91
|
+
expect(item[:peer_name]).to eql("SIP Peer 1")
|
92
|
+
expect(item[:description]).to eql("Sip Peer 1 description")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
describe BandwidthIris::Subscription 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 subscriptions' do
|
14
|
+
client.stubs.get('/v1.0/accounts/accountId/subscriptions') {|env| [200, {}, Helper.xml['subscriptions']]}
|
15
|
+
list = Subscription.list(client)
|
16
|
+
expect(list.length).to eql(1)
|
17
|
+
expect(list[0][:id]).to eql(1)
|
18
|
+
expect(list[0][:order_type]).to eql('orders')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#get' do
|
23
|
+
it 'should return a subscription' do
|
24
|
+
client.stubs.get('/v1.0/accounts/accountId/subscriptions/1') {|env| [200, {}, Helper.xml['subscriptions']]}
|
25
|
+
item = Subscription.get(client, 1)
|
26
|
+
expect(item[:id]).to eql(1)
|
27
|
+
expect(item[:order_type]).to eql('orders')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#create' do
|
32
|
+
it 'should create a subscription' do
|
33
|
+
data = {:name => "test", :description => "test"}
|
34
|
+
client.stubs.post('/v1.0/accounts/accountId/subscriptions', client.build_xml({:subscription => data})) {|env| [200, {'Location' => '/v1.0/accounts/accountId/subscriptions/1'}, '']}
|
35
|
+
client.stubs.get('/v1.0/accounts/accountId/subscriptions/1') {|env| [200, {}, Helper.xml['subscriptions']]}
|
36
|
+
item = Subscription.create(client, data)
|
37
|
+
expect(item[:id]).to eql(1)
|
38
|
+
expect(item[:order_type]).to eql('orders')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#update' do
|
43
|
+
it 'should update a subscription' do
|
44
|
+
data = {:description => "test"}
|
45
|
+
client.stubs.put('/v1.0/accounts/accountId/subscriptions/1', client.build_xml({:subscription => data})) {|env| [200, {}, '']}
|
46
|
+
item = Subscription.new({:id => 1}, client)
|
47
|
+
item.update(data)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#delete' do
|
52
|
+
it 'should remove a subscription' do
|
53
|
+
client.stubs.delete('/v1.0/accounts/accountId/subscriptions/1') {|env| [200, {}, '']}
|
54
|
+
item = Subscription.new({:id => 1}, client)
|
55
|
+
item.delete()
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|