ruby-bandwidth-iris 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +0 -0
  3. data/.gitignore +0 -0
  4. data/.rspec +0 -0
  5. data/.travis.yml +0 -0
  6. data/Gemfile +0 -0
  7. data/LICENSE.txt +0 -0
  8. data/README.md +0 -0
  9. data/Rakefile +0 -0
  10. data/examples/account.rb +0 -0
  11. data/examples/available_npa_nxx.rb +0 -0
  12. data/examples/available_number.rb +0 -0
  13. data/examples/city.rb +0 -0
  14. data/examples/config.yml.example +0 -0
  15. data/examples/covered-rate-center.rb +0 -0
  16. data/examples/loa.pdf +0 -0
  17. data/examples/order.rb +0 -0
  18. data/examples/port-in.rb +0 -0
  19. data/examples/sip_peer.rb +0 -0
  20. data/examples/site.rb +0 -0
  21. data/examples/tn.rb +0 -0
  22. data/lib/bandwidth-iris/account.rb +0 -0
  23. data/lib/bandwidth-iris/api_item.rb +0 -0
  24. data/lib/bandwidth-iris/available_npa_nxx.rb +0 -0
  25. data/lib/bandwidth-iris/available_number.rb +0 -0
  26. data/lib/bandwidth-iris/city.rb +0 -0
  27. data/lib/bandwidth-iris/client.rb +27 -4
  28. data/lib/bandwidth-iris/client_wrapper.rb +0 -0
  29. data/lib/bandwidth-iris/covered_rate_center.rb +0 -0
  30. data/lib/bandwidth-iris/disc_number.rb +0 -0
  31. data/lib/bandwidth-iris/disconnect.rb +0 -0
  32. data/lib/bandwidth-iris/dlda.rb +0 -0
  33. data/lib/bandwidth-iris/errors.rb +0 -0
  34. data/lib/bandwidth-iris/import_to_account.rb +0 -0
  35. data/lib/bandwidth-iris/in_service_number.rb +0 -0
  36. data/lib/bandwidth-iris/lidb.rb +0 -0
  37. data/lib/bandwidth-iris/lnp_checker.rb +2 -1
  38. data/lib/bandwidth-iris/lsr_order.rb +0 -0
  39. data/lib/bandwidth-iris/order.rb +0 -0
  40. data/lib/bandwidth-iris/port_in.rb +0 -0
  41. data/lib/bandwidth-iris/port_out.rb +0 -0
  42. data/lib/bandwidth-iris/rate_center.rb +0 -0
  43. data/lib/bandwidth-iris/sip_peer.rb +0 -0
  44. data/lib/bandwidth-iris/site.rb +0 -0
  45. data/lib/bandwidth-iris/subscription.rb +0 -0
  46. data/lib/bandwidth-iris/tn.rb +0 -0
  47. data/lib/bandwidth-iris/tn_reservation.rb +0 -0
  48. data/lib/bandwidth-iris/user.rb +0 -0
  49. data/lib/bandwidth-iris/version.rb +1 -1
  50. data/lib/ruby-bandwidth-iris.rb +0 -0
  51. data/ruby-bandwidth-iris.gemspec +0 -0
  52. data/spec/bandwidth-iris/account_spec.rb +0 -0
  53. data/spec/bandwidth-iris/available_npa_nxx_spec.rb +0 -0
  54. data/spec/bandwidth-iris/available_number_spec.rb +0 -0
  55. data/spec/bandwidth-iris/city_spec.rb +0 -0
  56. data/spec/bandwidth-iris/client_spec.rb +14 -0
  57. data/spec/bandwidth-iris/covered_rate_center_spec.rb +0 -0
  58. data/spec/bandwidth-iris/disc_number_spec.rb +0 -0
  59. data/spec/bandwidth-iris/disconnect_spec.rb +0 -0
  60. data/spec/bandwidth-iris/dlda_spec.rb +0 -0
  61. data/spec/bandwidth-iris/import_to_account_spec.rb +0 -0
  62. data/spec/bandwidth-iris/in_service_number_spec.rb +0 -0
  63. data/spec/bandwidth-iris/lidb_spec.rb +0 -0
  64. data/spec/bandwidth-iris/lnp_checker_spec.rb +10 -0
  65. data/spec/bandwidth-iris/lsr_order_spec.rb +0 -0
  66. data/spec/bandwidth-iris/order_spec.rb +0 -0
  67. data/spec/bandwidth-iris/port_in_spec.rb +0 -0
  68. data/spec/bandwidth-iris/port_out_spec.rb +0 -0
  69. data/spec/bandwidth-iris/rate_center_spec.rb +0 -0
  70. data/spec/bandwidth-iris/sip_peer_spec.rb +0 -0
  71. data/spec/bandwidth-iris/site_spec.rb +0 -0
  72. data/spec/bandwidth-iris/subscription_spec.rb +0 -0
  73. data/spec/bandwidth-iris/tn_reservation_spec.rb +0 -0
  74. data/spec/bandwidth-iris/tn_spec.rb +0 -0
  75. data/spec/bandwidth-iris/user_spec.rb +0 -0
  76. data/spec/helper.rb +0 -0
  77. data/spec/xml.yml +0 -0
  78. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c1eb4bde307b7c240acec4154603afe59d5cc22
4
- data.tar.gz: e6b92efda744bb9302b9ffd24fe2036f4b7f7ece
3
+ metadata.gz: 5c07a2a93d28a4b21c5c1fac4c2d3fb6d70e9a14
4
+ data.tar.gz: 53ed1ef78f197603c74524930b4d2a4182f98909
5
5
  SHA512:
6
- metadata.gz: 25fd084cdb9321a9831c04e786b08fc25c8bc1cbb4c375d7ddbb13ffd8c7fab5549161829cbb245036668dd4cb5bceee6e8ef784b57236235a74f28e87b2b2bb
7
- data.tar.gz: c0f4efb3ba404436cfa7387c227e632f0225b15251f2b41617f6a8b6807e4d0fb75044867ac79178809d1fd32e1f761919254b6e9bf65809fb95e04c86b4edf5
6
+ metadata.gz: aaf2f58842efa4971157bf3f2528a267e2c33ea9f83eeabb35608ba4b077bb662d671936ceebdc1b285d76c4c15de4c9277b6410cd0d061c0838ce74df107d02
7
+ data.tar.gz: 0b39fcf710b427c0b5e8dc62efcda645f54fe98c2e4707c254a9034848b9f98d55d0f3790633fe107dfa9917590cb8202221f0a65dc57434c9168eb6828a973c
data/.editorconfig CHANGED
File without changes
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/examples/account.rb CHANGED
File without changes
File without changes
File without changes
data/examples/city.rb CHANGED
File without changes
File without changes
File without changes
data/examples/loa.pdf CHANGED
File without changes
data/examples/order.rb CHANGED
File without changes
data/examples/port-in.rb CHANGED
File without changes
data/examples/sip_peer.rb CHANGED
File without changes
data/examples/site.rb CHANGED
File without changes
data/examples/tn.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -120,7 +120,7 @@ module BandwidthIris
120
120
  end
121
121
 
122
122
  def build_xml(data)
123
- doc = build_doc(data)
123
+ doc = build_doc(data, data.keys.first.to_s().camelcase(:upper))
124
124
  doc.values.first.to_xml({:root => doc.keys.first, :skip_types => true, :indent => 0 })
125
125
  end
126
126
 
@@ -163,15 +163,19 @@ module BandwidthIris
163
163
  process_parsed_doc(doc.values.first)
164
164
  end
165
165
 
166
- def build_doc(v)
166
+ def build_doc(v, name)
167
167
  case
168
168
  when v.is_a?(Array)
169
- v.map {|i| build_doc(i)}
169
+ list = v.map {|i| build_doc(i, name)}
170
+ list.extend(XmlArraySerializer)
171
+ list.element_name = name
172
+ list
170
173
  when v.is_a?(Hash)
171
174
  result = {}
172
175
  v.each do |k, val|
173
176
  if k[0] != '_'
174
- result[v["_#{k}XmlElement"] || (k.to_s().camelcase(:upper))] = build_doc(val)
177
+ element_name = v["_#{k}XmlElement"] || (k.to_s().camelcase(:upper))
178
+ result[element_name] = build_doc(val, element_name)
175
179
  end
176
180
  end
177
181
  result
@@ -229,4 +233,23 @@ module BandwidthIris
229
233
  result
230
234
  end
231
235
  end
236
+
237
+ module XmlArraySerializer
238
+ def element_name=(name)
239
+ @element_name = name
240
+ end
241
+
242
+ def to_xml(options = {})
243
+ builder = options[:builder]
244
+ self.map do |item|
245
+ if item.class.method_defined?(:to_xml)
246
+ builder << item.to_xml({skip_instruct: true, root: @element_name, skip_types: true, indent:0})
247
+ else
248
+ builder << "<#{@element_name}>#{item}</#{@element_name}>"
249
+ end
250
+ end
251
+ builder
252
+ end
253
+ end
232
254
  end
255
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -5,9 +5,10 @@ module BandwidthIris
5
5
  extend ClientWrapper
6
6
 
7
7
  def self.check(client, numbers, full_check = false)
8
+ list = if numbers.is_a?(Array) then numbers else [numbers] end
8
9
  data = {
9
10
  :number_portability_request => {
10
- :tn_list => {:tn => numbers}
11
+ :tn_list => {:tn => list}
11
12
  }
12
13
  }
13
14
  client.make_request(:post, "#{client.concat_account_path(LNP_CHECKER_PATH)}?fullCheck=#{full_check}", data)[0]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
1
  module BandwidthIris
2
2
  # Version of this gem
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -123,3 +123,17 @@ describe BandwidthIris::Client do
123
123
  end
124
124
  end
125
125
  end
126
+
127
+ describe '#build_xml' do
128
+ client = nil
129
+ before :each do
130
+ client = Helper.get_client()
131
+ end
132
+
133
+ it 'should generate valid XML' do
134
+ expect(client.build_xml({root: {item: {value: '123'}}})).to eql('<?xml version="1.0" encoding="UTF-8"?><Root><Item><Value>123</Value></Item></Root>')
135
+ expect(client.build_xml({root: {item: [1,2,3]}})).to eql('<?xml version="1.0" encoding="UTF-8"?><Root><Item>1</Item><Item>2</Item><Item>3</Item></Root>')
136
+ expect(client.build_xml({root: {item: [{value: '111'}, {value: '222'}]}})).to eql('<?xml version="1.0" encoding="UTF-8"?><Root><Item><Value>111</Value></Item><Item><Value>222</Value></Item></Root>')
137
+ expect(client.build_xml({root: {item: [{value: [1,2,3]}, {value: '222'}]}})).to eql('<?xml version="1.0" encoding="UTF-8"?><Root><Item><Value>1</Value><Value>2</Value><Value>3</Value></Item><Item><Value>222</Value></Item></Root>')
138
+ end
139
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -19,6 +19,16 @@ describe BandwidthIris::LnpChecker do
19
19
  expect(result[:supported_rate_centers][:rate_center_group][:city]).to eql("City1")
20
20
  expect(result[:supported_rate_centers][:rate_center_group][:state]).to eql("State1")
21
21
  end
22
+
23
+ it 'should allow to use 1 number as string' do
24
+ number = '1111'
25
+ data = {:number_portability_request => {:tn_list => {:tn => number}}}
26
+ client.stubs.post('/v1.0/accounts/accountId/lnpchecker?fullCheck=true', client.build_xml(data)) {|env| [200, {}, Helper.xml['lnp_check']]}
27
+ result = LnpChecker.check(client, number, true)
28
+ expect(result[:supported_rate_centers][:rate_center_group][:rate_center]).to eql("Center1")
29
+ expect(result[:supported_rate_centers][:rate_center_group][:city]).to eql("City1")
30
+ expect(result[:supported_rate_centers][:rate_center_group][:state]).to eql("State1")
31
+ end
22
32
  end
23
33
 
24
34
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/helper.rb CHANGED
File without changes
data/spec/xml.yml CHANGED
File without changes
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Belchikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  version: '0'
225
225
  requirements: []
226
226
  rubyforge_project:
227
- rubygems_version: 2.2.2
227
+ rubygems_version: 2.6.4
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: Gem for integrating to Bandwidth's Iris API
@@ -255,4 +255,3 @@ test_files:
255
255
  - spec/bandwidth-iris/user_spec.rb
256
256
  - spec/helper.rb
257
257
  - spec/xml.yml
258
- has_rdoc: