ruby-bandwidth-iris 4.1.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 373ed29bb9cd7ef9cd436aab511587a5a937f33bebde33773b56ac916b033119
4
- data.tar.gz: ba88ef8c2ab05e21b1b6849f1578bed13367b9300949fae0fe78dfed54185402
3
+ metadata.gz: a310f197858ca07c75e98aa16fc2db569fd65e4c2a8d64a5ed132c3f44e53637
4
+ data.tar.gz: 2e64aa64f0c857a9dd11266e1eb30a85080e5c63b8b4e9801c702db8a90ed9fc
5
5
  SHA512:
6
- metadata.gz: f690327563c59dd642d22fa0736c5acfa70a8f1f2e33d1543f7ce582ea9f0a379b680324ab2099da285b00109a9ad40b4cdd1bbe9abde0c9a70792fcc7a5b6e2
7
- data.tar.gz: b121461b763ad2c51f7f4f225989b6c525c1f6d05d8b311ada7b2432b23d5e639fc4f763c70069423519d7668fd64b64b21cede50edf994b345540e1728c438e
6
+ metadata.gz: 7f412e691838e2cb84b74e34cd7680352b22f3dea1c0cc3a96d36064805d564d2b58bf53e342e2f8b2255bf4977789f2f077ec0a5915f41df043e6f86ce3dc9c
7
+ data.tar.gz: 499ed540148810117009302ddad7352fa651f4b1c1bdc65e93493b73279ea2842967126d48a022bcef047ab13b85339824577693f3e9055caaeec96fcbf26821
@@ -0,0 +1,2 @@
1
+ # Global rule:
2
+ * @Bandwidth/dx
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: Bug Report
3
- about: Create a bug report
3
+ about: Create a bug report.
4
4
  title: '[BUG] Description'
5
5
  labels: 'bug'
6
6
  ---
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ${{ matrix.os }}
13
13
  strategy:
14
14
  matrix:
15
- os: [windows-2016, windows-2019, ubuntu-18.04, ubuntu-20.04]
15
+ os: [windows-2022, windows-2019, ubuntu-18.04, ubuntu-20.04]
16
16
  ruby-version: [2.6, 2.7, 3.0]
17
17
  steps:
18
18
  - name: Checkout
data/README.md CHANGED
@@ -387,6 +387,11 @@ order.get_notes()
387
387
  ```
388
388
 
389
389
  ## Port Ins
390
+
391
+ ### List Portins
392
+ ```ruby
393
+ page = BandwidthIris::PortIn.list(client, {'page': 1, 'size': 5})
394
+ ```
390
395
  ### Create PortIn
391
396
  ```ruby
392
397
  data = {
data/examples/account.rb CHANGED
@@ -11,5 +11,10 @@ BandwidthIris::Client.global_options = {
11
11
  :password => config['password'],
12
12
  :account_id => config['account_id']
13
13
  }
14
- puts BandwidthIris::Account.get()
14
+
15
+ begin
16
+ puts BandwidthIris::Account.get()
17
+ rescue BandwidthIris::Errors::GenericError => e
18
+ puts e.message
19
+ end
15
20
 
@@ -13,5 +13,9 @@ BandwidthIris::Client.global_options = {
13
13
  }
14
14
 
15
15
 
16
- puts BandwidthIris::AvailableNpaNxx.list({:state => 'NC', :quantity => 3})
16
+ begin
17
+ puts BandwidthIris::AvailableNpaNxx.list({:state => 'NC', :quantity => 3})
18
+ rescue BandwidthIris::Errors::GenericError => e
19
+ puts e.message
20
+ end
17
21
 
@@ -13,5 +13,9 @@ BandwidthIris::Client.global_options = {
13
13
  }
14
14
 
15
15
 
16
- puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3})
16
+ begin
17
+ puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3})
18
+ rescue BandwidthIris::Errors::GenericError => e
19
+ puts e.message
20
+ end
17
21
 
@@ -12,4 +12,8 @@ BandwidthIris::Client.global_options = {
12
12
  :account_id => config['account_id']
13
13
  }
14
14
 
15
- puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3, :enable_t_n_detail => true})
15
+ begin
16
+ puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3, :enable_t_n_detail => true})
17
+ rescue BandwidthIris::Errors::GenericError => e
18
+ puts e.message
19
+ end
data/examples/city.rb CHANGED
@@ -12,5 +12,9 @@ BandwidthIris::Client.global_options = {
12
12
  :account_id => config['account_id']
13
13
  }
14
14
 
15
- puts BandwidthIris::City.list({:available => true, :state => 'NC'})
15
+ begin
16
+ puts BandwidthIris::City.list({:available => true, :state => 'NC'})
17
+ rescue BandwidthIris::Errors::GenericError => e
18
+ puts e.message
19
+ end
16
20
 
@@ -1,4 +1,4 @@
1
- api_endpoint: "https:/dashboard.bandwidth.com"
1
+ api_endpoint: "https://dashboard.bandwidth.com"
2
2
  account_id: ""
3
3
  user_name: ""
4
4
  password: ""
@@ -12,8 +12,11 @@ BandwidthIris::Client.global_options = {
12
12
  :account_id => config['account_id']
13
13
  }
14
14
 
