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
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = Basic
10
+
9
11
  self.host = :rest_host
10
12
 
11
13
  # Retrieve your account balance.
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+ require "json"
3
+
4
+ module Vonage
5
+ class APIError < Error
6
+ extend T::Sig
7
+
8
+ sig { returns(Net::HTTPResponse) }
9
+ attr_reader :http_response
10
+
11
+ sig { params(message: T.nilable(String), http_response: T.nilable(Net::HTTPResponse)).void }
12
+ def initialize(message = nil, http_response: nil)
13
+ super(message)
14
+ @http_response = http_response
15
+ end
16
+
17
+ def http_response_code
18
+ return nil unless http_response
19
+ http_response.code
20
+ end
21
+
22
+ def http_response_headers
23
+ return nil unless http_response
24
+ http_response.to_hash
25
+ end
26
+
27
+ def http_response_body
28
+ return nil unless http_response
29
+ return {} unless http_response.content_type && http_response.content_type.include?("json")
30
+ ::JSON.parse(http_response.body)
31
+ end
32
+ end
33
+ end
@@ -33,6 +33,8 @@ module Vonage
33
33
  #
34
34
  # response = client.applications.create(params)
35
35
  #
36
+ # @param [Hash] params
37
+ #
36
38
  # @option params [required, String] :name
37
39
  # Application name.
38
40
  #
@@ -44,7 +46,9 @@ module Vonage
44
46
  # This contains the configuration for each product.
45
47
  # This replaces the application `type` from version 1 of the Application API.
46
48
  #
47
- # @param [Hash] params
49
+ # @option params [Hash] :privacy
50
+ # - **:improve_ai** (Boolean) If set to `true``, Vonage may store and use your content and data for the improvement
51
+ # of Vonage's AI based services and technologies.
48
52
  #
49
53
  # @return [Response]
50
54
  #
@@ -73,7 +77,7 @@ module Vonage
73
77
  # Set this to `false` to not auto-advance through all the pages in the record
74
78
  # and collect all the data. The default is `true`.
75
79
  # @param [Hash] params
76
- #
80
+ #
77
81
  # @return [ListResponse]
78
82
  #
79
83
  # @see https://developer.nexmo.com/api/application.v2#listApplication
@@ -109,6 +113,9 @@ module Vonage
109
113
  # @example
110
114
  # response = client.applications.update(id, answer_method: 'POST')
111
115
  #
116
+ # @param [String] id
117
+ # @param [Hash] params
118
+ #
112
119
  # @option params [required, String] :name
113
120
  # Application name.
114
121
  #
@@ -120,8 +127,9 @@ module Vonage
120
127
  # This contains the configuration for each product.
121
128
  # This replaces the application `type` from version 1 of the Application API.
122
129
  #
123
- # @param [String] id
124
- # @param [Hash] params
130
+ # @option params [Hash] :privacy
131
+ # - **:improve_ai** (Boolean) If set to `true``, Vonage may store and use your content and data for the improvement
132
+ # of Vonage's AI based services and technologies.
125
133
  #
126
134
  # @return [Response]
127
135
  #
data/lib/vonage/basic.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Vonage
4
4
  class Basic < AbstractAuthentication
5
- def update(object)
5
+ def update(object, data)
6
6
  return unless object.is_a?(Net::HTTPRequest)
7
7
 
8
8
  object.basic_auth(@config.api_key, @config.api_secret)
@@ -0,0 +1,18 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class BasicAndBearerToken < AbstractAuthentication
6
+ def update(object, data)
7
+ return unless object.is_a?(Net::HTTPRequest)
8
+
9
+ if @config.authentication_preference == :basic
10
+ object.basic_auth(@config.api_key, @config.api_secret)
11
+ else
12
+ object['Authorization'] = 'Bearer ' + @config.token
13
+ end
14
+ end
15
+ end
16
+
17
+ private_constant :BasicAndBearerToken
18
+ end
@@ -0,0 +1,22 @@
1
+ # typed: true
2
+
3
+ module Vonage
4
+ class BasicAndSignature < AbstractAuthentication
5
+ def update(object, data)
6
+ if @config.authentication_preference == :signature
7
+ return unless object.is_a?(Hash)
8
+
9
+ object['api_key'] = T.must(@config).api_key
10
+ object['timestamp'] =Time.now.to_i.to_s
11
+ signature = Signature.new(@config).generate(object)
12
+ object[:sig] = signature
13
+ else
14
+ return unless object.is_a?(Net::HTTPRequest)
15
+
16
+ object.basic_auth(@config.api_key, @config.api_secret)
17
+ end
18
+ end
19
+ end
20
+
21
+ private_constant :BasicAndSignature
22
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Vonage
5
5
  class BearerToken < AbstractAuthentication
6
- def update(object)
6
+ def update(object, data)
7
7
  return unless object.is_a?(Net::HTTPRequest)
8
8
 
9
9
  object['Authorization'] = 'Bearer ' + @config.token
data/lib/vonage/client.rb CHANGED
@@ -40,8 +40,17 @@ module Vonage
40
40
  @applications ||= T.let(Applications.new(config), T.nilable(Vonage::Applications))
41
41
  end
42
42
 
43
+ # @return [Conversation]
44
+ #
45
+ sig { returns(T.nilable(Vonage::Conversation)) }
46
+ def conversation
47
+ @conversation ||= T.let(Conversation.new(config), T.nilable(Vonage::Conversation))
48
+ end
49
+
43
50
  # @return [Conversations]
44
51
  #
52
+ # @deprecated Please use {#conversation} instead
53
+ #
45
54
  sig { returns(T.nilable(Vonage::Conversations)) }
46
55
  def conversations
47
56
  @conversations ||= T.let(Conversations.new(config), T.nilable(Vonage::Conversations))
@@ -61,6 +70,20 @@ module Vonage
61
70
  @files ||= T.let(Files.new(config), T.nilable(Vonage::Files))
62
71
  end
63
72
 
73
+ # @return [IdentityInsights]
74
+ #
75
+ sig { returns(T.nilable(Vonage::IdentityInsights)) }
76
+ def identity_insights
77
+ @identity_insights ||= T.let(IdentityInsights.new(config), T.nilable(Vonage::IdentityInsights))
78
+ end
79
+
80
+ # @return [Meetings]
81
+ # @deprecated
82
+ sig { returns(T.nilable(Vonage::Meetings)) }
83
+ def meetings
84
+ @meetings ||= T.let(Meetings.new(config), T.nilable(Vonage::Meetings))
85
+ end
86
+
64
87
  # @return [Messages]
65
88
  #
66
89
  sig { returns(T.nilable(Vonage::Messages)) }
@@ -75,6 +98,20 @@ module Vonage
75
98
  @messaging ||= T.let(Messaging.new(config), T.nilable(Vonage::Messaging))
76
99
  end
77
100
 
101
+ # @return [NetworkNumberVerification]
102
+ #
103
+ sig { returns(T.nilable(Vonage::NetworkNumberVerification)) }
104
+ def network_number_verification
105
+ @network_number_verification ||= T.let(NetworkNumberVerification.new(config), T.nilable(Vonage::NetworkNumberVerification))
106
+ end
107
+
108
+ # @return [NetworkSIMSwap]
109
+ #
110
+ sig { returns(T.nilable(Vonage::NetworkSIMSwap)) }
111
+ def network_sim_swap
112
+ @network_sim_swap ||= T.let(NetworkSIMSwap.new(config), T.nilable(Vonage::NetworkSIMSwap))
113
+ end
114
+
78
115
  # @return [NumberInsight]
79
116
  #
80
117
  sig { returns(T.nilable(Vonage::NumberInsight)) }
@@ -82,6 +119,13 @@ module Vonage
82
119
  @number_insight ||= T.let(NumberInsight.new(config), T.nilable(Vonage::NumberInsight))
83
120
  end
84
121
 
122
+ # @return [NumberInsight2]
123
+ # @deprecated
124
+ sig { returns(T.nilable(Vonage::NumberInsight2)) }
125
+ def number_insight_2
126
+ @number_insight_2 ||= T.let(NumberInsight2.new(config), T.nilable(Vonage::NumberInsight2))
127
+ end
128
+
85
129
  # @return [Numbers]
86
130
  #
87
131
  sig { returns(T.nilable(Vonage::Numbers)) }
@@ -96,6 +140,13 @@ module Vonage
96
140
  @pricing ||= T.let(PricingTypes.new(config), T.nilable(Vonage::PricingTypes))
