ruby-bandwidth-iris 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,19 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
DISC_NUMBER_PATH = 'users'
|
3
|
+
|
4
|
+
class DiscNumber
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client)
|
9
|
+
client.make_request(:get, client.concat_account_path(DISC_NUMBER_PATH))[0][:telephone_numbers]
|
10
|
+
end
|
11
|
+
wrap_client_arg :list
|
12
|
+
|
13
|
+
|
14
|
+
def self.totals(client)
|
15
|
+
client.make_request(:get, "#{client.concat_account_path(DISC_NUMBER_PATH)}/totals")[0]
|
16
|
+
end
|
17
|
+
wrap_client_arg :totals
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
DISCONNECT_PATH = 'disconnects'
|
3
|
+
|
4
|
+
class Disconnect
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.create(client, order_name, numbers)
|
9
|
+
data = {
|
10
|
+
:disconnect_telephone_number_order =>{
|
11
|
+
:name => order_name,
|
12
|
+
'_nameXmlElement' => 'name',
|
13
|
+
:disconnect_telephone_number_order_type => { :telephone_number => numbers }
|
14
|
+
}
|
15
|
+
}
|
16
|
+
client.make_request(:post, client.concat_account_path(DISCONNECT_PATH), data)[0]
|
17
|
+
end
|
18
|
+
wrap_client_arg :create
|
19
|
+
|
20
|
+
def get_notes()
|
21
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(DISCONNECT_PATH)}/#{id}/notes")[0][:note]
|
22
|
+
return [] if !list
|
23
|
+
if list.is_a?(Array)
|
24
|
+
list
|
25
|
+
else
|
26
|
+
[list]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_notes(note)
|
31
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(DISCONNECT_PATH)}/#{id}/notes", {:note => note})
|
32
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
33
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
DLDA_PATH = 'dldas'
|
3
|
+
|
4
|
+
class Dlda
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client, query = nil)
|
9
|
+
list = client.make_request(:get, client.concat_account_path(DLDA_PATH), query)[0][:list_order_id_user_id_date][:order_id_user_id_date]
|
10
|
+
return [] if !list
|
11
|
+
list = if list.is_a?(Array) then list else [list] end
|
12
|
+
list.map do |i|
|
13
|
+
i[:id] = i[:order_id]
|
14
|
+
Dlda.new(i, client)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
wrap_client_arg :list
|
18
|
+
|
19
|
+
def self.get(client, id)
|
20
|
+
data = client.make_request(:get, "#{client.concat_account_path(DLDA_PATH)}/#{id}")[0][:dlda_order]
|
21
|
+
data[:id] = data[:order_id]
|
22
|
+
Dlda.new(data, client)
|
23
|
+
end
|
24
|
+
wrap_client_arg :get
|
25
|
+
|
26
|
+
def self.create(client, item)
|
27
|
+
location = client.make_request(:post, client.concat_account_path(DLDA_PATH), {:dlda_order => item})[1][:location]
|
28
|
+
id = Client.get_id_from_location_header(location)
|
29
|
+
self.get(client, id)
|
30
|
+
end
|
31
|
+
wrap_client_arg :create
|
32
|
+
|
33
|
+
|
34
|
+
def get_history()
|
35
|
+
@client.make_request(:get,"#{@client.concat_account_path(DLDA_PATH)}/#{id}/history")[0][:order_history]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
module Errors
|
3
|
+
# Generic error class
|
4
|
+
class GenericError < StandardError
|
5
|
+
# @return [String] Error code
|
6
|
+
attr_reader :code
|
7
|
+
|
8
|
+
# @return [String] Http status code
|
9
|
+
attr_reader :http_status
|
10
|
+
|
11
|
+
# @api private
|
12
|
+
def initialize code, message, http_status
|
13
|
+
super message
|
14
|
+
@code = code
|
15
|
+
@http_status = http_status
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Agregate error class
|
20
|
+
class AgregateError < StandardError
|
21
|
+
# @return [Array] errors
|
22
|
+
attr_reader :errors
|
23
|
+
|
24
|
+
# @api private
|
25
|
+
def initialize errorss
|
26
|
+
super "Multiple errors"
|
27
|
+
@errors = errors
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
IMPORT_TO_ACCOUNT_PATH = 'importToAccounts'
|
3
|
+
|
4
|
+
class ImportToAccount
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def get_notes()
|
9
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(IMPORT_TO_ACCOUNT_PATH)}/#{id}/notes")[0][:note]
|
10
|
+
return [] if !list
|
11
|
+
if list.is_a?(Array)
|
12
|
+
list
|
13
|
+
else
|
14
|
+
[list]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_notes(note)
|
19
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(IMPORT_TO_ACCOUNT_PATH)}/#{id}/notes", {:note => note})
|
20
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
21
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
INSERVICE_NUMBER_PATH = 'inserviceNumbers'
|
3
|
+
|
4
|
+
class InServiceNumber
|
5
|
+
extend ClientWrapper
|
6
|
+
|
7
|
+
def self.list(client, query = nil)
|
8
|
+
list = client.make_request(:get, client.concat_account_path(INSERVICE_NUMBER_PATH), query)[0][:telephone_numbers][:telephone_number]
|
9
|
+
return [] if !list
|
10
|
+
if list.is_a?(Array) then list else [list] end
|
11
|
+
end
|
12
|
+
wrap_client_arg :list
|
13
|
+
|
14
|
+
def self.get(client, number)
|
15
|
+
client.make_request(:get, "#{client.concat_account_path(INSERVICE_NUMBER_PATH)}/#{URI.escape(number)}")[0]
|
16
|
+
end
|
17
|
+
wrap_client_arg :get
|
18
|
+
|
19
|
+
def self.totals(client)
|
20
|
+
client.make_request(:get, "#{client.concat_account_path(INSERVICE_NUMBER_PATH)}/totals")[0]
|
21
|
+
end
|
22
|
+
wrap_client_arg :totals
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
LIDB_PATH = 'lidbs'
|
3
|
+
|
4
|
+
class Lidb
|
5
|
+
extend ClientWrapper
|
6
|
+
|
7
|
+
def self.list(client, query = nil)
|
8
|
+
client.make_request(:get, client.concat_account_path(LIDB_PATH), query)[0]
|
9
|
+
end
|
10
|
+
wrap_client_arg :list
|
11
|
+
|
12
|
+
def self.get(client, id)
|
13
|
+
client.make_request(:get, "#{client.concat_account_path(LIDB_PATH)}/#{id}")[0]
|
14
|
+
end
|
15
|
+
wrap_client_arg :get
|
16
|
+
|
17
|
+
def self.create(client, item)
|
18
|
+
location = client.make_request(:post, client.concat_account_path(LIDB_PATH), {:lidb_order => item})[1][:location]
|
19
|
+
id = Client.get_id_from_location_header(location)
|
20
|
+
self.get(client, id)
|
21
|
+
end
|
22
|
+
wrap_client_arg :create
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
LNP_CHECKER_PATH = 'lnpchecker'
|
3
|
+
|
4
|
+
class LnpChecker
|
5
|
+
extend ClientWrapper
|
6
|
+
|
7
|
+
def self.check(client, numbers, full_check = false)
|
8
|
+
data = {
|
9
|
+
:number_portability_request => {
|
10
|
+
:tn_list => {:tn => numbers}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
client.make_request(:post, "#{client.concat_account_path(LNP_CHECKER_PATH)}?fullCheck=#{full_check}", data)[0]
|
14
|
+
end
|
15
|
+
wrap_client_arg :check
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
LSR_ORDER_PATH = 'lsrorders'
|
3
|
+
|
4
|
+
class LsrOrder
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.create(client, item)
|
9
|
+
item['_sPIDXmlElement'] = 'sPID'
|
10
|
+
location = client.make_request(:post, client.concat_account_path(LSR_ORDER_PATH), {:lsr_order => item})[1][:location]
|
11
|
+
id = Client.get_id_from_location_header(location)
|
12
|
+
self.get(client, id)
|
13
|
+
end
|
14
|
+
wrap_client_arg :create
|
15
|
+
|
16
|
+
def self.list(client, query = nil)
|
17
|
+
list = client.make_request(:get, client.concat_account_path(LSR_ORDER_PATH), query)[0][:lsr_order_summary]
|
18
|
+
return [] if !list
|
19
|
+
list = if list.is_a?(Array) then list else [list] end
|
20
|
+
list.map do |i|
|
21
|
+
i[:id] = i[:order_id]
|
22
|
+
LsrOrder.new(i, client)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
wrap_client_arg :list
|
26
|
+
|
27
|
+
def self.get(client, id)
|
28
|
+
data = client.make_request(:get, "#{client.concat_account_path(LSR_ORDER_PATH)}/#{id}")[0]
|
29
|
+
data[:id] = data[:order_id]
|
30
|
+
LsrOrder.new(data, client)
|
31
|
+
end
|
32
|
+
wrap_client_arg :get
|
33
|
+
|
34
|
+
def update(data)
|
35
|
+
@client.make_request(:put,"#{@client.concat_account_path(LSR_ORDER_PATH)}/#{id}", {:lsr_order => data})
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_notes()
|
39
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(LSR_ORDER_PATH)}/#{id}/notes")[0][:note]
|
40
|
+
if list.is_a?(Array)
|
41
|
+
list
|
42
|
+
else
|
43
|
+
[list]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_notes(note)
|
48
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(LSR_ORDER_PATH)}/#{id}/notes", {:note => note})
|
49
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
50
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def get_history()
|
55
|
+
@client.make_request(:get,"#{@client.concat_account_path(LSR_ORDER_PATH)}/#{id}/history")[0][:order_history]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
ORDER_PATH = 'orders'
|
3
|
+
|
4
|
+
class Order
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.create(client, item)
|
9
|
+
data = client.make_request(:post, client.concat_account_path(ORDER_PATH), {:order => item})[0][:order]
|
10
|
+
Order.new(data, client)
|
11
|
+
end
|
12
|
+
wrap_client_arg :create
|
13
|
+
|
14
|
+
def self.get(client, id)
|
15
|
+
data = client.make_request(:get, "#{client.concat_account_path(ORDER_PATH)}/#{id}")[0][:order]
|
16
|
+
Order.new(data, client)
|
17
|
+
end
|
18
|
+
wrap_client_arg :get
|
19
|
+
|
20
|
+
def self.list(client, query = nil)
|
21
|
+
list = client.make_request(:get, client.concat_account_path(ORDER_PATH), query)[0][:orders][:order]
|
22
|
+
return [] if !list
|
23
|
+
list = if list.is_a?(Array) then list else [list] end
|
24
|
+
list.map {|i| Order.new(i, client)}
|
25
|
+
end
|
26
|
+
wrap_client_arg :list
|
27
|
+
|
28
|
+
def update(data)
|
29
|
+
@client.make_request(:put, "#{@client.concat_account_path(ORDER_PATH)}/#{id}", {:order => data})[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_notes()
|
33
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/notes")[0][:note]
|
34
|
+
return [] if !list
|
35
|
+
if list.is_a?(Array)
|
36
|
+
list
|
37
|
+
else
|
38
|
+
[list]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_notes(note)
|
43
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/notes", {:note => note})
|
44
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
45
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_area_codes()
|
49
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/areaCodes")[0][:telephone_details_report]
|
50
|
+
return [] if !list
|
51
|
+
if list.is_a?(Array) then list else [list] end
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_npa_npx()
|
55
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/npaNxx")[0][:telephone_details_report]
|
56
|
+
return [] if !list
|
57
|
+
if list.is_a?(Array) then list else [list] end
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_totals()
|
61
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/totals")[0][:telephone_details_report]
|
62
|
+
return [] if !list
|
63
|
+
if list.is_a?(Array) then list else [list] end
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_tns()
|
67
|
+
@client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/tns")[0]
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_history()
|
71
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(ORDER_PATH)}/#{id}/history")[0][:order_history]
|
72
|
+
return [] if !list
|
73
|
+
if list.is_a?(Array) then list else [list] end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
PORT_IN_PATH = 'portins'
|
3
|
+
LOAS_PATH = 'loas'
|
4
|
+
|
5
|
+
class PortIn
|
6
|
+
extend ClientWrapper
|
7
|
+
include ApiItem
|
8
|
+
|
9
|
+
def self.create(client, item)
|
10
|
+
item = client.make_request(:post, client.concat_account_path(PORT_IN_PATH), {:lnp_order => item})[0]
|
11
|
+
item[:id] = item[:order_id]
|
12
|
+
PortIn.new(item, client)
|
13
|
+
end
|
14
|
+
wrap_client_arg :create
|
15
|
+
|
16
|
+
|
17
|
+
def update(data)
|
18
|
+
@client.make_request(:put,"#{@client.concat_account_path(PORT_IN_PATH)}/#{id}", {:lnp_order_supp => data})
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete()
|
22
|
+
@client.make_request(:delete,"#{@client.concat_account_path(PORT_IN_PATH)}/#{id}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_notes()
|
26
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/notes")[0][:note]
|
27
|
+
return [] if !list
|
28
|
+
if list.is_a?(Array)
|
29
|
+
list
|
30
|
+
else
|
31
|
+
[list]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_notes(note)
|
36
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/notes", {:note => note})
|
37
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
38
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_file(io, media_type = nil)
|
42
|
+
connection = @client.create_connection()
|
43
|
+
# FIXME use streams directly when Faraday will support streaming
|
44
|
+
buf = io.read()
|
45
|
+
response = connection.post("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}") do |req|
|
46
|
+
req.headers['Content-Length'] = buf.size.to_s
|
47
|
+
req.headers['Content-Type'] = media_type || 'application/octet-stream'
|
48
|
+
req.body = buf
|
49
|
+
end
|
50
|
+
r = @client.check_response(response)
|
51
|
+
r[:filename]
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_file(file_name, file, media_type)
|
55
|
+
connection = @client.create_connection()
|
56
|
+
# FIXME use streams directly when Faraday will support streaming
|
57
|
+
buf = io.read()
|
58
|
+
response = connection.put("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{URI.encode(file_name)}") do |req|
|
59
|
+
req.headers['Content-Length'] = buf.size.to_s
|
60
|
+
req.headers['Content-Type'] = media_type || 'application/octet-stream'
|
61
|
+
req.body = buf
|
62
|
+
end
|
63
|
+
@client.check_response(response)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_file_metadata(file_name)
|
67
|
+
@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{URI.encode(file_name)}/metadata")[0]
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_file(file_name)
|
71
|
+
connection = @client.create_connection()
|
72
|
+
response = connection.get("/#{@client.api_version}#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}/#{URI.encode(file_name)}")
|
73
|
+
[response.body, response.headers['Content-Type'] || 'application/octet-stream']
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_files(metadata = false)
|
77
|
+
@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{id}/#{LOAS_PATH}", {:metadata => metadata})[0][:file_data]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
PORT_OUT_PATH = 'portouts'
|
3
|
+
|
4
|
+
class PortOut
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def get_notes()
|
9
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(PORT_OUT_PATH)}/#{id}/notes")[0][:note]
|
10
|
+
return [] if !list
|
11
|
+
if list.is_a?(Array)
|
12
|
+
list
|
13
|
+
else
|
14
|
+
[list]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_notes(note)
|
19
|
+
r = @client.make_request(:post, "#{@client.concat_account_path(PORT_OUT_PATH)}/#{id}/notes", {:note => note})
|
20
|
+
note_id = Client.get_id_from_location_header(r[1][:location])
|
21
|
+
(get_notes().select {|n| n[:id].to_s == note_id }).first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
RATE_CENTER_PATH = 'rateCenters'
|
3
|
+
|
4
|
+
class RateCenter
|
5
|
+
extend ClientWrapper
|
6
|
+
|
7
|
+
def self.list(client)
|
8
|
+
list = client.make_request(:get, RATE_CENTER_PATH)[0][:rate_centers][:rate_center]
|
9
|
+
return [] if !list
|
10
|
+
if list.is_a?(Array)
|
11
|
+
list
|
12
|
+
else
|
13
|
+
[list]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
wrap_client_arg :list
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
SIPPEER_PATH = 'sippeers'
|
3
|
+
|
4
|
+
class SipPeer
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client, site_id)
|
9
|
+
Site.new({:id => site_id}, client).get_sip_peers()
|
10
|
+
end
|
11
|
+
wrap_client_arg :list
|
12
|
+
|
13
|
+
def self.get(client, site_id, id)
|
14
|
+
Site.new({:id => site_id}, client).get_sip_peer(id)
|
15
|
+
end
|
16
|
+
wrap_client_arg :get
|
17
|
+
|
18
|
+
def self.create(client, site_id, item)
|
19
|
+
Site.new({:id => site_id}, client).create_sip_peer(item)
|
20
|
+
end
|
21
|
+
wrap_client_arg :create
|
22
|
+
|
23
|
+
def delete()
|
24
|
+
@client.make_request(:delete,"#{@client.concat_account_path(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def get_tns(number = nil)
|
29
|
+
r = @client.make_request(:get,"#{@client.concat_account_path(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{id}/tns#{if number then '/' + URI.escape(number) else '' end}")[0]
|
30
|
+
if number
|
31
|
+
r[:sip_peer_telephone_number]
|
32
|
+
else
|
33
|
+
list = r[:sip_peer_telephone_numbers][:sip_peer_telephone_number]
|
34
|
+
return [] if !list
|
35
|
+
if list.is_a?(Array) then list else [list] end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_tns(number, data)
|
40
|
+
@client.make_request(:put,"#{@client.concat_account_path(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{id}/tns/#{URI.escape(number)}", {:sip_peer_telephone_number => data})[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
def move_tns(numbers)
|
44
|
+
@client.make_request(:post,"#{@client.concat_account_path(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{id}/movetns", {:sip_peer_telephone_numbers => {:full_number => numbers}})[0]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
SITE_PATH = 'sites'
|
3
|
+
|
4
|
+
class Site
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client, query = nil)
|
9
|
+
list = client.make_request(:get, client.concat_account_path(SITE_PATH), query)[0][:sites][:site]
|
10
|
+
list = if list.is_a?(Array) then list else [list] end
|
11
|
+
list.map do |i|
|
12
|
+
Site.new(i, client)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
wrap_client_arg :list
|
16
|
+
|
17
|
+
def self.get(client, id)
|
18
|
+
data = client.make_request(:get, "#{client.concat_account_path(SITE_PATH)}/#{id}")[0]
|
19
|
+
Site.new(data[:site], client)
|
20
|
+
end
|
21
|
+
wrap_client_arg :get
|
22
|
+
|
23
|
+
def self.create(client, item)
|
24
|
+
location = client.make_request(:post, client.concat_account_path(SITE_PATH), {:site => item})[1][:location]
|
25
|
+
id = Client.get_id_from_location_header(location)
|
26
|
+
self.get(client, id)
|
27
|
+
end
|
28
|
+
wrap_client_arg :create
|
29
|
+
|
30
|
+
|
31
|
+
def update(data)
|
32
|
+
@client.make_request(:put,"#{@client.concat_account_path(SITE_PATH)}/#{id}", {:site => data})
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete()
|
36
|
+
@client.make_request(:delete,"#{@client.concat_account_path(SITE_PATH)}/#{id}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_sip_peer(peer_id)
|
40
|
+
item = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/sippeers/#{peer_id}")[0][:sip_peer]
|
41
|
+
item[:id] = item[:peer_id]
|
42
|
+
item
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_sip_peers()
|
46
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/sippeers")[0][:sip_peers][:sip_peer]
|
47
|
+
return [] if !list
|
48
|
+
list = if list.is_a?(Array) then list else [list] end
|
49
|
+
list.each {|i| i[:id] = i[:peer_id]}
|
50
|
+
list
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_sip_peer(item)
|
54
|
+
location = @client.make_request(:post, "#{@client.concat_account_path(SITE_PATH)}/#{id}/sippeers", {:sip_peer => item})[1][:location]
|
55
|
+
id = Client.get_id_from_location_header(location)
|
56
|
+
get_sip_peer(id)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_portins()
|
60
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/portins")[0]
|
61
|
+
# TODO need additional documentaion
|
62
|
+
list
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_totaltns()
|
66
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/totaltns")[0]
|
67
|
+
# TODO need additional documentaion
|
68
|
+
list
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_orders()
|
72
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/orders")[0]
|
73
|
+
# TODO need additional documentaion
|
74
|
+
list
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_inservice_numbers()
|
78
|
+
list = @client.make_request(:get, "#{@client.concat_account_path(SITE_PATH)}/#{id}/inserviceNumbers")[0]
|
79
|
+
# TODO need additional documentaion
|
80
|
+
list
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module BandwidthIris
|
2
|
+
SUBSCRIPTION_PATH = 'subscriptions'
|
3
|
+
|
4
|
+
class Subscription
|
5
|
+
extend ClientWrapper
|
6
|
+
include ApiItem
|
7
|
+
|
8
|
+
def self.list(client, query = nil)
|
9
|
+
list = client.make_request(:get, client.concat_account_path(SUBSCRIPTION_PATH), query)[0][:subscriptions][:subscription]
|
10
|
+
return [] if !list
|
11
|
+
list = if list.is_a?(Array) then list else [list] end
|
12
|
+
list.map do |i|
|
13
|
+
i[:id] = i[:subscription_id]
|
14
|
+
Subscription.new(i, client)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
wrap_client_arg :list
|
18
|
+
|
19
|
+
def self.get(client, id)
|
20
|
+
data = client.make_request(:get, "#{client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}")[0][:subscriptions][:subscription]
|
21
|
+
data[:id] = data[:subscription_id]
|
22
|
+
Subscription.new(data, client)
|
23
|
+
end
|
24
|
+
wrap_client_arg :get
|
25
|
+
|
26
|
+
def self.create(client, item)
|
27
|
+
location = client.make_request(:post, client.concat_account_path(SUBSCRIPTION_PATH), {:subscription => item})[1][:location]
|
28
|
+
id = Client.get_id_from_location_header(location)
|
29
|
+
self.get(client, id)
|
30
|
+
end
|
31
|
+
wrap_client_arg :create
|
32
|
+
|
33
|
+
|
34
|
+
def update(data)
|
35
|
+
@client.make_request(:put,"#{@client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}", {:subscription => data})
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete()
|
39
|
+
@client.make_request(:delete,"#{@client.concat_account_path(SUBSCRIPTION_PATH)}/#{id}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|