15
-
16
- BandwidthIris::CoveredRateCenter.list({:zip => '27609', :page=>1, :size=>100}).each do |c|
17
- puts c.to_data
15
+ begin
16
+ BandwidthIris::CoveredRateCenter.list({:zip => '27609', :page=>1, :size=>100}).each do |c|
17
+ puts c.to_data
18
+ end
19
+ rescue BandwidthIris::Errors::GenericError => e
20
+ puts e.message
18
21
  end
19
22
 
data/examples/order.rb CHANGED
@@ -14,35 +14,39 @@ BandwidthIris::Client.global_options = {
14
14
 
15
15
  number = '9195551212' #exisitng number for order
16
16
 
17
+ begin
18
+ site = BandwidthIris::Site.create({
19
+ :name => "Ruby Test Site",
20
+ :description => "A Site From Ruby SDK Examples",
21
+ :address => {
22
+ :house_number => "123",
23
+ :street_name => "Anywhere St",
24
+ :city => "Raleigh",
25
+ :state_code =>"NC",
26
+ :zip => "27609",
27
+ :address_type => "Service"
28
+ }
29
+ })
30
+
31
+ order = BandwidthIris::Order.create({
32
+ :name =>"A Test Order",
33
+ :site_id => site.id,
34
+ :existing_telephone_number_order_type => {
35
+ :telephone_number_list =>
36
+ {
37
+ :telephone_number => [number]
38
+ }
39
+
40
+ }
41
+ })
42
+
43
+ puts order.to_data
44
+
45
+ order = BandwidthIris::Order.get(order.id)
46
+ rescue BandwidthIris::Errors::GenericError => e
47
+ puts e.message
48
+ end
17
49
 
18
- site = BandwidthIris::Site.create({
19
- :name => "Ruby Test Site",
20
- :description => "A Site From Ruby SDK Examples",
21
- :address => {
22
- :house_number => "123",
23
- :street_name => "Anywhere St",
24
- :city => "Raleigh",
25
- :state_code =>"NC",
26
- :zip => "27609",
27
- :address_type => "Service"
28
- }
29
- })
30
-
31
- order = BandwidthIris::Order.create({
32
- :name =>"A Test Order",
33
- :site_id => site.id,
34
- :existing_telephone_number_order_type => {
35
- :telephone_number_list =>
36
- {
37
- :telephone_number => [number]
38
- }
39
-
40
- }
41
- })
42
-
43
- puts order.to_data
44
-
45
- order = BandwidthIris::Order.get(order.id)
46
50
 
47
51
  puts order.to_data
48
52
 
data/examples/port-in.rb CHANGED
@@ -16,58 +16,62 @@ number_to_check = '+12525130283' #TODO fill with valid number
16
16
 
17
17
  host = '1.1.2.3'
18
18
 
19
+ begin
20
+ site = BandwidthIris::Site.create({
21
+ :name => "Ruby Test Site",
22
+ :description => "A Site From Ruby SDK Examples",
23
+ :address => {
24
+ :house_number => "123",
25
+ :street_name => "Anywhere St",
26
+ :city => "Raleigh",
27
+ :state_code =>"NC",
28
+ :zip => "27609",
29
+ :address_type => "Service"
30
+ }
31
+ })
19
32
 
20
- site = BandwidthIris::Site.create({
21
- :name => "Ruby Test Site",
22
- :description => "A Site From Ruby SDK Examples",
23
- :address => {
24
- :house_number => "123",
25
- :street_name => "Anywhere St",
26
- :city => "Raleigh",
27
- :state_code =>"NC",
28
- :zip => "27609",
29
- :address_type => "Service"
30
- }
31
- })
32
-
33
- data = {
34
- :peer_name => "A New SIP Peer",
35
- :is_default_peer => true,
36
- :short_messaging_protocol => "SMPP",
37
- :site_id => site[:id],
38
- :voice_hosts =>
39
- {
40
- :host => {
41
- :host_name => host
42
- }
43
- },
44
- :sms_hosts =>
45
- {
46
- :host => {
47
- :host_name => host
48
- }
49
- },
50
- :termination_hosts =>
33
+ data = {
34
+ :peer_name => "A New SIP Peer",
35
+ :is_default_peer => true,
36
+ :short_messaging_protocol => "SMPP",
37
+ :site_id => site[:id],
38
+ :voice_hosts =>
51
39
  {
52
- :termination_host => {
53
- :host_name => host,
54
- :port => 5060,
40
+ :host => {
41
+ :host_name => host
42
+ }
43
+ },
44
+ :sms_hosts =>
45
+ {
46
+ :host => {
47
+ :host_name => host
48
+ }
49
+ },
50
+ :termination_hosts =>
51
+ {
52
+ :termination_host => {
53
+ :host_name => host,
54
+ :port => 5060,
55
+ }
55
56
  }
56
- }
57
57
 
58
- }
58
+ }
59
59
 
60
- sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
60
+ sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
61
61
 
62
- res = BandwidthIris::LnpChecker.check(number_to_check)
62
+ res = BandwidthIris::LnpChecker.check(number_to_check)
63
63
 
64
- if res[:portable_numbers] && res[:portable_numbers][:tn] == number_to_check
65
- puts 'Your number is portable. Creating PortIn Order'
66
- port_in = BandwidthIris::PortIn.create(create_port_in_order(number_to_check, site, sip_peer))
67
- puts "Created order #{port_in[:id]}"
68
- port_in.create_file(File.open('./loa.pdf', 'r'), 'application/pdf')
64
+ if res[:portable_numbers] && res[:portable_numbers][:tn] == number_to_check
65
+ puts 'Your number is portable. Creating PortIn Order'
66
+ port_in = BandwidthIris::PortIn.create(create_port_in_order(number_to_check, site, sip_peer))
67
+ puts "Created order #{port_in[:id]}"
68
+ port_in.create_file(File.open('./loa.pdf', 'r'), 'application/pdf')
69
+ end
70
+ rescue BandwidthIris::Errors::GenericError => e
71
+ puts e.message
69
72
  end
70
73
 
74
+
71
75
  def create_port_in_order(number, site, sip_peer)
72
76
  {
73
77
  :site_id => site[:id],
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'yaml'
5
+ require 'ruby-bandwidth-iris'
6
+ config = YAML.load_file('config.yml')
7
+
8
+ BandwidthIris::Client.global_options = {
9
+ :api_endpoint => config['api_endpoint'],
10
+ :user_name => config['user_name'],
11
+ :password => config['password'],
12
+ :account_id => config['account_id']
13
+ }
14
+
15
+ @portins = Array.new # All portins on the account will be stored in this array
16
+ page = BandwidthIris::PortIn.list({'page': 1, 'size': 5}) # Get the first page of paginated portin results
17
+
18
+ def get_portins(page) # Recursively check for more pages of results and populate array with portins from current page
19
+ page.each do |portin|
20
+ @portins.push(portin)
21
+ end
22
+ unless page.next.nil?
23
+ get_portins(page.next)
24
+ end
25
+ end
26
+
27
+ get_portins(page)
28
+ puts "Total Port-Ins: #{@portins.length()}" # Print total number of portins on account
data/examples/sip_peer.rb CHANGED
@@ -14,47 +14,51 @@ BandwidthIris::Client.global_options = {
14
14
 
15
15
  host = '10.20.30.41'
16
16
 
17
+ begin
18
+ site = BandwidthIris::Site.create({
19
+ :name => "Ruby Test Site",
20
+ :description => "A Site From Ruby SDK Examples",
21
+ :address => {
22
+ :house_number => "123",
23
+ :street_name => "Anywhere St",
24
+ :city => "Raleigh",
25
+ :state_code =>"NC",
26
+ :zip => "27609",
27
+ :address_type => "Service"
28
+ }
29
+ })
17
30
 
18
- site = BandwidthIris::Site.create({
19
- :name => "Ruby Test Site",
20
- :description => "A Site From Ruby SDK Examples",
21
- :address => {
22
- :house_number => "123",
23
- :street_name => "Anywhere St",
24
- :city => "Raleigh",
25
- :state_code =>"NC",
26
- :zip => "27609",
27
- :address_type => "Service"
28
- }
29
- })
30
-
31
- data = {
32
- :peer_name => "A New SIP Peer",
33
- :is_default_peer => true,
34
- :short_messaging_protocol => "SMPP",
35
- :site_id => site[:id],
36
- :voice_hosts =>
37
- {
38
- :host => {
39
- :host_name => host
40
- }
41
- },
42
- :sms_hosts =>
43
- {
44
- :host => {
45
- :host_name => host
46
- }
47
- },
48
- :termination_hosts =>
31
+ data = {
32
+ :peer_name => "A New SIP Peer",
33
+ :is_default_peer => true,
34
+ :short_messaging_protocol => "SMPP",
35
+ :site_id => site[:id],
36
+ :voice_hosts =>
37
+ {
38
+ :host => {
39
+ :host_name => host
40
+ }
41
+ },
42
+ :sms_hosts =>
49
43
  {
50
- :termination_host => {
51
- :host_name => host,
52
- :port => 5060,
44
+ :host => {
45
+ :host_name => host
46
+ }
47
+ },
48
+ :termination_hosts =>
49
+ {
50
+ :termination_host => {
51
+ :host_name => host,
52
+ :port => 5060,
53
+ }
53
54
  }
54
- }
55
55
 
56
- }
57
- sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
56
+ }
57
+ sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
58
+ rescue BandwidthIris::Errors::GenericError => e
59
+ puts e.message
60
+ end
61
+
58
62
 
59
63
 
60
64
  sip_peer.delete(site[:id])
data/examples/site.rb CHANGED
@@ -12,18 +12,21 @@ BandwidthIris::Client.global_options = {
12
12
  :account_id => config['account_id']
13
13
  }
14
14
 
15
-
16
- site = BandwidthIris::Site.create({
17
- :name => "Ruby Test Sitei1",
18
- :description => "A Site From Ruby SDK Examples",
19
- :address => {
20
- :house_number => "123",
21
- :street_name => "Anywhere St",
22
- :city => "Raleigh",
23
- :state_code =>"NC",
24
- :zip => "27609",
25
- :address_type => "Service"
26
- }
27
- })
15
+ begin
16
+ site = BandwidthIris::Site.create({
17
+ :name => "Ruby Test Sitei1",
18
+ :description => "A Site From Ruby SDK Examples",
19
+ :address => {
20
+ :house_number => "123",
21
+ :street_name => "Anywhere St",
22
+ :city => "Raleigh",
23
+ :state_code =>"NC",
24
+ :zip => "27609",
25
+ :address_type => "Service"
26
+ }
27
+ })
28
+ rescue BandwidthIris::Errors::GenericError => e
29
+ puts e.message
30
+ end
28
31
 
29
32
  site.delete()
data/examples/tn.rb CHANGED
@@ -13,8 +13,11 @@ BandwidthIris::Client.global_options = {
13
13
  :account_id => config['account_id']
14
14
  }
15
15
 
16
- list = BandwidthIris::Tn.list({:npa => '818', :page => 1, :size => 100}).each do |n|
17
- puts n.to_data
16
+ begin
17
+ list = BandwidthIris::Tn.list({:npa => '818', :page => 1, :size => 100}).each do |n|
18
+ puts n.to_data
19
+ end
20
+ puts BandwidthIris::Tn.get(list[0][:full_number]).to_data
21
+ rescue BandwidthIris::Errors::GenericError => e
22
+ puts e.message
18
23
  end
19
-
20
- puts BandwidthIris::Tn.get(list[0][:full_number]).to_data
@@ -1,5 +1,6 @@
1
1
  require 'faraday'
2
2
  require 'faraday_middleware'
3
+ require 'active_support'
3
4
  require 'active_support/xml_mini'
4
5
  require 'active_support/core_ext/hash/conversions'
5
6
  require 'active_support/core_ext/string/inflections'
@@ -119,7 +120,7 @@ module BandwidthIris
119
120
  # @param response response object
120
121
  def check_response(response)
121
122
  parsed_body = parse_xml(response.body || '')
122
- raise Errors::GenericError.new('', "Http code #{response.status}", response.status) if response.status >= 400
123
+ raise Errors::GenericError.new(response.status, response.reason_phrase, response.headers, parsed_body) if response.status >= 400
123
124
  parsed_body
124
125
  end
125
126
 
@@ -2,17 +2,29 @@ module BandwidthIris
2
2
  module Errors
3
3
  # Generic error class
4
4
  class GenericError < StandardError
5
- # @return [String] Error code
6
- attr_reader :code
7
-
8
- # @return [String] Http status code
5
+ # @return [String] HTTP status code
9
6
  attr_reader :http_status
10
7
 
8
+ # return [String] Reason
9
+ attr_reader :reason
10
+
11
+ # return [Hash] Headers
12
+ attr_reader :headers
13
+
14
+ # return [Hash] Body
15
+ attr_reader :body
16
+
17
+ # @return [String] Iris Error code
18
+ attr_reader :code
19
+
11
20
  # @api private
12
- def initialize code, message, http_status
13
- super message
14
- @code = code
21
+ def initialize http_status, reason, headers, body
15
22
  @http_status = http_status
23
+ @reason = reason
24
+ @headers = headers
25
+ @body = body
26
+ @code = body.nil? ? '' : body[:error][:code]
27
+ super message = "HTTP Error\nStatus Code: #{@http_status}\nReason: #{@reason}\nHTTP Headers: #{@headers}\nResponse Body: #{@body}\nIris Error Code: #{@code}"
16
28
  end
17
29
  end
18
30
 
@@ -0,0 +1,17 @@
1
+ require "delegate"
2
+
3
+ module BandwidthIris
4
+ class PaginatedResult < SimpleDelegator
5
+ def initialize(items, links, &block)
6
+ super(items)
7
+ @links = links
8
+ @requestor = block
9
+ end
10
+
11
+ def next
12
+ return unless @links[:next]
13
+
14
+ @requestor.call(@links[:next].match(/\<([^>]+)\>/)[1].sub(/^http.*\/v1.0/, ""))
15
+ end
16
+ end
17
+ end
@@ -13,6 +13,26 @@ module BandwidthIris
13
13
  end
14
14
  wrap_client_arg :create
15
15
 
16
+ def self.list_from_page_url(client, url, query=nil)
17
+ response = client.make_request(:get, url, query)[0]
18
+ items = response[:lnp_port_info_for_given_status]
19
+ items = items.is_a?(Array) ? items : [items]
20
+ PaginatedResult.new(
21
+ items.map { |item| PortIn.new(item, client) },
22
+ response[:links]
23
+ ) do |next_url|
24
+ list_from_page_url(client, next_url)
25
+ end
26
+ end
27
+
28
+ def self.list(client, query=nil)
29
+ list_from_page_url(client, client.concat_account_path(PORT_IN_PATH), query)
30
+ end
31
+ wrap_client_arg :list
32
+
33
+ def tns
34
+ Array(@client.make_request(:get, "#{@client.concat_account_path(PORT_IN_PATH)}/#{order_id}/tns")[0][:telephone_number])
35
+ end
16
36
 
17
37
  def update(data)
18
38
  @client.make_request(:put,"#{@client.concat_account_path(PORT_IN_PATH)}/#{id}", {:lnp_order_supp => data})
@@ -37,5 +37,13 @@ module BandwidthIris
37
37
  def get_details()
38
38
  @client.make_request(:get, "#{TN_PATH}/#{CGI.escape(telephone_number)}/tndetails")[0][:telephone_number_details]
39
39
  end
40
+
41
+ def move(params)
42
+ @client.make_request(
43
+ :post,
44
+ @client.concat_account_path("moveTns"),
45
+ MoveTnsOrder: params.merge(TelephoneNumbers: { TelephoneNumber: telephone_number })
46
+ )
47
+ end
40
48
  end
41
49
  end
@@ -1,4 +1,4 @@
1
1
  module BandwidthIris
2
2
  # Version of this gem
3
- VERSION = "4.1.1"
3
+ VERSION = "5.1.0"
4
4
  end
@@ -17,6 +17,7 @@ require 'bandwidth-iris/lidb'
17
17
  require 'bandwidth-iris/lnp_checker'
18
18
  require 'bandwidth-iris/lsr_order'
19
19
  require 'bandwidth-iris/order'
20
+ require 'bandwidth-iris/paginated_result'
20
21
  require 'bandwidth-iris/port_in'
21
22
  require 'bandwidth-iris/port_out'
22
23
  require 'bandwidth-iris/rate_center'
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.add_dependency "faraday"
19
19
  spec.add_dependency "faraday_middleware"
20
20
  spec.add_dependency "nori"
21
- spec.add_dependency "activesupport", "~> 4.2.7"
21
+ spec.add_dependency "activesupport",">= 4.2.7"
22
+ spec.add_dependency "rexml"
22
23
 
23
24
  spec.add_development_dependency "bundler", ">= 1.3"
24
25
  spec.add_development_dependency "rake", ">= 11.1.0"
@@ -88,8 +88,13 @@ describe BandwidthIris::Client do
88
88
  end
89
89
 
90
90
  it 'should raise error if http status >= 400' do
91
- client.stubs.get('/v1.0/path1') { |env| [400, {}, ''] }
92
- expect{client.make_request(:get, '/path1')}.to raise_error(Errors::GenericError, "Http code 400")
91
+ client.stubs.get('/v1.0/path1') { |env| [400, {'content-type'=>'application/xml'}, '<SearchResult><Error><Code>4010</Code><Description>The state abbreviation N is not valid.</Description></Error></SearchResult>'] }
92
+ expect{client.make_request(:get, '/path1')}.to raise_error(an_instance_of(Errors::GenericError).and having_attributes({
93
+ http_status: 400,
94
+ headers: {"content-type"=>"application/xml"},
95
+ code: 4010,
96
+ body: {:error=>{:code=>4010, :description=>"The state abbreviation N is not valid."}}
97
+ }))
93
98
  end
94
99
  end
95
100
  end
@@ -9,6 +9,22 @@ describe BandwidthIris::PortIn do
9
9
  client.stubs.verify_stubbed_calls()
10
10
  end
11
11
 
12
+ describe '#list_orders' do
13
+ it 'should list port in orders' do
14
+ client.stubs.get('/v1.0/accounts/accountId/portins') {|env| [200, {}, Helper.xml['port_ins']]}
15
+ orders = PortIn.list(client)
16
+ orders.each do |order|
17
+ expect(order.class).to eql(BandwidthIris::PortIn)
18
+ end
19
+ expect(orders[0][:order_id]).to eql("ab03375f-e0a9-47f8-bd31-6d8435454a6b")
20
+ expect(orders[1][:order_id]).to eql("b2190bcc-0272-4a51-ba56-7c3d628e8706")
21
+ expect(orders[0][:lnp_losing_carrier_id]).to eql(1163)
22
+ expect(orders[1][:lnp_losing_carrier_id]).to eql(1290)
23
+ expect(orders[0][:last_modified_date]).to eql(DateTime.new(2020, 1, 15, 19, 8, 57.626))
24
+ expect(orders[1][:last_modified_date]).to eql(DateTime.new(2020, 1, 15, 19, 6, 10.085))
25
+ end
26
+ end
27
+
12
28
  describe '#create' do
13
29
  it 'should create an order' do
14
30
  data = {
@@ -27,6 +27,19 @@ describe BandwidthIris::Tn do
27
27
  end
28
28
  end
29
29
 
30
+ describe '#move' do
31
+ it 'should move a number' do
32
+ client.stubs.get('/v1.0/tns/1234') {|env| [200, {}, Helper.xml['tn']]}
33
+ tn = Tn.get(client, '1234')
34
+ client.stubs.post('/v1.0/accounts/accountId/moveTns') {|env| [201, {}, Helper.xml['tn_move']]}
35
+ order = tn.move({'SiteId': 12345, 'SipPeerId': 123450})[0][:move_tns_order]
36
+ expect(order[:created_by_user]).to eql('userapi')
37
+ expect(order[:order_id]).to eql('55689569-86a9-fe40-ab48-f12f6c11e108')
38
+ expect(order[:sip_peer_id]).to eql(123450)
39
+ expect(order[:site_id]).to eql(12345)
40
+ end
41
+ end
42
+
30
43
  describe '#get_sites' do
31
44
  it 'should return sites' do
32
45
  client.stubs.get('/v1.0/tns/1234/sites') {|env| [200, {}, Helper.xml['tn_sites']]}
data/spec/xml.yml CHANGED
@@ -13,12 +13,14 @@
13
13
  rate_centers1: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><RateCenterResponse><ResultCount>1</ResultCount><RateCenters><RateCenter><Abbreviation>ACME</Abbreviation><Name>ACME</Name></RateCenter></RateCenters></RateCenterResponse>"
14
14
  tn: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumber>1234</TelephoneNumber><Status>Inservice</Status><LastModifiedDate>2014-05-09T21:12:03.000Z</LastModifiedDate><OrderCreateDate>2014-05-09T21:12:03.835Z</OrderCreateDate><OrderId>5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04be</OrderId><OrderType>NEW_NUMBER_ORDER</OrderType><SiteId>1091</SiteId><AccountId>9500149</AccountId></TelephoneNumberResponse>"
15
15
  tns: "<?xml version=\"1.0\"?><TelephoneNumbersResponse><TelephoneNumberCount>5</TelephoneNumberCount><Links><first></first><next></next></Links><TelephoneNumbers><TelephoneNumber><City>CARY</City><Lata>426</Lata><State>NC</State><FullNumber>9192381138</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900008</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber><TelephoneNumber><City>CARY</City><Lata>426</Lata><FullNumber>9192381139</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900000</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber></TelephoneNumbers></TelephoneNumbersResponse>"
16
+ tn_move: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><MoveTnsOrderResponse><MoveTnsOrder><OrderCreateDate>2022-05-12T15:30:54.236Z</OrderCreateDate><AccountId>5551234</AccountId><CreatedByUser>userapi</CreatedByUser><OrderId>55689569-86a9-fe40-ab48-f12f6c11e108</OrderId><LastModifiedDate>2022-05-12T15:30:54.271Z</LastModifiedDate><SiteId>12345</SiteId><TelephoneNumbers><TelephoneNumber>1234</TelephoneNumber></TelephoneNumbers><ProcessingStatus>RECEIVED</ProcessingStatus><SipPeerId>123450</SipPeerId><Errors/><Warnings/></MoveTnsOrder></MoveTnsOrderResponse>"
16
17
  tn_sites: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Site><Id>1435</Id><Name>Sales Training</Name></Site>"
17
18
  tn_sip_peers: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeer><Id>4064</Id><Name>Sales</Name></SipPeer>"
18
19
  tn_rate_center: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumberDetails><State>CO</State><RateCenter>DENVER</RateCenter></TelephoneNumberDetails></TelephoneNumberResponse>"
19
20
  tn_reservation: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ReservationResponse><Reservation><ReservationId>e34474d6-1d47-486d-af32-be9f2eefdff4</ReservationId><AccountId>111</AccountId><ReservationExpires>13157</ReservationExpires><ReservedTn>9198975719</ReservedTn></Reservation></ReservationResponse>"
20
21
  tn_details: "<TelephoneNumberResponse><TelephoneNumberDetails><City>JERSEY CITY</City><Lata>224</Lata><State>NJ</State><FullNumber>2018981023</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>JERSEYCITY</RateCenter><Status>Inservice</Status><AccountId>14</AccountId><LastModified>2014-07-30T11:29:37.000Z</LastModified><Features><E911><Status>Success</Status></E911><Lidb><Status>Pending</Status><SubscriberInformation>Fred</SubscriberInformation><UseType>BUSINESS</UseType><Visibility>PUBLIC</Visibility></Lidb><Dlda><Status>Success</Status><SubscriberType>BUSINESS</SubscriberType><ListingType>LISTED</ListingType><ListingName><FirstName>Joe</FirstName><LastName>Smith</LastName></ListingName><ListAddress>true</ListAddress><Address><HouseNumber>12</HouseNumber><StreetName>ELM</StreetName><City>New York</City><StateCode>NY</StateCode><Zip>10007</Zip><Country>United States</Country><AddressType>Dlda</AddressType></Address></Dlda></Features><TnAttributes><TnAttribute>Protected</TnAttribute></TnAttributes></TelephoneNumberDetails></TelephoneNumberResponse>"
21
22
  port_in: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><LnpOrderResponse><OrderId>d28b36f7-fa96-49eb-9556-a40fca49f7c6</OrderId><Status><Code>201</Code><Description>Order request received. Please use the order id to check the status of your order later.</Description></Status><ProcessingStatus>PENDING_DOCUMENTS</ProcessingStatus><LoaAuthorizingPerson>John Doe</LoaAuthorizingPerson><Subscriber><SubscriberType>BUSINESS</SubscriberType><BusinessName>Acme Corporation</BusinessName><ServiceAddress><HouseNumber>1623</HouseNumber><StreetName>Brockton Ave #1</StreetName><City>Los Angeles</City><StateCode>CA</StateCode><Zip>90025</Zip><Country>USA</Country></ServiceAddress></Subscriber><BillingTelephoneNumber>6882015002</BillingTelephoneNumber><ListOfPhoneNumbers><PhoneNumber>6882015025</PhoneNumber><PhoneNumber>6882015026</PhoneNumber></ListOfPhoneNumbers><Triggered>false</Triggered><BillingType>PORTIN</BillingType></LnpOrderResponse>"
23
+ port_ins: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><LNPResponseWrapper><TotalCount>2</TotalCount><Links><first>Link=&lt;https://test.dashboard.bandwidth.com:443/v1.0/accounts/9900012/portins?page=1&amp;size=10&amp;date=2020-01-15&amp;status=foc&gt;;rel=\"first\";</first></Links><lnpPortInfoForGivenStatus><accountId>9900012</accountId><CountOfTNs>1</CountOfTNs><userId>System</userId><lastModifiedDate>2020-01-15T19:08:57.626Z</lastModifiedDate><OrderDate>2020-01-15T19:08:10.488Z</OrderDate><OrderId>ab03375f-e0a9-47f8-bd31-6d8435454a6b</OrderId><OrderType>port_in</OrderType><ActualFOCDate>2020-01-16T16:30:00.000Z</ActualFOCDate><BillingTelephoneNumber>9196247209</BillingTelephoneNumber><CompanyName>WandEDemo</CompanyName><LNPLosingCarrierId>1163</LNPLosingCarrierId><LNPLosingCarrierName>Bandwidth</LNPLosingCarrierName><ProcessingStatus>FOC</ProcessingStatus><RequestedFOCDate>2020-01-16T16:30:00.000Z</RequestedFOCDate><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><PON>4c129d8e-57fc-4ccb-a37d-7f21aca8b32d</PON></lnpPortInfoForGivenStatus><lnpPortInfoForGivenStatus><accountId>9900012</accountId><CountOfTNs>1</CountOfTNs><userId>gforrest</userId><lastModifiedDate>2020-01-15T19:06:10.085Z</lastModifiedDate><OrderDate>2019-10-14T17:16:41.949Z</OrderDate><OrderId>b2190bcc-0272-4a51-ba56-7c3d628e8706</OrderId><OrderType>port_in</OrderType><ActualFOCDate>2020-01-16T01:00:00.000Z</ActualFOCDate><BillingTelephoneNumber>2174101100</BillingTelephoneNumber><CompanyName>WandEDemo</CompanyName><LNPLosingCarrierId>1290</LNPLosingCarrierId><LNPLosingCarrierName>IntegraTelecom</LNPLosingCarrierName><ProcessingStatus>FOC</ProcessingStatus><RequestedFOCDate>2020-01-21T17:30:00.000Z</RequestedFOCDate><VendorId>57</VendorId><VendorName>Level 3</VendorName><PON>979E019287CDF6A1</PON></lnpPortInfoForGivenStatus></LNPResponseWrapper>"
22
24
  notes: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Notes><Note><Id>11299</Id><UserId>customer</UserId><Description>Test</Description><LastDateModifier>2014-11-20T07:08:47.000Z</LastDateModifier></Note><Note><Id>11301</Id><UserId>customer</UserId><Description>Test1</Description><LastDateModifier>2014-11-20T07:11:36.000Z</LastDateModifier></Note></Notes>"
23
25
  files: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><fileListResponse><fileCount>6</fileCount><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231534986.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231558768.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231581134.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231629005.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416231699462.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><fileData><FileName>d28b36f7-fa96-49eb-9556-a40fca49f7c6-1416232756923.txt</FileName><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData></fileData><resultCode>0</resultCode><resultMessage>LOA file list successfully returned</resultMessage></fileListResponse>"
24
26
  file_metadata: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><FileMetaData><DocumentType>LOA</DocumentType></FileMetaData>"
@@ -39,7 +41,6 @@
39
41
  users: "<?xml version=\"1.0\"?><UsersResponse><Users><User><Username>testcustomer</Username><FirstName>Jane</FirstName><LastName>Doe</LastName><EmailAddress>janedoe@bandwidth.com</EmailAddress><TelephoneNumber>9199999999</TelephoneNumber></User><User><Username>johndoe</Username><FirstName>John</FirstName><LastName>Doe</LastName><EmailAddress>johndoe@bandwidth.com</EmailAddress><TelephoneNumber>9199999998</TelephoneNumber></User></Users></UsersResponse>"
40
42
  dldas: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><ResponseSelectWrapper><ListOrderIdUserIdDate><TotalCount>3</TotalCount><OrderIdUserIdDate><accountId>14</accountId><CountOfTNs>2</CountOfTNs><userId>team_ua</userId><lastModifiedDate>2014-07-07T10:06:43.427Z</lastModifiedDate><OrderType>dlda</OrderType><OrderDate>2014-07-07T10:06:43.427Z</OrderDate><orderId>37a6447c-1a0b-4be9-ba89-3f5cb0aea142</orderId><OrderStatus>FAILED</OrderStatus></OrderIdUserIdDate><OrderIdUserIdDate><accountId>14</accountId><CountOfTNs>2</CountOfTNs><userId>team_ua</userId><lastModifiedDate>2014-07-07T10:05:56.595Z</lastModifiedDate><OrderType>dlda</OrderType><OrderDate>2014-07-07T10:05:56.595Z</OrderDate><orderId>743b0e64-3350-42e4-baa6-406dac7f4a85</orderId><OrderStatus>RECEIVED</OrderStatus></OrderIdUserIdDate><OrderIdUserIdDate><accountId>14</accountId><CountOfTNs>2</CountOfTNs><userId>team_ua</userId><lastModifiedDate>2014-07-07T09:32:17.234Z</lastModifiedDate><OrderType>dlda</OrderType><OrderDate>2014-07-07T09:32:17.234Z</OrderDate><orderId>f71eb4d2-bfef-4384-957f-45cd6321185e</orderId><OrderStatus>RECEIVED</OrderStatus></OrderIdUserIdDate></ListOrderIdUserIdDate></ResponseSelectWrapper>"
41
43
  dlda: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><DldaOrderResponse><DldaOrder><CustomerOrderId>5a88d16d-f8a9-45c5-a5db-137d700c6a22</CustomerOrderId><OrderCreateDate>2014-07-10T12:38:11.833Z</OrderCreateDate><AccountId>14</AccountId><CreatedByUser>jbm</CreatedByUser><OrderId>ea9e90c2-77a4-4f82-ac47-e1c5bb1311f4</OrderId><LastModifiedDate>2014-07-10T12:38:11.833Z</LastModifiedDate><ProcessingStatus>RECEIVED</ProcessingStatus><DldaTnGroups><DldaTnGroup><TelephoneNumbers><TelephoneNumber>2053778335</TelephoneNumber><TelephoneNumber>2053865784</TelephoneNumber></TelephoneNumbers><AccountType>BUSINESS</AccountType><ListingType>LISTED</ListingType><ListingName><FirstName>Joe</FirstName><LastName>Smith</LastName></ListingName><ListAddress>true</ListAddress><Address><HouseNumber>12</HouseNumber><StreetName>ELM</StreetName><City>New York</City><StateCode>NY</StateCode><Zip>10007</Zip><Country>United States</Country><AddressType>Dlda</AddressType></Address></DldaTnGroup></DldaTnGroups></DldaOrder></DldaOrderResponse>"
42
- order_history: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><OrderHistoryWrapper><OrderHistory><OrderDate>2014-05-20T14:21:43.937Z</OrderDate><Note>Order backordered - awaiting additional numbers</Note><Status>BACKORDERED</Status></OrderHistory><OrderHistory><OrderDate>2014-05-20T14:24:43.428Z</OrderDate><Note>Order backordered - awaiting additional numbers</Note><Author>System</Author><Status>BACKORDERED</Status><Difference></Difference></OrderHistory></OrderHistoryWrapper>"
43
44
  in_service_numbers: "<?xml version=\"1.0\"?><TNs><TotalCount>59</TotalCount><Links><first> ( a link goes here ) </first></Links><TelephoneNumbers><Count>59</Count><TelephoneNumber>8043024183</TelephoneNumber><TelephoneNumber>8042121778</TelephoneNumber><TelephoneNumber>8042146066</TelephoneNumber><TelephoneNumber>8043814903</TelephoneNumber><TelephoneNumber>8043814905</TelephoneNumber><TelephoneNumber>8043814864</TelephoneNumber><TelephoneNumber>8043326094</TelephoneNumber><TelephoneNumber>8042121771</TelephoneNumber><TelephoneNumber>8043024182</TelephoneNumber><!-- SNIP --><TelephoneNumber>8043814900</TelephoneNumber><TelephoneNumber>8047672642</TelephoneNumber><TelephoneNumber>8043024368</TelephoneNumber><TelephoneNumber>8042147950</TelephoneNumber><TelephoneNumber>8043169931</TelephoneNumber><TelephoneNumber>8043325302</TelephoneNumber></TelephoneNumbers></TNs>"
44
45
  in_service_numbers_totals: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Quantity><Count>3</Count></Quantity>"
45
46
  lidbs: "<?xml version=\"1.0\"?><ResponseSelectWrapper><ListOrderIdUserIdDate><TotalCount>2122</TotalCount><OrderIdUserIdDate><accountId>9999999</accountId><CountOfTNs>0</CountOfTNs><lastModifiedDate>2014-02-25T16:02:43.195Z</lastModifiedDate><OrderType>lidb</OrderType><OrderDate>2014-02-25T16:02:43.195Z</OrderDate><orderId>abe36738-6929-4c6f-926c-88e534e2d46f</orderId><OrderStatus>FAILED</OrderStatus><TelephoneNumberDetails/><userId>team_ua</userId></OrderIdUserIdDate><!-- ...SNIP... --><OrderIdUserIdDate><accountId>9999999</accountId><CountOfTNs>0</CountOfTNs><lastModifiedDate>2014-02-25T16:02:39.021Z</lastModifiedDate><OrderType>lidb</OrderType><OrderDate>2014-02-25T16:02:39.021Z</OrderDate><orderId>ba5b6297-139b-4430-aab0-9ff02c4362f4</orderId><OrderStatus>FAILED</OrderStatus><userId>team_ua</userId></OrderIdUserIdDate></ListOrderIdUserIdDate></ResponseSelectWrapper>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bandwidth-iris
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Belchikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -70,16 +70,30 @@ dependencies:
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 4.2.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.2.7
83
+ - !ruby/object:Gem::Dependency
84
+ name: rexml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -129,10 +143,10 @@ extensions: []
129
143
  extra_rdoc_files: []
130
144
  files:
131
145
  - ".editorconfig"
146
+ - ".github/CODEOWNERS"
132
147
  - ".github/ISSUE_TEMPLATE/bug_report.md"
133
148
  - ".github/ISSUE_TEMPLATE/config.yml"
134
149
  - ".github/workflows/deploy.yml"
135
- - ".github/workflows/release-draft.yml"
136
150
  - ".github/workflows/test.yml"
137
151
  - ".gitignore"
138
152
  - ".rspec"
@@ -153,6 +167,7 @@ files:
153
167
  - examples/order.rb
154
168
  - examples/order_number.rb
155
169
  - examples/port-in.rb
170
+ - examples/portin_list.rb
156
171
  - examples/sip_peer.rb
157
172
  - examples/site.rb
158
173
  - examples/tn.rb
@@ -182,6 +197,7 @@ files:
182
197
  - lib/bandwidth-iris/lnp_checker.rb
183
198
  - lib/bandwidth-iris/lsr_order.rb
184
199
  - lib/bandwidth-iris/order.rb
200
+ - lib/bandwidth-iris/paginated_result.rb
185
201
  - lib/bandwidth-iris/port_in.rb
186
202
  - lib/bandwidth-iris/port_out.rb
187
203
  - lib/bandwidth-iris/rate_center.rb
@@ -255,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
271
  - !ruby/object:Gem::Version
256
272
  version: '0'
257
273
  requirements: []
258
- rubygems_version: 3.2.32
274
+ rubygems_version: 3.2.33
259
275
  signing_key:
260
276
  specification_version: 4
261
277
  summary: Gem for integrating to Bandwidth's Iris API
@@ -1,19 +0,0 @@
1
- name: Create/update draft release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- deploy:
10
- name: deploy
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
- # Drafts your next Release notes as Pull Requests are merged
15
- - uses: release-drafter/release-drafter@v5
16
- with:
17
- config-name: draft_release.yml
18
- env:
19
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}