97
141
  end
98
142
 
143
+ # @return [ProactiveConnect]
144
+ # @deprecated
145
+ sig { returns(T.nilable(Vonage::ProactiveConnect)) }
146
+ def proactive_connect
147
+ @proactive_connect ||= T.let(ProactiveConnect.new(config), T.nilable(Vonage::ProactiveConnect))
148
+ end
149
+
99
150
  # @return [Redact]
100
151
  #
101
152
  sig { returns(T.nilable(Vonage::Redact)) }
@@ -117,6 +168,13 @@ module Vonage
117
168
  @sms ||= T.let(SMS.new(config), T.nilable(Vonage::SMS))
118
169
  end
119
170
 
171
+ # @return [Subaccounts]
172
+ #
173
+ sig { returns(T.nilable(Vonage::Subaccounts)) }
174
+ def subaccounts
175
+ @subaccounts ||= T.let(Subaccounts.new(config), T.nilable(Vonage::Subaccounts))
176
+ end
177
+
120
178
  # @return [TFA]
121
179
  #
122
180
  sig { returns(T.nilable(Vonage::TFA)) }
@@ -124,6 +182,13 @@ module Vonage
124
182
  @tfa ||= T.let(TFA.new(config), T.nilable(Vonage::TFA))
125
183
  end
126
184
 
185
+ # @return [Users]
186
+ #
187
+ sig { returns(T.nilable(Vonage::Users)) }
188
+ def users
189
+ @users ||= T.let(Users.new(config), T.nilable(Vonage::Users))
190
+ end
191
+
127
192
  # @return [Verify]
128
193
  #
129
194
  sig { returns(T.nilable(Vonage::Verify)) }
@@ -131,6 +196,20 @@ module Vonage
131
196
  @verify ||= T.let(Verify.new(config), T.nilable(Vonage::Verify))
132
197
  end
133
198
 
199
+ # @return [Verify2]
200
+ #
201
+ sig { returns(T.nilable(Vonage::Verify2)) }
202
+ def verify2
203
+ @verify2 ||= T.let(Verify2.new(config), T.nilable(Vonage::Verify2))
204
+ end
205
+
206
+ # @return [Video]
207
+ #
208
+ sig { returns(T.nilable(Vonage::Video)) }
209
+ def video
210
+ @video ||= T.let(Video.new(config), T.nilable(Vonage::Video))
211
+ end
212
+
134
213
  # @return [Voice]
135
214
  #
136
215
  sig { returns(T.nilable(Vonage::Voice)) }
@@ -1,6 +1,6 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- class ClientError < Error
4
+ class ClientError < APIError
5
5
  end
6
6
  end
data/lib/vonage/config.rb CHANGED
@@ -18,6 +18,8 @@ module Vonage
18
18
  self.signature_secret = ENV['VONAGE_SIGNATURE_SECRET']
19
19
  self.signature_method = ENV['VONAGE_SIGNATURE_METHOD'] || 'md5hash'
20
20
  self.token = T.let(nil, T.nilable(String))
21
+ self.video_host = 'video.api.vonage.com'
22
+ self.vonage_host = 'api-eu.vonage.com'
21
23
  end
22
24
 
23
25
  # Merges the config with the given options hash.
@@ -107,6 +109,9 @@ module Vonage
107
109
  sig { returns(T.nilable(String)) }
108
110
  attr_accessor :app_version
109
111
 
112
+ sig { returns(T.nilable(Symbol)) }
113
+ attr_accessor :authentication_preference
114
+
110
115
  # Returns the value of attribute http.
111
116
  #
112
117
  # @return [Vonage::HTTP::Options]
@@ -129,7 +134,6 @@ module Vonage
129
134
 
130
135
  # @return [Vonage::Logger]
131
136
  #
132
- sig { params(logger: T.nilable(T.any(::Logger, Vonage::Logger))).returns(T.nilable(Vonage::Logger)) }
133
137
  def logger=(logger)
134
138
  @logger = T.let(Logger.new(logger), T.nilable(Vonage::Logger))
135
139
  end
@@ -198,6 +202,12 @@ module Vonage
198
202
  sig { params(token: T.nilable(String)).returns(T.nilable(String)) }
199
203
  attr_writer :token
200
204
 
205
+ sig { returns(String) }
206
+ attr_accessor :video_host
207
+
208
+ sig { returns(String) }
209
+ attr_accessor :vonage_host
210
+
201
211
  protected
202
212
 
203
213
  sig { params(name: Symbol, value: T.untyped).void }
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Conversation::Event::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,108 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Conversation::Event < Namespace
6
+ self.authentication = BearerToken
7
+
8
+ self.request_body = JSON
9
+
10
+ # List conversation events
11
+ #
12
+ # @example
13
+ # response = client.conversation.event.list(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a')
14
+ #
15
+ # @param [required, String] :conversation_id The conversation_id of the conversation to list events for
16
+ #
17
+ # @param [String] :start_id
18
+ # The ID to start returning events at
19
+ #
20
+ # @param [String] :end_id
21
+ # The ID to end returning events at
22
+ #
23
+ # @param [String] :event_type
24
+ # The type of event to search for. Does not currently support custom events
25
+ #
26
+ # @param [Integer] :page_size
27
+ # Return this amount of records in the response.
28
+ #
29
+ # @param ['asc', 'desc'] :order
30
+ # Return the records in ascending or descending order.
31
+ #
32
+ # @param [String] :cursor
33
+ # The cursor to start returning results from.
34
+ #
35
+ # @return [Conversation::Member::ListResponse]
36
+ #
37
+ # @see https://developer.vonage.com/en/api/conversation#getEvents
38
+ #
39
+ def list(conversation_id:, **params)
40
+ request("/v1/conversations/#{conversation_id}/events", params: params, response_class: ListResponse)
41
+ end
42
+
43
+ # Create an event
44
+ # @example
45
+ # response = client.conversation.event.create(
46
+ # conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a',
47
+ # type: 'message',
48
+ # body: {
49
+ # message_type: 'text',
50
+ # text: 'Hello World'
51
+ # }
52
+ # )
53
+ #
54
+ # @param [required, String] :conversation_id The conversation_id of the conversation to create the event for
55
+ #
56
+ # @param [required, String] :type
57
+ # Event type.
58
+ #
59
+ # @param [String] :from
60
+ #
61
+ # @option params [required, String] :from
62
+ #
63
+ # @param [Hash] :body
64
+ # The body of the event. There are many possible properties depending on the event type and message_type
65
+ #
66
+ # @return [Response]
67
+ #
68
+ # @see https://developer.vonage.com/en/api/conversation#createEvent
69
+ #
70
+ def create(conversation_id:, **params)
71
+ request("/v1/conversations/#{conversation_id}/events", params: params, type: Post)
72
+ end
73
+
74
+ # Get details of a specific event
75
+ #
76
+ # @example
77
+ # response = client.conversation.event.find(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', event_id: 1)
78
+ #
79
+ # @param [required, String] :conversation_id
80
+ #
81
+ # @param [required, String] :event_id
82
+ #
83
+ # @return [Response]
84
+ #
85
+ # @see https://developer.vonage.com/en/api/conversation#getEvent
86
+ #
87
+ def find(conversation_id:, event_id:)
88
+ request("/v1/conversations/#{conversation_id}/events/#{event_id}")
89
+ end
90
+
91
+ # Delete an event.
92
+ #
93
+ # @example
94
+ # response = client.conversation.event.delete(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', event_id: 1)
95
+ #
96
+ # @param [String] :conversation_id
97
+ #
98
+ # @param [String] :event_id
99
+ #
100
+ # @return [Response]
101
+ #
102
+ # @see https://developer.vonage.com/en/api/conversation#deleteEvent
103
+ #
104
+ def delete(conversation_id:, event_id:)
105
+ request("/v1/conversations/#{conversation_id}/events/#{event_id}", type: Delete)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Conversation::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.conversations.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Conversation::Member::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.members.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,134 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Conversation::Member < Namespace
6
+ self.authentication = BearerToken
7
+
8
+ self.request_body = JSON
9
+
10
+ # List members of a conversation
11
+ #
12
+ # @example
13
+ # response = client.conversation.member.list(conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a')
14
+ #
15
+ # @param [required, String] :conversation_id The conversation_id of the conversation to list members for
16
+ #
17
+ # @param [Integer] :page_size
18
+ # Return this amount of records in the response.
19
+ #
20
+ # @param ['asc', 'desc'] :order
21
+ # Return the records in ascending or descending order.
22
+ #
23
+ # @param [String] :cursor
24
+ # The cursor to start returning results from.
25
+ #
26
+ # @return [Conversation::Member::ListResponse]
27
+ #
28
+ # @see https://developer.vonage.com/en/api/conversation#getMembers
29
+ #
30
+ def list(conversation_id:, **params)
31
+ request("/v1/conversations/#{conversation_id}/members", params: params, response_class: ListResponse)
32
+ end
33
+
34
+ # Create a member.
35
+ #
36
+ # @example
37
+ # response = client.conversation.member.create(
38
+ # conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a',
39
+ # user: {
40
+ # id: 'USR-82e028d9-5201-4f1e-8188-604b2d3471ec'
41
+ # }
42
+ # )
43
+ #
44
+ # @param [required, String] :conversation_id The conversation_id of the conversation for which to create the member
45
+ #
46
+ # @param [String] :state Must be one of ['invited', 'joined']
47
+ #
48
+ # @param [Hash] :user (Either :id or :name is required)
49
+ # - @option user [String] :id The user_id of the user to add to the conversation
50
+ # - @option user [String] :name The name of the user to add to the conversation
51
+ #
52
+ # @param [Hash] :channel
53
+ # - @option channel [required, String] :type The type of channel
54
+ # - @option channel [Hash] :from
55
+ # - @option from [String] :type
56
+ # - @option from [String] :number
57
+ # - @option from [String] :id
58
+ # - @option channel [Hash] :to
59
+ # - @option from [String] :type
60
+ # - @option from [String] :user
61
+ # - @option from [String] :number
62
+ # - @option from [String] :id
63
+ #
64
+ # @param [Hash] :media
65
+ # - @option media [Boolean] :audio
66
+ # - @option media [Hash] :audio_settings
67
+ # - @option audio_settings [Boolean] :enabled
68
+ # - @option audio_settings [Boolean] :earmuffed
69
+ # - @option audio_settings [Boolean] :muted
70
+ #
71
+ # @param [String] :knocking_id
72
+ #
73
+ # @param [String] :member_id_inviting
74
+ #
75
+ # @param [String] :from
76
+ #
77
+ # @return [Response]
78
+ #
79
+ # @see https://developer.vonage.com/en/api/conversation#createMember
80
+ #
81
+ def create(conversation_id:, **params)
82
+ request("/v1/conversations/#{conversation_id}/members", params: params, type: Post)
83
+ end
84
+
85
+ # Retrieve a member
86
+ #
87
+ # @example
88
+ # response = client.conversation.member.find(
89
+ # conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a',
90
+ # member_id: 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391'
91
+ # )
92
+ #
93
+ # @param [required, String] :conversation_id
94
+ #
95
+ # @param [required, String] :member_id
96
+ #
97
+ # @return [Response]
98
+ #
99
+ # @see https://developer.vonage.com/en/api/conversation#getMember
100
+ #
101
+ def find(conversation_id:, member_id:)
102
+ request("/v1/conversations/#{conversation_id}/members/#{member_id}", response_class: Vonage::Response)
103
+ end
104
+
105
+ # Update a member
106
+ #
107
+ # @example
108
+ # response = client.conversation.member.update(
109
+ # conversation_id: 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a',
110
+ # member_id: 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391',
111
+ # state: 'left'
112
+ # )
113
+ #
114
+ # @param [required, String] :conversation_id
115
+ #
116
+ # @param [required, String] :member_id
117
+ #
118
+ # @param [String] :state Must be one of ['joined', 'left']
119
+ #
120
+ # @param [String] :from
121
+ #
122
+ # @param [Hash] :reason
123
+ # - @option reason [String] :code
124
+ # - @option reason [String] :text
125
+ #
126
+ # @return [Response]
127
+ #
128
+ # @see https://developer.vonage.com/en/api/conversation#updateMember
129
+ #
130
+ def update(conversation_id:, member_id:, **params)
131
+ request("/v1/conversations/#{conversation_id}/members/#{member_id}", params: params, type: Patch)
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Conversation::User::ConversationsListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.conversations.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Conversation::User::SessionsListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.sessions.each { |item| yield item }
10
+ end
11
+ end