twilio-ruby 5.39.2 → 5.40.3

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +107 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/ISSUE_TEMPLATE.md +5 -1
  6. data/PULL_REQUEST_TEMPLATE.md +1 -1
  7. data/README.md +4 -3
  8. data/lib/twilio-ruby/framework/version.rb +4 -8
  9. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  10. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +12 -3
  11. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +12 -3
  12. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +12 -3
  13. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +12 -3
  14. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +12 -3
  15. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +12 -3
  16. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +12 -3
  17. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +2 -1
  18. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +85 -60
  19. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +5 -2
  20. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
  21. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
  22. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
  23. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +8 -1
  24. data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +3 -1
  25. data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +2 -1
  26. data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb +8 -4
  27. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +11 -4
  28. data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb +13 -6
  29. data/lib/twilio-ruby/rest/client.rb +7 -0
  30. data/lib/twilio-ruby/rest/conversations.rb +39 -3
  31. data/lib/twilio-ruby/rest/conversations/v1.rb +68 -5
  32. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +268 -0
  33. data/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb +262 -0
  34. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +21 -10
  35. data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +13 -10
  36. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +34 -19
  37. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +48 -32
  38. data/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +14 -11
  39. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  40. data/lib/twilio-ruby/rest/conversations/v1/role.rb +374 -0
  41. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  42. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +388 -0
  43. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +271 -0
  44. data/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb +315 -0
  45. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  46. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +549 -0
  47. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +394 -0
  48. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +519 -0
  49. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +457 -0
  50. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +395 -0
  51. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  52. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  53. data/lib/twilio-ruby/rest/events.rb +72 -0
  54. data/lib/twilio-ruby/rest/events/v1.rb +90 -0
  55. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  56. data/lib/twilio-ruby/rest/events/v1/schema.rb +226 -0
  57. data/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb +290 -0
  58. data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
  59. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  60. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
  61. data/lib/twilio-ruby/rest/events/v1/subscription.rb +383 -0
  62. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +216 -0
  63. data/lib/twilio-ruby/rest/fax/v1/fax.rb +2 -1
  64. data/lib/twilio-ruby/rest/messaging.rb +6 -0
  65. data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
  66. data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
  67. data/lib/twilio-ruby/rest/messaging/v1/service.rb +6 -3
  68. data/lib/twilio-ruby/rest/notify/v1/credential.rb +12 -6
  69. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +10 -2
  70. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
  71. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
  72. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  73. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +10 -5
  74. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb +6 -3
  75. data/lib/twilio-ruby/rest/preview/trusted_comms/business/insights.rb +1 -4
  76. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +3 -1
  77. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
  78. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
  79. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  80. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  81. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  82. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  83. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  84. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  85. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  86. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  87. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  88. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  89. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  90. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
  91. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  92. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  93. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +6 -2
  94. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +1 -4
  95. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +6 -2
  96. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +38 -23
  97. data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +2 -1
  98. data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +2 -1
  99. data/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb +201 -0
  100. data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
  101. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
  102. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +7 -2
  103. data/lib/twilio-ruby/rest/video/v1/composition.rb +7 -3
  104. data/lib/twilio-ruby/rest/video/v1/composition_hook.rb +18 -9
  105. data/lib/twilio-ruby/rest/video/v1/room.rb +2 -1
  106. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  107. data/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb +1 -4
  108. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +2 -1
  109. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  110. data/lib/twilio-ruby/version.rb +1 -1
  111. data/spec/framework/version_spec.rb +53 -0
  112. data/spec/holodeck/holodeck.rb +3 -3
  113. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
  114. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
  115. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
  116. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
  117. data/spec/integration/api/v2010/account/message_spec.rb +37 -0
  118. data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
  119. data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
  120. data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
  121. data/spec/integration/conversations/v1/{webhook_spec.rb → configuration/webhook_spec.rb} +12 -8
  122. data/spec/integration/conversations/v1/configuration_spec.rb +87 -0
  123. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  124. data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
  125. data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
  126. data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
  127. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  128. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  129. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  130. data/spec/integration/conversations/v1/service/configuration/notification_spec.rb +115 -0
  131. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  132. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  133. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  134. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  135. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  136. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  137. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  138. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  139. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  140. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  141. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  142. data/spec/integration/events/v1/schema/schema_version_spec.rb +126 -0
  143. data/spec/integration/events/v1/schema_spec.rb +46 -0
  144. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  145. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  146. data/spec/integration/events/v1/sink_spec.rb +217 -0
  147. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +91 -0
  148. data/spec/integration/events/v1/subscription_spec.rb +243 -0
  149. data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
  150. data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
  151. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  152. data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
  153. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
  154. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  155. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  156. data/spec/integration/trunking/v1/trunk/recording_spec.rb +79 -0
  157. data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
  158. data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
  159. data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
  160. data/spec/integration/video/v1/room_spec.rb +37 -0
  161. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  162. data/spec/spec_helper.rb +1 -1
  163. metadata +82 -5
  164. data/lib/twilio-ruby/rest/conversations/v1/webhook.rb +0 -262
@@ -0,0 +1,457 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Conversations < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ class ConversationContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
17
+ class WebhookList < ListResource
18
+ ##
19
+ # Initialize the WebhookList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] chat_service_sid The SID of the [Conversation
22
+ # Service](https://www.twilio.com/docs/conversations/api/service-resource) the
23
+ # Participant resource is associated with.
24
+ # @param [String] conversation_sid The unique ID of the
25
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
26
+ # for this webhook.
27
+ # @return [WebhookList] WebhookList
28
+ def initialize(version, chat_service_sid: nil, conversation_sid: nil)
29
+ super(version)
30
+
31
+ # Path Solution
32
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid}
33
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Webhooks"
34
+ end
35
+
36
+ ##
37
+ # Create the WebhookInstance
38
+ # @param [webhook.Target] target The target of this webhook: `webhook`, `studio`,
39
+ # `trigger`
40
+ # @param [String] configuration_url The absolute url the webhook request should be
41
+ # sent to.
42
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
43
+ # sending a webhook request.
44
+ # @param [String] configuration_filters The list of events, firing webhook event
45
+ # for this Conversation.
46
+ # @param [String] configuration_triggers The list of keywords, firing webhook
47
+ # event for this Conversation.
48
+ # @param [String] configuration_flow_sid The studio flow SID, where the webhook
49
+ # should be sent to.
50
+ # @param [String] configuration_replay_after The message index for which and it's
51
+ # successors the webhook will be replayed. Not set by default
52
+ # @return [WebhookInstance] Created WebhookInstance
53
+ def create(target: nil, configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_replay_after: :unset)
54
+ data = Twilio::Values.of({
55
+ 'Target' => target,
56
+ 'Configuration.Url' => configuration_url,
57
+ 'Configuration.Method' => configuration_method,
58
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
59
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
60
+ 'Configuration.FlowSid' => configuration_flow_sid,
61
+ 'Configuration.ReplayAfter' => configuration_replay_after,
62
+ })
63
+
64
+ payload = @version.create('POST', @uri, data: data)
65
+
66
+ WebhookInstance.new(
67
+ @version,
68
+ payload,
69
+ chat_service_sid: @solution[:chat_service_sid],
70
+ conversation_sid: @solution[:conversation_sid],
71
+ )
72
+ end
73
+
74
+ ##
75
+ # Lists WebhookInstance records from the API as a list.
76
+ # Unlike stream(), this operation is eager and will load `limit` records into
77
+ # memory before returning.
78
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
79
+ # guarantees to never return more than limit. Default is no limit
80
+ # @param [Integer] page_size Number of records to fetch per request, when
81
+ # not set will use the default value of 50 records. If no page_size is defined
82
+ # but a limit is defined, stream() will attempt to read the limit with the most
83
+ # efficient page size, i.e. min(limit, 1000)
84
+ # @return [Array] Array of up to limit results
85
+ def list(limit: nil, page_size: nil)
86
+ self.stream(limit: limit, page_size: page_size).entries
87
+ end
88
+
89
+ ##
90
+ # Streams WebhookInstance records from the API as an Enumerable.
91
+ # This operation lazily loads records as efficiently as possible until the limit
92
+ # is reached.
93
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
94
+ # guarantees to never return more than limit. Default is no limit.
95
+ # @param [Integer] page_size Number of records to fetch per request, when
96
+ # not set will use the default value of 50 records. If no page_size is defined
97
+ # but a limit is defined, stream() will attempt to read the limit with the most
98
+ # efficient page size, i.e. min(limit, 1000)
99
+ # @return [Enumerable] Enumerable that will yield up to limit results
100
+ def stream(limit: nil, page_size: nil)
101
+ limits = @version.read_limits(limit, page_size)
102
+
103
+ page = self.page(page_size: limits[:page_size], )
104
+
105
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
106
+ end
107
+
108
+ ##
109
+ # When passed a block, yields WebhookInstance records from the API.
110
+ # This operation lazily loads records as efficiently as possible until the limit
111
+ # is reached.
112
+ def each
113
+ limits = @version.read_limits
114
+
115
+ page = self.page(page_size: limits[:page_size], )
116
+
117
+ @version.stream(page,
118
+ limit: limits[:limit],
119
+ page_limit: limits[:page_limit]).each {|x| yield x}
120
+ end
121
+
122
+ ##
123
+ # Retrieve a single page of WebhookInstance records from the API.
124
+ # Request is executed immediately.
125
+ # @param [String] page_token PageToken provided by the API
126
+ # @param [Integer] page_number Page Number, this value is simply for client state
127
+ # @param [Integer] page_size Number of records to return, defaults to 50
128
+ # @return [Page] Page of WebhookInstance
129
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
130
+ params = Twilio::Values.of({
131
+ 'PageToken' => page_token,
132
+ 'Page' => page_number,
133
+ 'PageSize' => page_size,
134
+ })
135
+
136
+ response = @version.page('GET', @uri, params: params)
137
+
138
+ WebhookPage.new(@version, response, @solution)
139
+ end
140
+
141
+ ##
142
+ # Retrieve a single page of WebhookInstance records from the API.
143
+ # Request is executed immediately.
144
+ # @param [String] target_url API-generated URL for the requested results page
145
+ # @return [Page] Page of WebhookInstance
146
+ def get_page(target_url)
147
+ response = @version.domain.request(
148
+ 'GET',
149
+ target_url
150
+ )
151
+ WebhookPage.new(@version, response, @solution)
152
+ end
153
+
154
+ ##
155
+ # Provide a user friendly representation
156
+ def to_s
157
+ '#<Twilio.Conversations.V1.WebhookList>'
158
+ end
159
+ end
160
+
161
+ ##
162
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
163
+ class WebhookPage < Page
164
+ ##
165
+ # Initialize the WebhookPage
166
+ # @param [Version] version Version that contains the resource
167
+ # @param [Response] response Response from the API
168
+ # @param [Hash] solution Path solution for the resource
169
+ # @return [WebhookPage] WebhookPage
170
+ def initialize(version, response, solution)
171
+ super(version, response)
172
+
173
+ # Path Solution
174
+ @solution = solution
175
+ end
176
+
177
+ ##
178
+ # Build an instance of WebhookInstance
179
+ # @param [Hash] payload Payload response from the API
180
+ # @return [WebhookInstance] WebhookInstance
181
+ def get_instance(payload)
182
+ WebhookInstance.new(
183
+ @version,
184
+ payload,
185
+ chat_service_sid: @solution[:chat_service_sid],
186
+ conversation_sid: @solution[:conversation_sid],
187
+ )
188
+ end
189
+
190
+ ##
191
+ # Provide a user friendly representation
192
+ def to_s
193
+ '<Twilio.Conversations.V1.WebhookPage>'
194
+ end
195
+ end
196
+
197
+ ##
198
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
199
+ class WebhookContext < InstanceContext
200
+ ##
201
+ # Initialize the WebhookContext
202
+ # @param [Version] version Version that contains the resource
203
+ # @param [String] chat_service_sid The SID of the [Conversation
204
+ # Service](https://www.twilio.com/docs/conversations/api/service-resource) the
205
+ # Participant resource is associated with.
206
+ # @param [String] conversation_sid The unique ID of the
207
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
208
+ # for this webhook.
209
+ # @param [String] sid A 34 character string that uniquely identifies this
210
+ # resource.
211
+ # @return [WebhookContext] WebhookContext
212
+ def initialize(version, chat_service_sid, conversation_sid, sid)
213
+ super(version)
214
+
215
+ # Path Solution
216
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
217
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Webhooks/#{@solution[:sid]}"
218
+ end
219
+
220
+ ##
221
+ # Update the WebhookInstance
222
+ # @param [String] configuration_url The absolute url the webhook request should be
223
+ # sent to.
224
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
225
+ # sending a webhook request.
226
+ # @param [String] configuration_filters The list of events, firing webhook event
227
+ # for this Conversation.
228
+ # @param [String] configuration_triggers The list of keywords, firing webhook
229
+ # event for this Conversation.
230
+ # @param [String] configuration_flow_sid The studio flow SID, where the webhook
231
+ # should be sent to.
232
+ # @return [WebhookInstance] Updated WebhookInstance
233
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
234
+ data = Twilio::Values.of({
235
+ 'Configuration.Url' => configuration_url,
236
+ 'Configuration.Method' => configuration_method,
237
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
238
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
239
+ 'Configuration.FlowSid' => configuration_flow_sid,
240
+ })
241
+
242
+ payload = @version.update('POST', @uri, data: data)
243
+
244
+ WebhookInstance.new(
245
+ @version,
246
+ payload,
247
+ chat_service_sid: @solution[:chat_service_sid],
248
+ conversation_sid: @solution[:conversation_sid],
249
+ sid: @solution[:sid],
250
+ )
251
+ end
252
+
253
+ ##
254
+ # Delete the WebhookInstance
255
+ # @return [Boolean] true if delete succeeds, false otherwise
256
+ def delete
257
+ @version.delete('DELETE', @uri)
258
+ end
259
+
260
+ ##
261
+ # Fetch the WebhookInstance
262
+ # @return [WebhookInstance] Fetched WebhookInstance
263
+ def fetch
264
+ payload = @version.fetch('GET', @uri)
265
+
266
+ WebhookInstance.new(
267
+ @version,
268
+ payload,
269
+ chat_service_sid: @solution[:chat_service_sid],
270
+ conversation_sid: @solution[:conversation_sid],
271
+ sid: @solution[:sid],
272
+ )
273
+ end
274
+
275
+ ##
276
+ # Provide a user friendly representation
277
+ def to_s
278
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
279
+ "#<Twilio.Conversations.V1.WebhookContext #{context}>"
280
+ end
281
+
282
+ ##
283
+ # Provide a detailed, user friendly representation
284
+ def inspect
285
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
286
+ "#<Twilio.Conversations.V1.WebhookContext #{context}>"
287
+ end
288
+ end
289
+
290
+ ##
291
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
292
+ class WebhookInstance < InstanceResource
293
+ ##
294
+ # Initialize the WebhookInstance
295
+ # @param [Version] version Version that contains the resource
296
+ # @param [Hash] payload payload that contains response from Twilio
297
+ # @param [String] chat_service_sid The SID of the [Conversation
298
+ # Service](https://www.twilio.com/docs/conversations/api/service-resource) the
299
+ # Participant resource is associated with.
300
+ # @param [String] conversation_sid The unique ID of the
301
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
302
+ # for this webhook.
303
+ # @param [String] sid A 34 character string that uniquely identifies this
304
+ # resource.
305
+ # @return [WebhookInstance] WebhookInstance
306
+ def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil)
307
+ super(version)
308
+
309
+ # Marshaled Properties
310
+ @properties = {
311
+ 'sid' => payload['sid'],
312
+ 'account_sid' => payload['account_sid'],
313
+ 'chat_service_sid' => payload['chat_service_sid'],
314
+ 'conversation_sid' => payload['conversation_sid'],
315
+ 'target' => payload['target'],
316
+ 'url' => payload['url'],
317
+ 'configuration' => payload['configuration'],
318
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
319
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
320
+ }
321
+
322
+ # Context
323
+ @instance_context = nil
324
+ @params = {
325
+ 'chat_service_sid' => chat_service_sid,
326
+ 'conversation_sid' => conversation_sid,
327
+ 'sid' => sid || @properties['sid'],
328
+ }
329
+ end
330
+
331
+ ##
332
+ # Generate an instance context for the instance, the context is capable of
333
+ # performing various actions. All instance actions are proxied to the context
334
+ # @return [WebhookContext] WebhookContext for this WebhookInstance
335
+ def context
336
+ unless @instance_context
337
+ @instance_context = WebhookContext.new(
338
+ @version,
339
+ @params['chat_service_sid'],
340
+ @params['conversation_sid'],
341
+ @params['sid'],
342
+ )
343
+ end
344
+ @instance_context
345
+ end
346
+
347
+ ##
348
+ # @return [String] A 34 character string that uniquely identifies this resource.
349
+ def sid
350
+ @properties['sid']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The unique ID of the Account responsible for this conversation.
355
+ def account_sid
356
+ @properties['account_sid']
357
+ end
358
+
359
+ ##
360
+ # @return [String] The SID of the Conversation Service that the resource is associated with.
361
+ def chat_service_sid
362
+ @properties['chat_service_sid']
363
+ end
364
+
365
+ ##
366
+ # @return [String] The unique ID of the Conversation for this webhook.
367
+ def conversation_sid
368
+ @properties['conversation_sid']
369
+ end
370
+
371
+ ##
372
+ # @return [String] The target of this webhook.
373
+ def target
374
+ @properties['target']
375
+ end
376
+
377
+ ##
378
+ # @return [String] An absolute URL for this webhook.
379
+ def url
380
+ @properties['url']
381
+ end
382
+
383
+ ##
384
+ # @return [Hash] The configuration of this webhook.
385
+ def configuration
386
+ @properties['configuration']
387
+ end
388
+
389
+ ##
390
+ # @return [Time] The date that this resource was created.
391
+ def date_created
392
+ @properties['date_created']
393
+ end
394
+
395
+ ##
396
+ # @return [Time] The date that this resource was last updated.
397
+ def date_updated
398
+ @properties['date_updated']
399
+ end
400
+
401
+ ##
402
+ # Update the WebhookInstance
403
+ # @param [String] configuration_url The absolute url the webhook request should be
404
+ # sent to.
405
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
406
+ # sending a webhook request.
407
+ # @param [String] configuration_filters The list of events, firing webhook event
408
+ # for this Conversation.
409
+ # @param [String] configuration_triggers The list of keywords, firing webhook
410
+ # event for this Conversation.
411
+ # @param [String] configuration_flow_sid The studio flow SID, where the webhook
412
+ # should be sent to.
413
+ # @return [WebhookInstance] Updated WebhookInstance
414
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
415
+ context.update(
416
+ configuration_url: configuration_url,
417
+ configuration_method: configuration_method,
418
+ configuration_filters: configuration_filters,
419
+ configuration_triggers: configuration_triggers,
420
+ configuration_flow_sid: configuration_flow_sid,
421
+ )
422
+ end
423
+
424
+ ##
425
+ # Delete the WebhookInstance
426
+ # @return [Boolean] true if delete succeeds, false otherwise
427
+ def delete
428
+ context.delete
429
+ end
430
+
431
+ ##
432
+ # Fetch the WebhookInstance
433
+ # @return [WebhookInstance] Fetched WebhookInstance
434
+ def fetch
435
+ context.fetch
436
+ end
437
+
438
+ ##
439
+ # Provide a user friendly representation
440
+ def to_s
441
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
442
+ "<Twilio.Conversations.V1.WebhookInstance #{values}>"
443
+ end
444
+
445
+ ##
446
+ # Provide a detailed, user friendly representation
447
+ def inspect
448
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
449
+ "<Twilio.Conversations.V1.WebhookInstance #{values}>"
450
+ end
451
+ end
452
+ end
453
+ end
454
+ end
455
+ end
456
+ end
457
+ end