ruby-bandwidth-iris 2.1.0 → 2.2.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: 7b1159ee27c2a2ee423bdd0ce54a1b0943749127da435a611eeb113dec178ad0
4
- data.tar.gz: a7e09992b64e938a9dc1c3943ee8be92dc9d6b8a1ed9d3b722268879a35779bd
3
+ metadata.gz: b38867e95d7ff4df6b99dccd34053aee236600eafae007ca2ff81c7a7ae8c30e
4
+ data.tar.gz: a8c7e2a15ea0330c21bd1303e21df32463c2d76f051fe29bdf3fc30da77ce9ca
5
5
  SHA512:
6
- metadata.gz: bc146c9252add1af25853dd70416d790ba9bb5ad8b74adb6f1575e95b754cd6dcf5d5875112060b643493fcc4b970df156c8d8072db1d054c8f68a6c49faaf87
7
- data.tar.gz: 33db19d5c8f58b4632206a82333fd526b708726b8fbed3d71ba8efe6841708a19d29e66e2a9f1357f7a3caab668c2ff132422e34116e45bbdc33b3c7aee79516
6
+ metadata.gz: 589d2010d44909cb6596974f08484729e29ba4963ae360d849f86f7d55361c68c262c3cb4d8a0376ea8c5efae24e5e80abb7a85e8985fff4f3a4db6994c28e47
7
+ data.tar.gz: 03f6ccdff3f5bacfe5395b5bcf6bff95fec5dc72695396f7395dff33947a6e7ce0a3c221226bd482672fcb24c3e2d09c4d02537cfea0c096488784f17fba80f0
data/README.md CHANGED
@@ -12,6 +12,7 @@ Ruby Client library for IRIS / BBS API
12
12
  | 2.0.0 | Added `importTnOrders`, `removeImportedTnOrders`, `inserviceNumbers`, and `importTnChecker` endpoints. This release also changed the response body of `BandwidthIris::InServiceNumber.list()`. Please make sure to update your code to include this change. |
13
13
  | 2.0.1 | Updated gem dependencies to be less restrictive |
14
14
  | 2.1.0 | Added `csrs` endpoints |
15
+ | 2.2.0 | Added `loas` endpoints to `importTnOrders` |
15
16
 
16
17
  ## Install
17
18
 
