ruby-bandwidth-iris 4.2.0 → 5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 357817b797657f2774dcc40552d77a0cb89f40af087ff1ae2b0034be3705a940
4
- data.tar.gz: ac3b0522e1bd592dfdadb14ec58cf38e9089e25b74316a912e03458eb8be47a7
3
+ metadata.gz: f77d77b3e9fd1b459cab7159cff5f35ec0d4dcb00186e70d54106382c3156d20
4
+ data.tar.gz: d08b335e9133e43b37bc5d79381eda44fc9aed4cca7e91905887d9e5e1b2282e
5
5
  SHA512:
6
- metadata.gz: 25debb84b4997bef6beb4863eec6db8fc33f472bab4aacb160dec6435abdb26aeb1e0c5a3f73dc1168a5624cd0604bb9c37b65eecd4700f69e5726550a503fce
7
- data.tar.gz: 1c5c4ed9c913d524336887cf618e76c6685d567f565246b8b6770f5f794714b6955ee4ef53341a602d7520dd7e20c36aa86534a4d80a0e785b648efcc9eeb8f4
6
+ metadata.gz: c359fa2a8b0a422f13262cefb9006d2e236728bda17d91184f50c8ec63b4c3f44348cadbd954987997ffc3dccc3670abf120997acc7c7cfb8350f794ef9b0a74
7
+ data.tar.gz: 4ec6c1230937b62513f1950652b11906b2090265a2ea97a1a38f737fe166d411ea0943b93fe24770adec385e3bc35e3cc2415d573c61c5acd40c5920901a8cbf
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],
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
@@ -14,7 +14,7 @@ module BandwidthIris
14
14
  # return [Hash] Body
15
15
  attr_reader :body
16
16
 
17
- # @return [String] Error code
17
+ # @return [String] Iris Error code
18
18
  attr_reader :code
19
19
 
20
20
  # @api private
@@ -23,8 +23,8 @@ module BandwidthIris
23
23
  @reason = reason
24
24
  @headers = headers
25
25
  @body = body
26
- @code = '' # Iris Error Code can be accessed with body[:error][:code]
27
- super message = "Http code #{@http_status}"
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}"
28
28
  end
29
29
  end
30
30
 
@@ -1,4 +1,4 @@
1
1
  module BandwidthIris
2
2
  # Version of this gem
3
- VERSION = "4.2.0"
3
+ VERSION = "5.0.0"
4
4
  end
@@ -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
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.2.0
4
+ version: 5.0.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-04-12 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder