twilio-ruby 5.52.0 → 5.67.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 (163) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/pr-lint.yml +15 -0
  3. data/.github/workflows/test-and-deploy.yml +129 -0
  4. data/.gitignore +5 -1
  5. data/.rubocop.yml +1 -1
  6. data/.rubocop_todo.yml +91 -28
  7. data/CHANGES.md +563 -0
  8. data/Gemfile +1 -0
  9. data/Makefile +8 -11
  10. data/README.md +13 -6
  11. data/examples/examples.rb +1 -1
  12. data/lib/rack/twilio_webhook_authentication.rb +25 -1
  13. data/lib/twilio-ruby/http/http_client.rb +20 -4
  14. data/lib/twilio-ruby/http.rb +5 -0
  15. data/lib/twilio-ruby/jwt/access_token.rb +13 -0
  16. data/lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb +23 -23
  17. data/lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb +5 -5
  18. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +8 -8
  19. data/lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb +674 -0
  20. data/lib/twilio-ruby/rest/api/v2010/account/call/stream.rb +674 -0
  21. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +68 -14
  22. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +12 -8
  23. data/lib/twilio-ruby/rest/api/v2010/account/conference/recording.rb +1 -1
  24. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +11 -4
  25. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +11 -4
  26. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +11 -4
  27. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +17 -10
  28. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +18 -5
  29. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +34 -7
  30. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +11 -11
  31. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +11 -11
  32. data/lib/twilio-ruby/rest/bulkexports/v1/export/day.rb +0 -8
  33. data/lib/twilio-ruby/rest/bulkexports/v1/export/export_custom_job.rb +0 -6
  34. data/lib/twilio-ruby/rest/bulkexports/v1/export/job.rb +0 -8
  35. data/lib/twilio-ruby/rest/bulkexports/v1/export.rb +0 -8
  36. data/lib/twilio-ruby/rest/bulkexports/v1/export_configuration.rb +0 -8
  37. data/lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb +10 -4
  38. data/lib/twilio-ruby/rest/chat/v3/channel.rb +275 -0
  39. data/lib/twilio-ruby/rest/chat/v3.rb +48 -0
  40. data/lib/twilio-ruby/rest/chat.rb +16 -0
  41. data/lib/twilio-ruby/rest/client.rb +21 -12
  42. data/lib/twilio-ruby/rest/conversations/v1/address_configuration.rb +454 -0
  43. data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +12 -5
  44. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +7 -0
  45. data/lib/twilio-ruby/rest/conversations/v1/participant_conversation.rb +312 -0
  46. data/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb +18 -2
  47. data/lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb +269 -0
  48. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +8 -0
  49. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +12 -5
  50. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +7 -0
  51. data/lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb +324 -0
  52. data/lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb +466 -0
  53. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +44 -0
  54. data/lib/twilio-ruby/rest/conversations/v1/service.rb +23 -0
  55. data/lib/twilio-ruby/rest/conversations/v1/user/user_conversation.rb +442 -0
  56. data/lib/twilio-ruby/rest/conversations/v1/user.rb +35 -0
  57. data/lib/twilio-ruby/rest/conversations/v1.rb +24 -0
  58. data/lib/twilio-ruby/rest/conversations.rb +15 -0
  59. data/lib/twilio-ruby/rest/events/v1/event_type.rb +12 -5
  60. data/lib/twilio-ruby/rest/events/v1/sink.rb +41 -5
  61. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +28 -0
  62. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +55 -34
  63. data/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.rb +236 -0
  64. data/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.rb +330 -0
  65. data/lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb +384 -0
  66. data/lib/twilio-ruby/rest/flex_api/v1/interaction.rb +233 -0
  67. data/lib/twilio-ruby/rest/flex_api/v1.rb +16 -0
  68. data/lib/twilio-ruby/rest/flex_api.rb +9 -0
  69. data/lib/twilio-ruby/rest/frontline_api/v1/user.rb +258 -0
  70. data/lib/twilio-ruby/rest/{fax → frontline_api}/v1.rb +11 -11
  71. data/lib/twilio-ruby/rest/{fax.rb → frontline_api.rb} +11 -11
  72. data/lib/twilio-ruby/rest/insights/v1/annotation.rb +271 -0
  73. data/lib/twilio-ruby/rest/insights/v1/call_summaries.rb +434 -0
  74. data/lib/twilio-ruby/rest/insights/v1/conference/conference_participant.rb +474 -0
  75. data/lib/twilio-ruby/rest/insights/v1/conference.rb +512 -0
  76. data/lib/twilio-ruby/rest/insights/v1/setting.rb +215 -0
  77. data/lib/twilio-ruby/rest/insights/v1.rb +46 -0
  78. data/lib/twilio-ruby/rest/insights.rb +28 -0
  79. data/lib/twilio-ruby/rest/lookups/v2/phone_number.rb +268 -0
  80. data/lib/twilio-ruby/rest/lookups/v2.rb +45 -0
  81. data/lib/twilio-ruby/rest/lookups.rb +7 -0
  82. data/lib/twilio-ruby/rest/media/v1/media_processor.rb +397 -0
  83. data/lib/twilio-ruby/rest/media/v1/media_recording.rb +406 -0
  84. data/lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb +221 -0
  85. data/lib/twilio-ruby/rest/media/v1/player_streamer.rb +403 -0
  86. data/lib/twilio-ruby/rest/media/v1.rb +76 -0
  87. data/lib/twilio-ruby/rest/media.rb +65 -0
  88. data/lib/twilio-ruby/rest/{fax/v1/fax/fax_media.rb → messaging/v1/brand_registration/brand_vetting.rb} +134 -95
  89. data/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +127 -2
  90. data/lib/twilio-ruby/rest/messaging/v1/external_campaign.rb +7 -0
  91. data/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb +187 -20
  92. data/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person_usecase.rb +6 -2
  93. data/lib/twilio-ruby/rest/messaging/v1/service.rb +37 -5
  94. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/bundle_copy.rb +268 -0
  95. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/replace_items.rb +188 -0
  96. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +128 -26
  97. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +7 -0
  98. data/lib/twilio-ruby/rest/pricing/v2/country.rb +280 -0
  99. data/lib/twilio-ruby/rest/pricing/v2/number.rb +225 -0
  100. data/lib/twilio-ruby/rest/pricing/v2.rb +37 -0
  101. data/lib/twilio-ruby/rest/pricing.rb +19 -0
  102. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +1 -1
  103. data/lib/twilio-ruby/rest/serverless/v1/service.rb +7 -0
  104. data/lib/twilio-ruby/rest/studio/v1/flow/execution.rb +1 -1
  105. data/lib/twilio-ruby/rest/studio/v2/flow/execution.rb +1 -1
  106. data/lib/twilio-ruby/rest/supersim/v1/esim_profile.rb +372 -0
  107. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +44 -55
  108. data/lib/twilio-ruby/rest/supersim/v1/{command.rb → ip_command.rb} +132 -84
  109. data/lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb +231 -0
  110. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +30 -1
  111. data/lib/twilio-ruby/rest/supersim/v1/sms_command.rb +1 -1
  112. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +23 -9
  113. data/lib/twilio-ruby/rest/supersim/v1.rb +23 -7
  114. data/lib/twilio-ruby/rest/supersim.rb +15 -6
  115. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +7 -0
  116. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +7 -3
  117. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb +6 -2
  118. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +7 -3
  119. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +23 -11
  120. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb +4 -2
  121. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb +4 -2
  122. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +38 -22
  123. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +19 -3
  124. data/lib/twilio-ruby/rest/verify/v2/service/access_token.rb +155 -10
  125. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge/notification.rb +12 -9
  126. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +74 -22
  127. data/lib/twilio-ruby/rest/verify/v2/service/entity/factor.rb +34 -15
  128. data/lib/twilio-ruby/rest/verify/v2/service/entity/new_factor.rb +66 -31
  129. data/lib/twilio-ruby/rest/verify/v2/service/entity.rb +7 -3
  130. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +25 -7
  131. data/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +24 -5
  132. data/lib/twilio-ruby/rest/verify/v2/service.rb +40 -11
  133. data/lib/twilio-ruby/rest/verify/v2/template.rb +206 -0
  134. data/lib/twilio-ruby/rest/verify/v2/verification_attempt.rb +89 -21
  135. data/lib/twilio-ruby/rest/verify/v2/verification_attempts_summary.rb +234 -0
  136. data/lib/twilio-ruby/rest/verify/v2.rb +14 -0
  137. data/lib/twilio-ruby/rest/verify.rb +14 -2
  138. data/lib/twilio-ruby/rest/video/v1/composition.rb +21 -8
  139. data/lib/twilio-ruby/rest/video/v1/composition_hook.rb +0 -8
  140. data/lib/twilio-ruby/rest/video/v1/recording.rb +21 -0
  141. data/lib/twilio-ruby/rest/video/v1/room/recording.rb +7 -0
  142. data/lib/twilio-ruby/rest/video/v1/room.rb +62 -5
  143. data/lib/twilio-ruby/rest/voice/v1/archived_call.rb +184 -0
  144. data/lib/twilio-ruby/rest/voice/v1.rb +21 -0
  145. data/lib/twilio-ruby/rest/voice.rb +8 -0
  146. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +3 -3
  147. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +16 -26
  148. data/lib/twilio-ruby/rest.rb +13 -0
  149. data/lib/twilio-ruby/twiml/voice_response.rb +727 -87
  150. data/lib/twilio-ruby/version.rb +1 -1
  151. data/lib/twilio-ruby.rb +6 -16
  152. data/sonar-project.properties +13 -0
  153. data/twilio-ruby.gemspec +1 -2
  154. metadata +59 -32
  155. data/.travis.yml +0 -45
  156. data/lib/twilio-ruby/rest/fax/v1/fax.rb +0 -536
  157. /data/lib/twilio-ruby/framework/{domain.rb → rest/domain.rb} +0 -0
  158. /data/lib/twilio-ruby/framework/{error.rb → rest/error.rb} +0 -0
  159. /data/lib/twilio-ruby/framework/{helper.rb → rest/helper.rb} +0 -0
  160. /data/lib/twilio-ruby/framework/{obsolete_client.rb → rest/obsolete_client.rb} +0 -0
  161. /data/lib/twilio-ruby/framework/{page.rb → rest/page.rb} +0 -0
  162. /data/lib/twilio-ruby/framework/{resource.rb → rest/resource.rb} +0 -0
  163. /data/lib/twilio-ruby/framework/{version.rb → rest/version.rb} +0 -0
@@ -13,11 +13,11 @@ module Twilio
13
13
  class Client
14
14
  @@default_region = 'us1'
15
15
 
16
- attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region, :edge, :logger
16
+ attr_accessor :http_client, :username, :password, :account_sid, :auth_token, :region, :edge, :logger, :user_agent_extensions
17
17
 
18
18
  ##
19
19
  # Initializes the Twilio Client
20
- def initialize(username=nil, password=nil, account_sid=nil, region=nil, http_client=nil, logger=nil)
20
+ def initialize(username=nil, password=nil, account_sid=nil, region=nil, http_client=nil, logger=nil, user_agent_extensions=nil)
21
21
  @username = username || Twilio.account_sid
22
22
  @password = password || Twilio.auth_token
23
23
  @region = region || Twilio.region
@@ -27,6 +27,7 @@ module Twilio
27
27
  @auth = [@username, @password]
28
28
  @http_client = http_client || Twilio.http_client || Twilio::HTTP::Client.new
29
29
  @logger = logger || Twilio.logger
30
+ @user_agent_extensions = user_agent_extensions || []
30
31
 
31
32
  # Domains
32
33
  @accounts = nil
@@ -35,11 +36,12 @@ module Twilio
35
36
  @chat = nil
36
37
  @conversations = nil
37
38
  @events = nil
38
- @fax = nil
39
39
  @flex_api = nil
40
+ @frontline_api = nil
40
41
  @insights = nil
41
42
  @ip_messaging = nil
42
43
  @lookups = nil
44
+ @media = nil
43
45
  @messaging = nil
44
46
  @monitor = nil
45
47
  @notify = nil
@@ -67,11 +69,12 @@ module Twilio
67
69
  def request(host, port, method, uri, params={}, data={}, headers={}, auth=nil, timeout=nil)
68
70
  auth ||= @auth
69
71
 
70
- headers['User-Agent'] = "twilio-ruby/#{Twilio::VERSION}" +
71
- " (#{RUBY_ENGINE}/#{RUBY_PLATFORM}" +
72
- " #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
72
+ ruby_config = RbConfig::CONFIG
73
+ headers['User-Agent'] = "twilio-ruby/#{Twilio::VERSION} (#{ruby_config["host_os"]} #{ruby_config["host_cpu"]}) Ruby/#{RUBY_VERSION}"
73
74
  headers['Accept-Charset'] = 'utf-8'
74
75
 
76
+ user_agent_extensions.each { |extension| headers['User-Agent'] += " #{extension}" }
77
+
75
78
  if method == 'POST' && !headers['Content-Type']
76
79
  headers['Content-Type'] = 'application/x-www-form-urlencoded'
77
80
  end
@@ -194,18 +197,18 @@ module Twilio
194
197
  @events ||= Events.new self
195
198
  end
196
199
 
197
- ##
198
- # Access the Fax Twilio Domain
199
- def fax
200
- @fax ||= Fax.new self
201
- end
202
-
203
200
  ##
204
201
  # Access the FlexApi Twilio Domain
205
202
  def flex_api
206
203
  @flex_api ||= FlexApi.new self
207
204
  end
208
205
 
206
+ ##
207
+ # Access the FrontlineApi Twilio Domain
208
+ def frontline_api
209
+ @frontline_api ||= FrontlineApi.new self
210
+ end
211
+
209
212
  ##
210
213
  # Access the Insights Twilio Domain
211
214
  def insights
@@ -224,6 +227,12 @@ module Twilio
224
227
  @lookups ||= Lookups.new self
225
228
  end
226
229
 
230
+ ##
231
+ # Access the Media Twilio Domain
232
+ def media
233
+ @media ||= Media.new self
234
+ end
235
+
227
236
  ##
228
237
  # Access the Messaging Twilio Domain
229
238
  def messaging
@@ -0,0 +1,454 @@
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 AddressConfigurationList < ListResource
14
+ ##
15
+ # Initialize the AddressConfigurationList
16
+ # @param [Version] version Version that contains the resource
17
+ # @return [AddressConfigurationList] AddressConfigurationList
18
+ def initialize(version)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {}
23
+ @uri = "/Configuration/Addresses"
24
+ end
25
+
26
+ ##
27
+ # Lists AddressConfigurationInstance records from the API as a list.
28
+ # Unlike stream(), this operation is eager and will load `limit` records into
29
+ # memory before returning.
30
+ # @param [String] type Filter the address configurations by its type. This value
31
+ # can be one of: `whatsapp`, `sms`.
32
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
33
+ # guarantees to never return more than limit. Default is no limit
34
+ # @param [Integer] page_size Number of records to fetch per request, when
35
+ # not set will use the default value of 50 records. If no page_size is defined
36
+ # but a limit is defined, stream() will attempt to read the limit with the most
37
+ # efficient page size, i.e. min(limit, 1000)
38
+ # @return [Array] Array of up to limit results
39
+ def list(type: :unset, limit: nil, page_size: nil)
40
+ self.stream(type: type, limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams AddressConfigurationInstance records from the API as an Enumerable.
45
+ # This operation lazily loads records as efficiently as possible until the limit
46
+ # is reached.
47
+ # @param [String] type Filter the address configurations by its type. This value
48
+ # can be one of: `whatsapp`, `sms`.
49
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
50
+ # guarantees to never return more than limit. Default is no limit.
51
+ # @param [Integer] page_size Number of records to fetch per request, when
52
+ # not set will use the default value of 50 records. If no page_size is defined
53
+ # but a limit is defined, stream() will attempt to read the limit with the most
54
+ # efficient page size, i.e. min(limit, 1000)
55
+ # @return [Enumerable] Enumerable that will yield up to limit results
56
+ def stream(type: :unset, limit: nil, page_size: nil)
57
+ limits = @version.read_limits(limit, page_size)
58
+
59
+ page = self.page(type: type, page_size: limits[:page_size], )
60
+
61
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
62
+ end
63
+
64
+ ##
65
+ # When passed a block, yields AddressConfigurationInstance records from the API.
66
+ # This operation lazily loads records as efficiently as possible until the limit
67
+ # is reached.
68
+ def each
69
+ limits = @version.read_limits
70
+
71
+ page = self.page(page_size: limits[:page_size], )
72
+
73
+ @version.stream(page,
74
+ limit: limits[:limit],
75
+ page_limit: limits[:page_limit]).each {|x| yield x}
76
+ end
77
+
78
+ ##
79
+ # Retrieve a single page of AddressConfigurationInstance records from the API.
80
+ # Request is executed immediately.
81
+ # @param [String] type Filter the address configurations by its type. This value
82
+ # can be one of: `whatsapp`, `sms`.
83
+ # @param [String] page_token PageToken provided by the API
84
+ # @param [Integer] page_number Page Number, this value is simply for client state
85
+ # @param [Integer] page_size Number of records to return, defaults to 50
86
+ # @return [Page] Page of AddressConfigurationInstance
87
+ def page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
88
+ params = Twilio::Values.of({
89
+ 'Type' => type,
90
+ 'PageToken' => page_token,
91
+ 'Page' => page_number,
92
+ 'PageSize' => page_size,
93
+ })
94
+
95
+ response = @version.page('GET', @uri, params: params)
96
+
97
+ AddressConfigurationPage.new(@version, response, @solution)
98
+ end
99
+
100
+ ##
101
+ # Retrieve a single page of AddressConfigurationInstance records from the API.
102
+ # Request is executed immediately.
103
+ # @param [String] target_url API-generated URL for the requested results page
104
+ # @return [Page] Page of AddressConfigurationInstance
105
+ def get_page(target_url)
106
+ response = @version.domain.request(
107
+ 'GET',
108
+ target_url
109
+ )
110
+ AddressConfigurationPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Create the AddressConfigurationInstance
115
+ # @param [address_configuration.Type] type Type of Address. Value can be
116
+ # `whatsapp` or `sms`.
117
+ # @param [String] address The unique address to be configured. The address can be
118
+ # a whatsapp address or phone number
119
+ # @param [String] friendly_name The human-readable name of this configuration,
120
+ # limited to 256 characters. Optional.
121
+ # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating
122
+ # conversations for messages to this address
123
+ # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto
124
+ # Creation. Value can be one of `webhook`, `studio` or `default`.
125
+ # @param [String] auto_creation_conversation_service_sid Conversation Service for
126
+ # the auto-created conversation. If not set, the conversation is created in the
127
+ # default service.
128
+ # @param [String] auto_creation_webhook_url For type `webhook`, the url for the
129
+ # webhook request.
130
+ # @param [address_configuration.Method] auto_creation_webhook_method For type
131
+ # `webhook`, the HTTP method to be used when sending a webhook request.
132
+ # @param [Array[String]] auto_creation_webhook_filters The list of events, firing
133
+ # webhook event for this Conversation. Values can be any of the following:
134
+ # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`,
135
+ # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`,
136
+ # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`,
137
+ # `onDeliveryUpdated`
138
+ # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow
139
+ # SID where the webhook should be sent to.
140
+ # @param [String] auto_creation_studio_retry_count For type `studio`, number of
141
+ # times to retry the webhook request
142
+ # @return [AddressConfigurationInstance] Created AddressConfigurationInstance
143
+ def create(type: nil, address: nil, friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset)
144
+ data = Twilio::Values.of({
145
+ 'Type' => type,
146
+ 'Address' => address,
147
+ 'FriendlyName' => friendly_name,
148
+ 'AutoCreation.Enabled' => auto_creation_enabled,
149
+ 'AutoCreation.Type' => auto_creation_type,
150
+ 'AutoCreation.ConversationServiceSid' => auto_creation_conversation_service_sid,
151
+ 'AutoCreation.WebhookUrl' => auto_creation_webhook_url,
152
+ 'AutoCreation.WebhookMethod' => auto_creation_webhook_method,
153
+ 'AutoCreation.WebhookFilters' => Twilio.serialize_list(auto_creation_webhook_filters) { |e| e },
154
+ 'AutoCreation.StudioFlowSid' => auto_creation_studio_flow_sid,
155
+ 'AutoCreation.StudioRetryCount' => auto_creation_studio_retry_count,
156
+ })
157
+
158
+ payload = @version.create('POST', @uri, data: data)
159
+
160
+ AddressConfigurationInstance.new(@version, payload, )
161
+ end
162
+
163
+ ##
164
+ # Provide a user friendly representation
165
+ def to_s
166
+ '#<Twilio.Conversations.V1.AddressConfigurationList>'
167
+ end
168
+ end
169
+
170
+ class AddressConfigurationPage < Page
171
+ ##
172
+ # Initialize the AddressConfigurationPage
173
+ # @param [Version] version Version that contains the resource
174
+ # @param [Response] response Response from the API
175
+ # @param [Hash] solution Path solution for the resource
176
+ # @return [AddressConfigurationPage] AddressConfigurationPage
177
+ def initialize(version, response, solution)
178
+ super(version, response)
179
+
180
+ # Path Solution
181
+ @solution = solution
182
+ end
183
+
184
+ ##
185
+ # Build an instance of AddressConfigurationInstance
186
+ # @param [Hash] payload Payload response from the API
187
+ # @return [AddressConfigurationInstance] AddressConfigurationInstance
188
+ def get_instance(payload)
189
+ AddressConfigurationInstance.new(@version, payload, )
190
+ end
191
+
192
+ ##
193
+ # Provide a user friendly representation
194
+ def to_s
195
+ '<Twilio.Conversations.V1.AddressConfigurationPage>'
196
+ end
197
+ end
198
+
199
+ class AddressConfigurationContext < InstanceContext
200
+ ##
201
+ # Initialize the AddressConfigurationContext
202
+ # @param [Version] version Version that contains the resource
203
+ # @param [String] sid The SID of the Address Configuration resource. This value
204
+ # can be either the `sid` or the `address` of the configuration
205
+ # @return [AddressConfigurationContext] AddressConfigurationContext
206
+ def initialize(version, sid)
207
+ super(version)
208
+
209
+ # Path Solution
210
+ @solution = {sid: sid, }
211
+ @uri = "/Configuration/Addresses/#{@solution[:sid]}"
212
+ end
213
+
214
+ ##
215
+ # Fetch the AddressConfigurationInstance
216
+ # @return [AddressConfigurationInstance] Fetched AddressConfigurationInstance
217
+ def fetch
218
+ payload = @version.fetch('GET', @uri)
219
+
220
+ AddressConfigurationInstance.new(@version, payload, sid: @solution[:sid], )
221
+ end
222
+
223
+ ##
224
+ # Update the AddressConfigurationInstance
225
+ # @param [String] friendly_name The human-readable name of this configuration,
226
+ # limited to 256 characters. Optional.
227
+ # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating
228
+ # conversations for messages to this address
229
+ # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto
230
+ # Creation. Value can be one of `webhook`, `studio` or `default`.
231
+ # @param [String] auto_creation_conversation_service_sid Conversation Service for
232
+ # the auto-created conversation. If not set, the conversation is created in the
233
+ # default service.
234
+ # @param [String] auto_creation_webhook_url For type `webhook`, the url for the
235
+ # webhook request.
236
+ # @param [address_configuration.Method] auto_creation_webhook_method For type
237
+ # `webhook`, the HTTP method to be used when sending a webhook request.
238
+ # @param [Array[String]] auto_creation_webhook_filters The list of events, firing
239
+ # webhook event for this Conversation. Values can be any of the following:
240
+ # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`,
241
+ # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`,
242
+ # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`,
243
+ # `onDeliveryUpdated`
244
+ # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow
245
+ # SID where the webhook should be sent to.
246
+ # @param [String] auto_creation_studio_retry_count For type `studio`, number of
247
+ # times to retry the webhook request
248
+ # @return [AddressConfigurationInstance] Updated AddressConfigurationInstance
249
+ def update(friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset)
250
+ data = Twilio::Values.of({
251
+ 'FriendlyName' => friendly_name,
252
+ 'AutoCreation.Enabled' => auto_creation_enabled,
253
+ 'AutoCreation.Type' => auto_creation_type,
254
+ 'AutoCreation.ConversationServiceSid' => auto_creation_conversation_service_sid,
255
+ 'AutoCreation.WebhookUrl' => auto_creation_webhook_url,
256
+ 'AutoCreation.WebhookMethod' => auto_creation_webhook_method,
257
+ 'AutoCreation.WebhookFilters' => Twilio.serialize_list(auto_creation_webhook_filters) { |e| e },
258
+ 'AutoCreation.StudioFlowSid' => auto_creation_studio_flow_sid,
259
+ 'AutoCreation.StudioRetryCount' => auto_creation_studio_retry_count,
260
+ })
261
+
262
+ payload = @version.update('POST', @uri, data: data)
263
+
264
+ AddressConfigurationInstance.new(@version, payload, sid: @solution[:sid], )
265
+ end
266
+
267
+ ##
268
+ # Delete the AddressConfigurationInstance
269
+ # @return [Boolean] true if delete succeeds, false otherwise
270
+ def delete
271
+ @version.delete('DELETE', @uri)
272
+ end
273
+
274
+ ##
275
+ # Provide a user friendly representation
276
+ def to_s
277
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
278
+ "#<Twilio.Conversations.V1.AddressConfigurationContext #{context}>"
279
+ end
280
+
281
+ ##
282
+ # Provide a detailed, user friendly representation
283
+ def inspect
284
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
285
+ "#<Twilio.Conversations.V1.AddressConfigurationContext #{context}>"
286
+ end
287
+ end
288
+
289
+ class AddressConfigurationInstance < InstanceResource
290
+ ##
291
+ # Initialize the AddressConfigurationInstance
292
+ # @param [Version] version Version that contains the resource
293
+ # @param [Hash] payload payload that contains response from Twilio
294
+ # @param [String] sid The SID of the Address Configuration resource. This value
295
+ # can be either the `sid` or the `address` of the configuration
296
+ # @return [AddressConfigurationInstance] AddressConfigurationInstance
297
+ def initialize(version, payload, sid: nil)
298
+ super(version)
299
+
300
+ # Marshaled Properties
301
+ @properties = {
302
+ 'sid' => payload['sid'],
303
+ 'account_sid' => payload['account_sid'],
304
+ 'type' => payload['type'],
305
+ 'address' => payload['address'],
306
+ 'friendly_name' => payload['friendly_name'],
307
+ 'auto_creation' => payload['auto_creation'],
308
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
309
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
310
+ 'url' => payload['url'],
311
+ }
312
+
313
+ # Context
314
+ @instance_context = nil
315
+ @params = {'sid' => sid || @properties['sid'], }
316
+ end
317
+
318
+ ##
319
+ # Generate an instance context for the instance, the context is capable of
320
+ # performing various actions. All instance actions are proxied to the context
321
+ # @return [AddressConfigurationContext] AddressConfigurationContext for this AddressConfigurationInstance
322
+ def context
323
+ unless @instance_context
324
+ @instance_context = AddressConfigurationContext.new(@version, @params['sid'], )
325
+ end
326
+ @instance_context
327
+ end
328
+
329
+ ##
330
+ # @return [String] A 34 character string that uniquely identifies this resource.
331
+ def sid
332
+ @properties['sid']
333
+ end
334
+
335
+ ##
336
+ # @return [String] The unique ID of the Account the address belongs to.
337
+ def account_sid
338
+ @properties['account_sid']
339
+ end
340
+
341
+ ##
342
+ # @return [String] Type of Address.
343
+ def type
344
+ @properties['type']
345
+ end
346
+
347
+ ##
348
+ # @return [String] The unique address to be configured.
349
+ def address
350
+ @properties['address']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The human-readable name of this configuration.
355
+ def friendly_name
356
+ @properties['friendly_name']
357
+ end
358
+
359
+ ##
360
+ # @return [Hash] Auto Creation configuration for the address.
361
+ def auto_creation
362
+ @properties['auto_creation']
363
+ end
364
+
365
+ ##
366
+ # @return [Time] The date that this resource was created.
367
+ def date_created
368
+ @properties['date_created']
369
+ end
370
+
371
+ ##
372
+ # @return [Time] The date that this resource was last updated.
373
+ def date_updated
374
+ @properties['date_updated']
375
+ end
376
+
377
+ ##
378
+ # @return [String] An absolute URL for this address configuration.
379
+ def url
380
+ @properties['url']
381
+ end
382
+
383
+ ##
384
+ # Fetch the AddressConfigurationInstance
385
+ # @return [AddressConfigurationInstance] Fetched AddressConfigurationInstance
386
+ def fetch
387
+ context.fetch
388
+ end
389
+
390
+ ##
391
+ # Update the AddressConfigurationInstance
392
+ # @param [String] friendly_name The human-readable name of this configuration,
393
+ # limited to 256 characters. Optional.
394
+ # @param [Boolean] auto_creation_enabled Enable/Disable auto-creating
395
+ # conversations for messages to this address
396
+ # @param [address_configuration.AutoCreationType] auto_creation_type Type of Auto
397
+ # Creation. Value can be one of `webhook`, `studio` or `default`.
398
+ # @param [String] auto_creation_conversation_service_sid Conversation Service for
399
+ # the auto-created conversation. If not set, the conversation is created in the
400
+ # default service.
401
+ # @param [String] auto_creation_webhook_url For type `webhook`, the url for the
402
+ # webhook request.
403
+ # @param [address_configuration.Method] auto_creation_webhook_method For type
404
+ # `webhook`, the HTTP method to be used when sending a webhook request.
405
+ # @param [Array[String]] auto_creation_webhook_filters The list of events, firing
406
+ # webhook event for this Conversation. Values can be any of the following:
407
+ # `onMessageAdded`, `onMessageUpdated`, `onMessageRemoved`,
408
+ # `onConversationUpdated`, `onConversationStateUpdated`, `onConversationRemoved`,
409
+ # `onParticipantAdded`, `onParticipantUpdated`, `onParticipantRemoved`,
410
+ # `onDeliveryUpdated`
411
+ # @param [String] auto_creation_studio_flow_sid For type `studio`, the studio flow
412
+ # SID where the webhook should be sent to.
413
+ # @param [String] auto_creation_studio_retry_count For type `studio`, number of
414
+ # times to retry the webhook request
415
+ # @return [AddressConfigurationInstance] Updated AddressConfigurationInstance
416
+ def update(friendly_name: :unset, auto_creation_enabled: :unset, auto_creation_type: :unset, auto_creation_conversation_service_sid: :unset, auto_creation_webhook_url: :unset, auto_creation_webhook_method: :unset, auto_creation_webhook_filters: :unset, auto_creation_studio_flow_sid: :unset, auto_creation_studio_retry_count: :unset)
417
+ context.update(
418
+ friendly_name: friendly_name,
419
+ auto_creation_enabled: auto_creation_enabled,
420
+ auto_creation_type: auto_creation_type,
421
+ auto_creation_conversation_service_sid: auto_creation_conversation_service_sid,
422
+ auto_creation_webhook_url: auto_creation_webhook_url,
423
+ auto_creation_webhook_method: auto_creation_webhook_method,
424
+ auto_creation_webhook_filters: auto_creation_webhook_filters,
425
+ auto_creation_studio_flow_sid: auto_creation_studio_flow_sid,
426
+ auto_creation_studio_retry_count: auto_creation_studio_retry_count,
427
+ )
428
+ end
429
+
430
+ ##
431
+ # Delete the AddressConfigurationInstance
432
+ # @return [Boolean] true if delete succeeds, false otherwise
433
+ def delete
434
+ context.delete
435
+ end
436
+
437
+ ##
438
+ # Provide a user friendly representation
439
+ def to_s
440
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
441
+ "<Twilio.Conversations.V1.AddressConfigurationInstance #{values}>"
442
+ end
443
+
444
+ ##
445
+ # Provide a detailed, user friendly representation
446
+ def inspect
447
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
448
+ "<Twilio.Conversations.V1.AddressConfigurationInstance #{values}>"
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+ end
@@ -63,6 +63,8 @@ module Twilio
63
63
  # Lists MessageInstance records from the API as a list.
64
64
  # Unlike stream(), this operation is eager and will load `limit` records into
65
65
  # memory before returning.
66
+ # @param [message.OrderType] order The sort order of the returned messages. Can
67
+ # be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
66
68
  # @param [Integer] limit Upper limit for the number of records to return. stream()
67
69
  # guarantees to never return more than limit. Default is no limit
68
70
  # @param [Integer] page_size Number of records to fetch per request, when
@@ -70,14 +72,16 @@ module Twilio
70
72
  # but a limit is defined, stream() will attempt to read the limit with the most
71
73
  # efficient page size, i.e. min(limit, 1000)
72
74
  # @return [Array] Array of up to limit results
73
- def list(limit: nil, page_size: nil)
74
- self.stream(limit: limit, page_size: page_size).entries
75
+ def list(order: :unset, limit: nil, page_size: nil)
76
+ self.stream(order: order, limit: limit, page_size: page_size).entries
75
77
  end
76
78
 
77
79
  ##
78
80
  # Streams MessageInstance records from the API as an Enumerable.
79
81
  # This operation lazily loads records as efficiently as possible until the limit
80
82
  # is reached.
83
+ # @param [message.OrderType] order The sort order of the returned messages. Can
84
+ # be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
81
85
  # @param [Integer] limit Upper limit for the number of records to return. stream()
82
86
  # guarantees to never return more than limit. Default is no limit.
83
87
  # @param [Integer] page_size Number of records to fetch per request, when
@@ -85,10 +89,10 @@ module Twilio
85
89
  # but a limit is defined, stream() will attempt to read the limit with the most
86
90
  # efficient page size, i.e. min(limit, 1000)
87
91
  # @return [Enumerable] Enumerable that will yield up to limit results
88
- def stream(limit: nil, page_size: nil)
92
+ def stream(order: :unset, limit: nil, page_size: nil)
89
93
  limits = @version.read_limits(limit, page_size)
90
94
 
91
- page = self.page(page_size: limits[:page_size], )
95
+ page = self.page(order: order, page_size: limits[:page_size], )
92
96
 
93
97
  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
94
98
  end
@@ -110,12 +114,15 @@ module Twilio
110
114
  ##
111
115
  # Retrieve a single page of MessageInstance records from the API.
112
116
  # Request is executed immediately.
117
+ # @param [message.OrderType] order The sort order of the returned messages. Can
118
+ # be: `asc` (ascending) or `desc` (descending), with `asc` as the default.
113
119
  # @param [String] page_token PageToken provided by the API
114
120
  # @param [Integer] page_number Page Number, this value is simply for client state
115
121
  # @param [Integer] page_size Number of records to return, defaults to 50
116
122
  # @return [Page] Page of MessageInstance
117
- def page(page_token: :unset, page_number: :unset, page_size: :unset)
123
+ def page(order: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
118
124
  params = Twilio::Values.of({
125
+ 'Order' => order,
119
126
  'PageToken' => page_token,
120
127
  'Page' => page_number,
121
128
  'PageSize' => page_size,
@@ -362,6 +362,7 @@ module Twilio
362
362
  'timers' => payload['timers'],
363
363
  'url' => payload['url'],
364
364
  'links' => payload['links'],
365
+ 'bindings' => payload['bindings'],
365
366
  }
366
367
 
367
368
  # Context
@@ -458,6 +459,12 @@ module Twilio
458
459
  @properties['links']
459
460
  end
460
461
 
462
+ ##
463
+ # @return [Hash] The bindings
464
+ def bindings
465
+ @properties['bindings']
466
+ end
467
+
461
468
  ##
462
469
  # Update the ConversationInstance
463
470
  # @param [String] friendly_name The human-readable name of this conversation,