@@ -604,6 +605,7 @@ tn.delete()
604
605
  import_tn_order = {
605
606
  :customer_order_id => "id",
606
607
  :site_id => "12345",
608
+ :sip_peer_id => "23456",
607
609
  :subscriber => {
608
610
  :service_address => {
609
611
  :city => "city",
@@ -696,6 +698,71 @@ response = BandwidthIris::RemoveImportedTnOrders.create_remove_imported_tn_order
696
698
  puts response
697
699
  ```
698
700
 
701
+ ### Get LOAs
702
+ ```ruby
703
+ response = BandwidthIris::ImportTnOrders.get_loa_files("order_id")
704
+ puts response[0][:result_message]
705
+ puts response[0][:file_names] #this can be a single string (if there's 1 file) or an array of strings (if there's multiple files)
706
+ ```
707
+
708
+ ### Upload LOA
709
+ Valid `mime_types` can be found on the [Dashboard API Reference](https://dev.bandwidth.com/numbers/apiReference.html) under `/accounts /{accountId} /importTnOrders /{orderid} /loas`
710
+
711
+ Mime types are expected to be in the format `x/y`, such as `application/pdf` or `text/plain`
712
+
713
+ ```ruby
714
+ BandwidthIris::ImportTnOrders.upload_loa_file("order_id", "binary_file_contents", "mime_type")
715
+ ```
716
+
717
+ ```ruby
718
+ f = open("loa.pdf", "rb")
719
+ file_content = f.read
720
+ f.close()
721
+
722
+ BandwidthIris::ImportTnOrders.upload_loa_file("order_id", file_content, "application/pdf")
723
+ ```
724
+
725
+ ### Download LOA
726
+ Note: Make sure to grab the desired file ID from the response of `BandwidthIris::ImportTnOrders.get_loa_files("order_id")` in the field `response[0][:file_names]`
727
+
728
+ ```ruby
729
+ f = open("write.pdf", "wb")
730
+ response = BandwidthIris::ImportTnOrders.download_loa_file("order_id", "file_id")
731
+ f.puts(response)
732
+ f.close()
733
+ ```
734
+
735
+ ### Replace LOA
736
+ ```ruby
737
+ BandwidthIris::ImportTnOrders.replace_loa_file("order_id", "file_id", "binary_file_contents", "mime_type")
738
+ ```
739
+
740
+ ### Delete LOA
741
+ ```ruby
742
+ BandwidthIris::ImportTnOrders.delete_loa_file("order_id", "file_id")
743
+ ```
744
+
745
+ ### Get LOA Metadata
746
+ ```ruby
747
+ response = BandwidthIris::ImportTnOrders.get_loa_file_metadata("order_id", "file_id")
748
+ puts response[0][:document_name]
749
+ puts response[0][:file_name]
750
+ ```
751
+
752
+ ### Update LOA Metadata
753
+ ```ruby
754
+ metadata = {
755
+ :document_name => "file_name",
756
+ :document_type => "LOA"
757
+ }
758
+ BandwidthIris::ImportTnOrders.update_loa_file_metadata("order_id", "file_id", metadata)
759
+ ```
760
+
761
+ ### Delete LOA Metadata
762
+ ```ruby
763
+ BandwidthIris::ImportTnOrders.delete_loa_file_metadata("order_id", "file_id")
764
+ ```
765
+
699
766
  ## CSR
700
767
 
701
768
  ### Create CSR Order
@@ -83,6 +83,37 @@ module BandwidthIris
83
83
  [body || {}, symbolize(response.headers || {})]
84
84
  end
85
85
 
86
+ # Makes an HTTP request for file uploads
87
+ # @param method [Symbol] http method to make
88
+ # @param path [string] path of url (exclude api verion and endpoint) to make call
89
+ # @param data [string] the raw binary string representing the file to upload
90
+ # @param content_type [string] the content type of the request
91
+ # @return [Array] array with 2 elements: parsed data of response and response headers
92
+ def make_request_file_upload(method, path, data, content_type)
93
+ connection = @create_connection.call()
94
+ response = connection.run_request(method, @build_path.call(path), data, {'Content-Type' => content_type})
95
+ body = check_response(response)
96
+ [body || {}, symbolize(response.headers || {})]
97
+ end
98
+
99
+ # Makes an HTTP request for a file download
100
+ # @param method [Symbol] http method to make
101
+ # @param path [string] path of url (exclude api verion and endpoint) to make call
102
+ # @param data [Hash] data which will be sent with request (for :get and :delete request they will be sent with query in url)
103
+ # @return [string] raw response from the API
104
+ def make_request_file_download(method, path, data = {})
105
+ connection = @create_connection.call()
106
+ response = if method == :get || method == :delete
107
+ d = camelcase(data)
108
+ connection.run_request(method, @build_path.call(path), nil, nil) do |req|
109
+ req.params = d unless d == nil || d.empty?
110
+ end
111
+ else
112
+ connection.run_request(method, @build_path.call(path), build_xml(data), {'Content-Type' => 'application/xml'})
113
+ end
114
+ return response.body
115
+ end
116
+
86
117
  # Check response object and raise error if status code >= 400
87
118
  # @param response response object
88
119
  def check_response(response)
@@ -1,5 +1,5 @@
1
1
  module BandwidthIris
2
- IMPORT_TN_ORDERS_PATH = "importTnOrders"
2
+ IMPORT_TN_ORDERS_PATH = "importtnorders"
3
3
 
4
4
  class ImportTnOrders
5
5
  extend ClientWrapper
@@ -28,5 +28,48 @@ module BandwidthIris
28
28
  return data
29
29
  end
30
30
  wrap_client_arg :create_import_tn_order
31
+
32
+ def self.get_loa_files(client, order_id)
33
+ data = client.make_request(:get, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}"))
34
+ return data
35
+ end
36
+ wrap_client_arg :get_loa_files
37
+
38
+ def self.upload_loa_file(client, order_id, file_contents, mime_type)
39
+ client.make_request_file_upload(:post, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}"), file_contents, mime_type)
40
+ end
41
+ wrap_client_arg :upload_loa_file
42
+
43
+ def self.download_loa_file(client, order_id, file_id)
44
+ data = client.make_request_file_download(:get, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}"))
45
+ return data
46
+ end
47
+ wrap_client_arg :download_loa_file
48
+
49
+ def self.replace_loa_file(client, order_id, file_id, file_contents, mime_type)
50
+ data = client.make_request_file_upload(:put, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}"), file_contents, mime_type)
51
+ end
52
+ wrap_client_arg :replace_loa_file
53
+
54
+ def self.delete_loa_file(client, order_id, file_id)
55
+ client.make_request(:delete, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}"))
56
+ end
57
+ wrap_client_arg :delete_loa_file
58
+
59
+ def self.get_loa_file_metadata(client, order_id, file_id)
60
+ data = client.make_request(:get, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}/metadata"))
61
+ return data
62
+ end
63
+ wrap_client_arg :get_loa_file_metadata
64
+
65
+ def self.update_loa_file_metadata(client, order_id, file_id, file_metadata)
66
+ client.make_request(:put, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}/metadata"), {:file_meta_data => file_metadata})
67
+ end
68
+ wrap_client_arg :update_loa_file_metadata
69
+
70
+ def self.delete_loa_file_metadata(client, order_id, file_id)
71
+ client.make_request(:delete, client.concat_account_path("#{IMPORT_TN_ORDERS_PATH}/#{order_id}/#{LOAS_PATH}/#{file_id}/metadata"))
72
+ end
73
+ wrap_client_arg :delete_loa_file_metadata
31
74
  end
32
75
  end
@@ -1,4 +1,4 @@
1
1
  module BandwidthIris
2
2
  # Version of this gem
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
@@ -11,7 +11,7 @@ describe BandwidthIris::ImportTnOrders do
11
11
 
12
12
  describe '#create' do
13
13
  it 'should get an order' do
14
- client.stubs.get('/v1.0/accounts/accountId/importTnOrders', {}) {|env| [200, {}, '']}
14
+ client.stubs.get('/v1.0/accounts/accountId/importtnorders', {}) {|env| [200, {}, '']}
15
15
  item = ImportTnOrders.get_import_tn_orders(client)
16
16
  end
17
17
  end
@@ -19,7 +19,7 @@ describe BandwidthIris::ImportTnOrders do
19
19
  describe '#get' do
20
20
  it 'should get an order' do
21
21
  order = "123"
22
- client.stubs.get("/v1.0/accounts/accountId/importTnOrders/#{order}", {}) {|env| [200, {}, '']}
22
+ client.stubs.get("/v1.0/accounts/accountId/importtnorders/#{order}", {}) {|env| [200, {}, '']}
23
23
  item = ImportTnOrders.get_import_tn_order(client, order)
24
24
  end
25
25
  end
@@ -27,7 +27,7 @@ describe BandwidthIris::ImportTnOrders do
27
27
  describe '#get history' do
28
28
  it 'should get an order history' do
29
29
  order = "123"
30
- client.stubs.get("/v1.0/accounts/accountId/importTnOrders/#{order}/history", {}) {|env| [200, {}, '']}
30
+ client.stubs.get("/v1.0/accounts/accountId/importtnorders/#{order}/history", {}) {|env| [200, {}, '']}
31
31
  item = ImportTnOrders.get_import_tn_order_history(client, order)
32
32
  end
33
33
  end
@@ -37,8 +37,86 @@ describe BandwidthIris::ImportTnOrders do
37
37
  data = {
38
38
  :id => "id"
39
39
  }
40
- client.stubs.post("/v1.0/accounts/accountId/importTnOrders", client.build_xml({:import_tn_order => data})) {|env| [200, {}, '']}
40
+ client.stubs.post("/v1.0/accounts/accountId/importtnorders", client.build_xml({:import_tn_order => data})) {|env| [200, {}, '']}
41
41
  item = ImportTnOrders.create_import_tn_order(client, data)
42
42
  end
43
43
  end
44
+
45
+ describe '#get loa files' do
46
+ it 'should get loa files' do
47
+ order = "123"
48
+ client.stubs.get("/v1.0/accounts/accountId/importtnorders/#{order}/loas") {|env| [200, {}, '']}
49
+ item = ImportTnOrders.get_loa_files(client, order)
50
+ end
51
+ end
52
+
53
+ describe '#upload loa file' do
54
+ it 'should upload loa file' do
55
+ file = '12345'
56
+ mime_type = 'text/plain'
57
+ order = '123'
58
+ client.stubs.post("/v1.0/accounts/accountId/importtnorders/#{order}/loas", file) {|env| [200, {}, '']}
59
+ item = ImportTnOrders.upload_loa_file(client, order, file, mime_type)
60
+ end
61
+ end
62
+
63
+ describe '#download loa file' do
64
+ it 'should download loa file' do
65
+ order = "123"
66
+ file_id = "456"
67
+ client.stubs.get("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}") {|env| [200, {}, '']}
68
+ item = ImportTnOrders.download_loa_file(client, order, file_id)
69
+ end
70
+ end
71
+
72
+ describe '#replace loa file' do
73
+ it 'should replace loa file' do
74
+ file = '12345'
75
+ mime_type = 'text/plain'
76
+ order = '123'
77
+ file_id = '456'
78
+ client.stubs.put("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}", file) {|env| [200, {}, '']}
79
+ item = ImportTnOrders.replace_loa_file(client, order, file_id, file, mime_type)
80
+ end
81
+ end
82
+
83
+ describe '#delete loa file' do
84
+ it 'should delete loa file' do
85
+ order = '123'
86
+ file_id = '456'
87
+ client.stubs.delete("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}") {|env| [200, {}, '']}
88
+ item = ImportTnOrders.delete_loa_file(client, order, file_id)
89
+ end
90
+ end
91
+
92
+ describe '#get loa file metadata' do
93
+ it 'should get loa file metadata' do
94
+ order = "123"
95
+ file_id = "456"
96
+ client.stubs.get("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}/metadata") {|env| [200, {}, '']}
97
+ item = ImportTnOrders.get_loa_file_metadata(client, order, file_id)
98
+ end
99
+ end
100
+
101
+ describe '#update loa file metadata' do
102
+ it 'should update loa file metadata' do
103
+ data = {
104
+ :test => "1234"
105
+ }
106
+ order = "123"
107
+ file_id = "456"
108
+ client.stubs.put("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}/metadata", client.build_xml({:file_meta_data => data})) {|env| [200, {}, '']}
109
+ item = ImportTnOrders.update_loa_file_metadata(client, order, file_id, data)
110
+ end
111
+ end
112
+
113
+ describe '#delete loa file metadata' do
114
+ it 'should delete loa file metadata' do
115
+ order = "123"
116
+ file_id = "456"
117
+ client.stubs.delete("/v1.0/accounts/accountId/importtnorders/#{order}/loas/#{file_id}/metadata") {|env| [200, {}, '']}
118
+ item = ImportTnOrders.delete_loa_file_metadata(client, order, file_id)
119
+ end
120
+ end
121
+
44
122
  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: 2.1.0
4
+ version: 2.2.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: 2020-02-28 00:00:00.000000000 Z
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder