vonage 7.8.2 → 7.36.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +880 -87
  3. data/lib/vonage/account.rb +2 -0
  4. data/lib/vonage/api_error.rb +33 -0
  5. data/lib/vonage/applications.rb +12 -4
  6. data/lib/vonage/basic.rb +1 -1
  7. data/lib/vonage/basic_and_bearer_token.rb +18 -0
  8. data/lib/vonage/basic_and_signature.rb +22 -0
  9. data/lib/vonage/bearer_token.rb +1 -1
  10. data/lib/vonage/client.rb +79 -0
  11. data/lib/vonage/client_error.rb +1 -1
  12. data/lib/vonage/config.rb +11 -1
  13. data/lib/vonage/conversation/event/list_response.rb +11 -0
  14. data/lib/vonage/conversation/event.rb +108 -0
  15. data/lib/vonage/conversation/list_response.rb +11 -0
  16. data/lib/vonage/conversation/member/list_response.rb +11 -0
  17. data/lib/vonage/conversation/member.rb +134 -0
  18. data/lib/vonage/conversation/user/conversations_list_response.rb +11 -0
  19. data/lib/vonage/conversation/user/sessions_list_response.rb +11 -0
  20. data/lib/vonage/conversation/user.rb +67 -0
  21. data/lib/vonage/conversation.rb +164 -0
  22. data/lib/vonage/conversations/events.rb +12 -0
  23. data/lib/vonage/conversations/legs.rb +6 -0
  24. data/lib/vonage/conversations/members.rb +15 -0
  25. data/lib/vonage/conversations/users.rb +15 -0
  26. data/lib/vonage/conversations.rb +30 -0
  27. data/lib/vonage/conversions.rb +2 -0
  28. data/lib/vonage/errors.rb +37 -20
  29. data/lib/vonage/http.rb +3 -3
  30. data/lib/vonage/identity_insights/insights_builder.rb +75 -0
  31. data/lib/vonage/identity_insights.rb +75 -0
  32. data/lib/vonage/jwt.rb +17 -0
  33. data/lib/vonage/key_secret_params.rb +3 -2
  34. data/lib/vonage/keys.rb +24 -1
  35. data/lib/vonage/logger.rb +0 -3
  36. data/lib/vonage/meetings/applications.rb +28 -0
  37. data/lib/vonage/meetings/dial_in_numbers/list_response.rb +11 -0
  38. data/lib/vonage/meetings/dial_in_numbers.rb +26 -0
  39. data/lib/vonage/meetings/recordings.rb +42 -0
  40. data/lib/vonage/meetings/rooms/list_response.rb +11 -0
  41. data/lib/vonage/meetings/rooms.rb +167 -0
  42. data/lib/vonage/meetings/sessions/list_response.rb +11 -0
  43. data/lib/vonage/meetings/sessions.rb +31 -0
  44. data/lib/vonage/meetings/themes/list_response.rb +11 -0
  45. data/lib/vonage/meetings/themes.rb +239 -0
  46. data/lib/vonage/meetings.rb +50 -0
  47. data/lib/vonage/messaging/channels/messenger.rb +2 -0
  48. data/lib/vonage/messaging/channels/mms.rb +13 -3
  49. data/lib/vonage/messaging/channels/rcs.rb +44 -0
  50. data/lib/vonage/messaging/channels/sms.rb +2 -0
  51. data/lib/vonage/messaging/channels/viber.rb +11 -2
  52. data/lib/vonage/messaging/channels/whats_app.rb +5 -1
  53. data/lib/vonage/messaging/message.rb +4 -1
  54. data/lib/vonage/messaging.rb +43 -4
  55. data/lib/vonage/namespace.rb +152 -69
  56. data/lib/vonage/network_authentication/client_authentication.rb +39 -0
  57. data/lib/vonage/network_authentication/server_authentication.rb +47 -0
  58. data/lib/vonage/network_authentication.rb +22 -0
  59. data/lib/vonage/network_number_verification.rb +92 -0
  60. data/lib/vonage/network_sim_swap.rb +84 -0
  61. data/lib/vonage/number_insight.rb +1 -0
  62. data/lib/vonage/number_insight_2.rb +21 -0
  63. data/lib/vonage/numbers.rb +40 -17
  64. data/lib/vonage/proactive_connect/events/list_response.rb +11 -0
  65. data/lib/vonage/proactive_connect/events.rb +71 -0
  66. data/lib/vonage/proactive_connect/item.rb +116 -0
  67. data/lib/vonage/proactive_connect/items/file_response.rb +32 -0
  68. data/lib/vonage/proactive_connect/items/list_response.rb +11 -0
  69. data/lib/vonage/proactive_connect/items.rb +116 -0
  70. data/lib/vonage/proactive_connect/list.rb +186 -0
  71. data/lib/vonage/proactive_connect/lists/list_response.rb +11 -0
  72. data/lib/vonage/proactive_connect/lists.rb +38 -0
  73. data/lib/vonage/proactive_connect.rb +43 -0
  74. data/lib/vonage/server_error.rb +1 -1
  75. data/lib/vonage/signature.rb +29 -6
  76. data/lib/vonage/sms.rb +25 -0
  77. data/lib/vonage/subaccounts/balance_transfers/list_response.rb +11 -0
  78. data/lib/vonage/subaccounts/credit_transfers/list_response.rb +11 -0
  79. data/lib/vonage/subaccounts/list_response.rb +15 -0
  80. data/lib/vonage/subaccounts.rb +203 -0
  81. data/lib/vonage/users/list_response.rb +11 -0
  82. data/lib/vonage/users.rb +156 -0
  83. data/lib/vonage/verify.rb +2 -0
  84. data/lib/vonage/verify2/channels/email.rb +36 -0
  85. data/lib/vonage/verify2/channels/silent_auth.rb +46 -0
  86. data/lib/vonage/verify2/channels/sms.rb +63 -0
  87. data/lib/vonage/verify2/channels/voice.rb +32 -0
  88. data/lib/vonage/verify2/channels/whats_app.rb +45 -0
  89. data/lib/vonage/verify2/channels/whats_app_interactive.rb +32 -0
  90. data/lib/vonage/verify2/start_verification_options.rb +63 -0
  91. data/lib/vonage/verify2/template_fragments/list_response.rb +11 -0
  92. data/lib/vonage/verify2/template_fragments.rb +125 -0
  93. data/lib/vonage/verify2/templates/list_response.rb +11 -0
  94. data/lib/vonage/verify2/templates.rb +86 -0
  95. data/lib/vonage/verify2/workflow.rb +39 -0
  96. data/lib/vonage/verify2/workflow_builder.rb +25 -0
  97. data/lib/vonage/verify2.rb +112 -0
  98. data/lib/vonage/version.rb +1 -1
  99. data/lib/vonage/video/archives/list_response.rb +11 -0
  100. data/lib/vonage/video/archives.rb +164 -0
  101. data/lib/vonage/video/broadcasts/list_response.rb +11 -0
  102. data/lib/vonage/video/broadcasts.rb +75 -0
  103. data/lib/vonage/video/captions.rb +67 -0
  104. data/lib/vonage/video/connections/list_response.rb +11 -0
  105. data/lib/vonage/video/connections.rb +29 -0
  106. data/lib/vonage/video/moderation.rb +58 -0
  107. data/lib/vonage/video/renders/list_response.rb +11 -0
  108. data/lib/vonage/video/renders.rb +107 -0
  109. data/lib/vonage/video/signals.rb +50 -0
  110. data/lib/vonage/video/sip.rb +48 -0
  111. data/lib/vonage/video/streams/list_response.rb +11 -0
  112. data/lib/vonage/video/streams.rb +70 -0
  113. data/lib/vonage/video/web_socket.rb +68 -0
  114. data/lib/vonage/video.rb +134 -0
  115. data/lib/vonage/voice/actions/connect.rb +45 -9
  116. data/lib/vonage/voice/actions/conversation.rb +10 -4
  117. data/lib/vonage/voice/actions/input.rb +26 -3
  118. data/lib/vonage/voice/actions/notify.rb +8 -3
  119. data/lib/vonage/voice/actions/record.rb +52 -4
  120. data/lib/vonage/voice/actions/stream.rb +7 -3
  121. data/lib/vonage/voice/actions/talk.rb +29 -4
  122. data/lib/vonage/voice/actions/transfer.rb +83 -0
  123. data/lib/vonage/voice/actions/wait.rb +43 -0
  124. data/lib/vonage/voice/ncco.rb +3 -1
  125. data/lib/vonage/voice/talk.rb +11 -1
  126. data/lib/vonage/voice.rb +24 -0
  127. data/lib/vonage.rb +4 -0
  128. data/vonage.gemspec +3 -1
  129. metadata +119 -9
  130. data/lib/vonage/voice/actions/pay.rb +0 -107
@@ -5,6 +5,8 @@ module Vonage
5
5
  class Numbers < Namespace
6
6
  include Keys
7
7
 
8
+ self.authentication = Basic
9
+
8
10
  self.host = :rest_host
9
11
 
10
12
  # Retrieve all the inbound numbers associated with your Vonage account.
@@ -15,6 +17,8 @@ module Vonage
15
17
  # puts "#{item.msisdn} #{item.country} #{item.type}"
16
18
  # end
17
19
  #
20
+ # @param [Hash] params
21
+ #
18
22
  # @option params [String] :application_id
19
23
  # The application that you want to return the numbers for.
20
24
  #
@@ -45,14 +49,12 @@ module Vonage
45
49
  # Set this to `true` to auto-advance through all the pages in the record
46
50
  # and collect all the data. The default is `false`.
47
51
  #
48
- # @param [Hash] params
49
- #
50
52
  # @return [ListResponse]
51
53
  #
52
54
  # @see https://developer.nexmo.com/api/developer/numbers#getOwnedNumbers
53
55
  #
54
56
  def list(params = nil)
55
- request('/account/numbers', params: params, response_class: ListResponse)
57
+ request("/account/numbers", params: params, response_class: ListResponse)
56
58
  end
57
59
 
58
60
  # Retrieve inbound numbers that are available for the specified country.
@@ -63,6 +65,8 @@ module Vonage
63
65
  # puts "#{item.msisdn} #{item.type} #{item.cost}"
64
66
  # end
65
67
  #
68
+ # @param [Hash] params
69
+ #
66
70
  # @option params [required, String] :country
67
71
  # The two character country code in ISO 3166-1 alpha-2 format.
68
72
  #
@@ -80,7 +84,7 @@ module Vonage
80
84
  # - `2` - Search for numbers that end with **:pattern**
81
85
  #
82
86
  # @option params [String] :features
83
- # Available features are `SMS` and `VOICE`.
87
+ # Available features are `SMS`, `MMS`, and `VOICE`.
84
88
  # To look for numbers that support both, use a comma-separated value: `SMS,VOICE`.
85
89
  #
86
90
  # @option params [Integer] :size
@@ -93,14 +97,12 @@ module Vonage
93
97
  # Set this to `true` to auto-advance through all the pages in the record
94
98
  # and collect all the data. The default is `false`.
95
99
  #
96
- # @param [Hash] params
97
- #
98
100
  # @return [ListResponse]
99
101
  #
100
102
  # @see https://developer.nexmo.com/api/developer/numbers#getAvailableNumbers
101
103
  #
102
104
  def search(params)
103
- request('/number/search', params: params, response_class: ListResponse)
105
+ request("/number/search", params: params, response_class: ListResponse)
104
106
  end
105
107
 
106
108
  # Request to purchase a specific inbound number.
@@ -108,6 +110,8 @@ module Vonage
108
110
  # @example
109
111
  # response = client.numbers.buy(country: 'GB', msisdn: '447700900000')
110
112
  #
113
+ # @param [Hash] params
114
+ #
111
115
  # @option params [required, String] :country
112
116
  # The two character country code in ISO 3166-1 alpha-2 format.
113
117
  #
@@ -118,14 +122,17 @@ module Vonage
118
122
  # If you'd like to perform an action on a subaccount, provide the `api_key` of that account here.
119
123
  # If you'd like to perform an action on your own account, you do not need to provide this field.
120
124
  #
121
- # @param [Hash] params
122
- #
123
125
  # @return [Response]
124
126
  #
125
127
  # @see https://developer.nexmo.com/api/developer/numbers#buyANumber
126
128
  #
127
129
  def buy(params)
128
- request('/number/buy', params: params, type: Post, response_class: Response)
130
+ request(
131
+ "/number/buy",
132
+ params: params,
133
+ type: Post,
134
+ response_class: Response
135
+ )
129
136
  end
130
137
 
131
138
  # Cancel your subscription for a specific inbound number.
@@ -133,6 +140,8 @@ module Vonage
133
140
  # @example
134
141
  # response = client.numbers.cancel(country: 'GB', msisdn: '447700900000')
135
142
  #
143
+ # @param [Hash] params
144
+ #
136
145
  # @option params [required, String] :country
137
146
  # The two character country code in ISO 3166-1 alpha-2 format.
138
147
  #
@@ -143,14 +152,17 @@ module Vonage
143
152
  # If you'd like to perform an action on a subaccount, provide the `api_key` of that account here.
144
153
  # If you'd like to perform an action on your own account, you do not need to provide this field.
145
154
  #
146
- # @param [Hash] params
147
- #
148
155
  # @return [Response]
149
156
  #
150
157
  # @see https://developer.nexmo.com/api/developer/numbers#cancelANumber
151
158
  #
152
159
  def cancel(params)
153
- request('/number/cancel', params: params, type: Post, response_class: Response)
160
+ request(
161
+ "/number/cancel",
162
+ params: params,
163
+ type: Post,
164
+ response_class: Response
165
+ )
154
166
  end
155
167
 
156
168
  # Change the behaviour of a number that you own.
@@ -165,6 +177,8 @@ module Vonage
165
177
  #
166
178
  # response = client.numbers.update(params)
167
179
  #
180
+ # @param [Hash] params
181
+ #
168
182
  # @option params [required, String] :country
169
183
  # The two character country code in ISO 3166-1 alpha-2 format.
170
184
  #
@@ -191,21 +205,30 @@ module Vonage
191
205
  # @option params [String] :voice_status_callback
192
206
  # A webhook URI for Vonage to send a request to when a call ends.
193
207
  #
194
- # @param [Hash] params
195
- #
196
208
  # @return [Response]
197
209
  #
198
210
  # @see https://developer.nexmo.com/api/developer/numbers#updateANumber
199
211
  #
200
212
  def update(params)
201
- request('/number/update', params: camelcase(params), type: Post, response_class: Response)
213
+ request(
214
+ "/number/update",
215
+ params: camelcase(params),
216
+ type: Post,
217
+ response_class: Response
218
+ )
202
219
  end
203
220
 
204
221
  private
205
222
 
206
223
  # A specific implementation of iterable_request for Numbers, because the Numbers API
207
224
  # handles pagination differently to other Vonage APIs
208
- def iterable_request(path, response: nil, response_class: nil, params: {}, &block)
225
+ def iterable_request(
226
+ path,
227
+ response: nil,
228
+ response_class: nil,
229
+ params: {},
230
+ &block
231
+ )
209
232
  response = parse(response, response_class)
210
233
  params[:index] = 1 unless params.has_key?(:index)
211
234
  size = params.fetch(:size, 10)
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::ProactiveConnect::Events::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.events.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,71 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class ProactiveConnect::Events < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.host = :vonage_host
11
+
12
+ # Find all events
13
+ #
14
+ # @deprecated
15
+ #
16
+ # @example
17
+ # response = proactive_connect.events.list
18
+ #
19
+ # @param [optional, String] :page
20
+ # Page of results to jump to
21
+ #
22
+ # @param [optional, String] :page_size
23
+ # Number of results per page
24
+ #
25
+ # @param [optional, String] order
26
+ # Sort in either ascending (asc, the default) or descending (desc) order
27
+ #
28
+ # @param [optional, String] :run_id
29
+ # Run IDs to filter by, if not specified, returns events for any run id
30
+ #
31
+ # @param [optional, String] :type
32
+ # Event types to filter by
33
+ #
34
+ # @param [optional, String] action_id
35
+ # Action IDs to filter by.
36
+ #
37
+ # @param [optional, String] :invocation_id
38
+ # Invocation IDs to filter by
39
+ #
40
+ # @param [optional, String] :recipient_id
41
+ # Recipient IDs to filter by
42
+ #
43
+ # @param [optional, String] :run_item_id
44
+ # Run item IDs to filter by
45
+ #
46
+ # @param [optional, String] src_ctx
47
+ # The name of the segment / matcher the item / event to filter by (exact string)
48
+ #
49
+ # @param [optional, String] :src_type
50
+ # Source types to filter by
51
+ #
52
+ # @param [optional, String] :trace_id
53
+ # Trace IDs to filter events by
54
+ #
55
+ # @param [optional, String] date_start
56
+ # ISO-8601 formatted date for when to begin events filter
57
+ #
58
+ # @param [optional, String] :date_end
59
+ # ISO-8601 formatted date for when to end events filter
60
+ #
61
+ # @see https://developer.vonage.com/en/api/proactive-connect#eventsFindAll
62
+ #
63
+ def list(**params)
64
+ logger.info('This method is deprecated and will be removed in a future release.')
65
+ path = "/v0.1/bulk/events"
66
+ path += "?#{Params.encode(params)}" unless params.empty?
67
+
68
+ request(path, response_class: ListResponse)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,116 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class ProactiveConnect::Item < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.host = :vonage_host
11
+
12
+ self.request_body = JSON
13
+
14
+ # Create a list item
15
+ #
16
+ # @deprecated
17
+ #
18
+ # @example
19
+ # response = proactive_connect.item.create(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', data: {name: 'Joe Bloggs', email: 'joe@email.com'})
20
+ #
21
+ # @param [required, String] :list_id
22
+ # Unique identifier for the list
23
+ #
24
+ # @param [required, Hash] :data
25
+ # A hash of data containing the item's data attributes and values
26
+ #
27
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsCreate
28
+ #
29
+ def create(list_id:, data:)
30
+ logger.info('This method is deprecated and will be removed in a future release.')
31
+ raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
32
+ request(
33
+ "/v0.1/bulk/lists/#{list_id}/items",
34
+ params: { data: data },
35
+ type: Post
36
+ )
37
+ end
38
+
39
+ # Get list item by id
40
+ #
41
+ # @deprecated
42
+ #
43
+ # @example
44
+ # response = proactive_connect.item.find(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
45
+ #
46
+ # @param [required, String] :list_id
47
+ # Unique identifier for the list
48
+ #
49
+ # @param [required, String] :item_id
50
+ # Unique identifier for the item
51
+ #
52
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsGet
53
+ #
54
+ def find(list_id:, item_id:)
55
+ logger.info('This method is deprecated and will be removed in a future release.')
56
+ request("/v0.1/bulk/lists/#{list_id}/items/#{item_id}")
57
+ end
58
+
59
+ # Update list item
60
+ #
61
+ # @deprecated
62
+ #
63
+ # @example
64
+ # response = proactive_connect.item.create(
65
+ # list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865',
66
+ # item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a',
67
+ # data: {name: 'Jane Bloggs', email: 'joe@email.com'}
68
+ # )
69
+ #
70
+ # @param [required, String] :list_id
71
+ # Unique identifier for the list
72
+ #
73
+ # @param [required, String] :item_id
74
+ # Unique identifier for the item
75
+ #
76
+ # @param [required, Hash] :data
77
+ # A hash of data containing the item's data attributes and values
78
+ # All attributes for the item must be passed, even ones for which the value is not changing.
79
+ # If an attribute is omitted, existing data for that attribute will be deleted.
80
+ #
81
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsUpdate
82
+ #
83
+ def update(list_id:, item_id:, data:)
84
+ logger.info('This method is deprecated and will be removed in a future release.')
85
+ raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
86
+ request(
87
+ "/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
88
+ params: { data: data },
89
+ type: Put
90
+ )
91
+ end
92
+
93
+ # Delete list item
94
+ #
95
+ # @deprecated
96
+ #
97
+ # @example
98
+ # response = proactive_connect.item.delete(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
99
+ #
100
+ # @param [required, String] :list_id
101
+ # Unique identifier for the list
102
+ #
103
+ # @param [required, String] :item_id
104
+ # Unique identifier for the item
105
+ #
106
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsDelete
107
+ #
108
+ def delete(list_id:, item_id:)
109
+ logger.info('This method is deprecated and will be removed in a future release.')
110
+ request(
111
+ "/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
112
+ type: Delete
113
+ )
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,32 @@
1
+ # typed: true
2
+
3
+ class Vonage::ProactiveConnect::Items::FileResponse < Vonage::Response
4
+ DEFAULT_FILENAME = 'vonage-proactive-connect-list-items.csv'
5
+
6
+ attr_accessor :filename
7
+
8
+ def initialize(entity=nil, http_response=nil)
9
+ super
10
+ self.filename = initial_filename
11
+ end
12
+
13
+ def save(filepath:)
14
+ pn = Pathname.new(filepath)
15
+ raise ArgumentError, ':filepath not a directory' unless pn.directory?
16
+ raise ArgumentError, ':filepath not absolute' unless pn.absolute?
17
+ raise ArgumentError, ':filepath not writable' unless pn.writable?
18
+
19
+ File.open("#{pn.cleanpath}/#{filename}", 'w') {|f| f.write(http_response.body) }
20
+ end
21
+
22
+ def data
23
+ http_response ? http_response.body : nil
24
+ end
25
+
26
+ private
27
+
28
+ def initial_filename
29
+ match_data = http_response['Content-Disposition'].match(/filename=(\"?)(.+)\1/)
30
+ match_data ? match_data[2] : DEFAULT_FILENAME
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::ProactiveConnect::Items::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.items.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,116 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class ProactiveConnect::Items < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.host = :vonage_host
11
+
12
+ # Find all list items
13
+ #
14
+ # @deprecated
15
+ #
16
+ # @example
17
+ # response = proactive_connect.items.list(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
18
+ #
19
+ # @param [required, String] :list_id
20
+ # Unique identifier for the list
21
+ #
22
+ # @param [optional, String] :page
23
+ # Page of results to jump to
24
+ #
25
+ # @param [optional, String] :page_size
26
+ # Number of results per page
27
+ #
28
+ # @param [optional, String] order
29
+ # Sort in either ascending (asc, the default) or descending (desc) order
30
+ #
31
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsFindAll
32
+ #
33
+ def list(list_id:, **params)
34
+ logger.info('This method is deprecated and will be removed in a future release.')
35
+ path = "/v0.1/bulk/lists/#{list_id}/items"
36
+ path += "?#{Params.encode(params)}" unless params.empty?
37
+
38
+ request(path, response_class: ListResponse)
39
+ end
40
+
41
+ # Download list items as a CSV file format
42
+ #
43
+ # @deprecated
44
+ #
45
+ # @example
46
+ # response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
47
+ #
48
+ # @param [required, String] :list_id
49
+ # ID for the list to download
50
+ #
51
+ # @param [optional, String] order
52
+ # Sort in either ascending (asc, the default) or descending (desc) order
53
+ #
54
+ # @param [optional, String] :filename
55
+ # A name to set for the returned File object. If not set, the File object will use the actual filename (if available)
56
+ # or a default of `download.csv` if the actual filename is not available.
57
+ #
58
+ # @param [optional, String] :filepath
59
+ # A filepath to a directory where the file should be written.
60
+ # If not set, the file is not written, though the the file can be written at any time by calling `save` on the returned
61
+ # object and passing in `:filepath` as an argument to the `save` method, for example:
62
+ # response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
63
+ # response.save('/files/downloads/')
64
+ # If set, the filepath must be:
65
+ # - An absolute path
66
+ # - For a valid directory
67
+ # - The directory must be writable
68
+ #
69
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsDownload
70
+ #
71
+ def download_csv(list_id:, order: 'asc', **params)
72
+ logger.info('This method is deprecated and will be removed in a future release.')
73
+ response = request("/v0.1/bulk/lists/#{list_id}/items/download?order=#{order}", response_class: FileResponse)
74
+
75
+ response.filename = params[:filename] if params[:filename]
76
+ response.save(filepath: params[:filepath]) if params[:filepath]
77
+
78
+ response
79
+ end
80
+
81
+ # Import list items from a CSV file
82
+ #
83
+ # @deprecated
84
+ #
85
+ # @example
86
+ # response = proactive_connect.items.upload_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', filepath: '/files/import.csv')
87
+ #
88
+ # @param [required, String] :list_id
89
+ # ID for the list to download
90
+ #
91
+ # @param [optional, String] order
92
+ # Sort in either ascending (asc, the default) or descending (desc) order
93
+ #
94
+ # @param [optional, String] :filename
95
+ # A name to set for the returned File object. If not set, the File object will use the actual filename (if available)
96
+ # or a default of `download.csv` if the actual filename is not available.
97
+ #
98
+ # @param [required, String] :filepath
99
+ # A filepath for the file to import. The file must be:
100
+ # - A valid file
101
+ # - Readable
102
+ # - Must have a `.csv` extension
103
+ #
104
+ # @see https://developer.vonage.com/en/api/proactive-connect#itemsImport
105
+ #
106
+ def upload_csv(list_id:, filepath:)
107
+ logger.info('This method is deprecated and will be removed in a future release.')
108
+ pn = Pathname.new(filepath)
109
+ raise ArgumentError, ':filepath not for a file' unless pn.file?
110
+ raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
111
+ raise ArgumentError, 'file at :filepath not csv' unless pn.extname == '.csv'
112
+
113
+ multipart_post_request("/v0.1/bulk/lists/#{list_id}/items/import", filepath: filepath, file_name: pn.basename, mime_type: 'text/csv')
114
+ end
115
+ end
116
+ end