twilio-ruby 5.46.1 → 5.47.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +31 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/events/v1/sink.rb +2 -1
  5. data/lib/twilio-ruby/rest/events/v1/subscription.rb +1 -0
  6. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +14 -0
  7. data/lib/twilio-ruby/rest/messaging.rb +22 -0
  8. data/lib/twilio-ruby/rest/messaging/v1.rb +37 -0
  9. data/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +328 -0
  10. data/lib/twilio-ruby/rest/messaging/v1/campaign.rb +387 -0
  11. data/lib/twilio-ruby/rest/messaging/v1/use_case.rb +198 -0
  12. data/lib/twilio-ruby/rest/preview/sync/service/document.rb +4 -8
  13. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +11 -1
  14. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +13 -13
  15. data/lib/twilio-ruby/rest/sync/v1/service.rb +0 -8
  16. data/lib/twilio-ruby/rest/sync/v1/service/document.rb +4 -16
  17. data/lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb +0 -8
  18. data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +0 -8
  19. data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb +16 -12
  20. data/lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb +0 -8
  21. data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +0 -8
  22. data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb +16 -12
  23. data/lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb +0 -8
  24. data/lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb +0 -8
  25. data/lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb +0 -6
  26. data/lib/twilio-ruby/twiml/voice_response.rb +4 -2
  27. data/lib/twilio-ruby/version.rb +1 -1
  28. data/spec/integration/api/v2010/account/conference_spec.rb +302 -44
  29. data/spec/integration/flex_api/v1/configuration_spec.rb +24 -0
  30. data/spec/integration/messaging/v1/brand_registration_spec.rb +143 -0
  31. data/spec/integration/messaging/v1/campaign_spec.rb +194 -0
  32. data/spec/integration/messaging/v1/use_case_spec.rb +55 -0
  33. data/spec/integration/preview/sync/service/document_spec.rb +1 -3
  34. data/spec/integration/serverless/v1/service/build_spec.rb +12 -2
  35. data/spec/integration/supersim/v1/fleet_spec.rb +8 -0
  36. data/spec/integration/sync/v1/service/document_spec.rb +1 -3
  37. metadata +11 -2
@@ -0,0 +1,387 @@
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 Messaging < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
15
+ class CampaignList < ListResource
16
+ ##
17
+ # Initialize the CampaignList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [CampaignList] CampaignList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/a2p/Campaigns"
26
+ end
27
+
28
+ ##
29
+ # Lists CampaignInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
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(limit: nil, page_size: nil)
40
+ self.stream(limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams CampaignInstance 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 [Integer] limit Upper limit for the number of records to return. stream()
48
+ # guarantees to never return more than limit. Default is no limit.
49
+ # @param [Integer] page_size Number of records to fetch per request, when
50
+ # not set will use the default value of 50 records. If no page_size is defined
51
+ # but a limit is defined, stream() will attempt to read the limit with the most
52
+ # efficient page size, i.e. min(limit, 1000)
53
+ # @return [Enumerable] Enumerable that will yield up to limit results
54
+ def stream(limit: nil, page_size: nil)
55
+ limits = @version.read_limits(limit, page_size)
56
+
57
+ page = self.page(page_size: limits[:page_size], )
58
+
59
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
+ end
61
+
62
+ ##
63
+ # When passed a block, yields CampaignInstance records from the API.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ def each
67
+ limits = @version.read_limits
68
+
69
+ page = self.page(page_size: limits[:page_size], )
70
+
71
+ @version.stream(page,
72
+ limit: limits[:limit],
73
+ page_limit: limits[:page_limit]).each {|x| yield x}
74
+ end
75
+
76
+ ##
77
+ # Retrieve a single page of CampaignInstance records from the API.
78
+ # Request is executed immediately.
79
+ # @param [String] page_token PageToken provided by the API
80
+ # @param [Integer] page_number Page Number, this value is simply for client state
81
+ # @param [Integer] page_size Number of records to return, defaults to 50
82
+ # @return [Page] Page of CampaignInstance
83
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
84
+ params = Twilio::Values.of({
85
+ 'PageToken' => page_token,
86
+ 'Page' => page_number,
87
+ 'PageSize' => page_size,
88
+ })
89
+
90
+ response = @version.page('GET', @uri, params: params)
91
+
92
+ CampaignPage.new(@version, response, @solution)
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of CampaignInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] target_url API-generated URL for the requested results page
99
+ # @return [Page] Page of CampaignInstance
100
+ def get_page(target_url)
101
+ response = @version.domain.request(
102
+ 'GET',
103
+ target_url
104
+ )
105
+ CampaignPage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Create the CampaignInstance
110
+ # @param [String] brand_registration_sid A2P BrandRegistration Sid
111
+ # @param [String] use_case A2P Campaign UseCase. One of [ 2FA, EMERGENCY,
112
+ # MARKETING ]
113
+ # @param [String] description A short description of what this SMS campaign does.
114
+ # @param [Array[String]] message_samples Message samples, up to 5 sample messages,
115
+ # <=255 chars each. Example: [ "EXPRESS: Denim Days Event is ON", "LAST CHANCE:
116
+ # Book your next flight for just 1 (ONE) EUR" ]
117
+ # @param [Boolean] has_embedded_links Indicate that this SMS campaign will send
118
+ # messages that contain links.
119
+ # @param [Boolean] has_embedded_phone Indicates that this SMS campaign will send
120
+ # messages that contain phone numbers.
121
+ # @param [String] messaging_service_sid The SID of the
122
+ # {Service}[https://www.twilio.com/docs/chat/rest/service-resource] to read the
123
+ # resources from.
124
+ # @return [CampaignInstance] Created CampaignInstance
125
+ def create(brand_registration_sid: nil, use_case: nil, description: nil, message_samples: nil, has_embedded_links: nil, has_embedded_phone: nil, messaging_service_sid: nil)
126
+ data = Twilio::Values.of({
127
+ 'BrandRegistrationSid' => brand_registration_sid,
128
+ 'UseCase' => use_case,
129
+ 'Description' => description,
130
+ 'MessageSamples' => Twilio.serialize_list(message_samples) { |e| e },
131
+ 'HasEmbeddedLinks' => has_embedded_links,
132
+ 'HasEmbeddedPhone' => has_embedded_phone,
133
+ 'MessagingServiceSid' => messaging_service_sid,
134
+ })
135
+
136
+ payload = @version.create('POST', @uri, data: data)
137
+
138
+ CampaignInstance.new(@version, payload, )
139
+ end
140
+
141
+ ##
142
+ # Provide a user friendly representation
143
+ def to_s
144
+ '#<Twilio.Messaging.V1.CampaignList>'
145
+ end
146
+ end
147
+
148
+ ##
149
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
150
+ class CampaignPage < Page
151
+ ##
152
+ # Initialize the CampaignPage
153
+ # @param [Version] version Version that contains the resource
154
+ # @param [Response] response Response from the API
155
+ # @param [Hash] solution Path solution for the resource
156
+ # @return [CampaignPage] CampaignPage
157
+ def initialize(version, response, solution)
158
+ super(version, response)
159
+
160
+ # Path Solution
161
+ @solution = solution
162
+ end
163
+
164
+ ##
165
+ # Build an instance of CampaignInstance
166
+ # @param [Hash] payload Payload response from the API
167
+ # @return [CampaignInstance] CampaignInstance
168
+ def get_instance(payload)
169
+ CampaignInstance.new(@version, payload, )
170
+ end
171
+
172
+ ##
173
+ # Provide a user friendly representation
174
+ def to_s
175
+ '<Twilio.Messaging.V1.CampaignPage>'
176
+ end
177
+ end
178
+
179
+ ##
180
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
181
+ class CampaignContext < InstanceContext
182
+ ##
183
+ # Initialize the CampaignContext
184
+ # @param [Version] version Version that contains the resource
185
+ # @param [String] sid The SID of the Campaign resource to fetch.
186
+ # @return [CampaignContext] CampaignContext
187
+ def initialize(version, sid)
188
+ super(version)
189
+
190
+ # Path Solution
191
+ @solution = {sid: sid, }
192
+ @uri = "/a2p/Campaigns/#{@solution[:sid]}"
193
+ end
194
+
195
+ ##
196
+ # Fetch the CampaignInstance
197
+ # @return [CampaignInstance] Fetched CampaignInstance
198
+ def fetch
199
+ payload = @version.fetch('GET', @uri)
200
+
201
+ CampaignInstance.new(@version, payload, sid: @solution[:sid], )
202
+ end
203
+
204
+ ##
205
+ # Delete the CampaignInstance
206
+ # @return [Boolean] true if delete succeeds, false otherwise
207
+ def delete
208
+ @version.delete('DELETE', @uri)
209
+ end
210
+
211
+ ##
212
+ # Provide a user friendly representation
213
+ def to_s
214
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
215
+ "#<Twilio.Messaging.V1.CampaignContext #{context}>"
216
+ end
217
+
218
+ ##
219
+ # Provide a detailed, user friendly representation
220
+ def inspect
221
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
222
+ "#<Twilio.Messaging.V1.CampaignContext #{context}>"
223
+ end
224
+ end
225
+
226
+ ##
227
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
228
+ class CampaignInstance < InstanceResource
229
+ ##
230
+ # Initialize the CampaignInstance
231
+ # @param [Version] version Version that contains the resource
232
+ # @param [Hash] payload payload that contains response from Twilio
233
+ # @param [String] sid The SID of the Campaign resource to fetch.
234
+ # @return [CampaignInstance] CampaignInstance
235
+ def initialize(version, payload, sid: nil)
236
+ super(version)
237
+
238
+ # Marshaled Properties
239
+ @properties = {
240
+ 'account_sid' => payload['account_sid'],
241
+ 'messaging_service_sid' => payload['messaging_service_sid'],
242
+ 'brand_registration_sid' => payload['brand_registration_sid'],
243
+ 'sid' => payload['sid'],
244
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
245
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
246
+ 'description' => payload['description'],
247
+ 'message_samples' => payload['message_samples'],
248
+ 'status' => payload['status'],
249
+ 'failure_reason' => payload['failure_reason'],
250
+ 'use_case' => payload['use_case'],
251
+ 'has_embedded_links' => payload['has_embedded_links'],
252
+ 'has_embedded_phone' => payload['has_embedded_phone'],
253
+ 'url' => payload['url'],
254
+ }
255
+
256
+ # Context
257
+ @instance_context = nil
258
+ @params = {'sid' => sid || @properties['sid'], }
259
+ end
260
+
261
+ ##
262
+ # Generate an instance context for the instance, the context is capable of
263
+ # performing various actions. All instance actions are proxied to the context
264
+ # @return [CampaignContext] CampaignContext for this CampaignInstance
265
+ def context
266
+ unless @instance_context
267
+ @instance_context = CampaignContext.new(@version, @params['sid'], )
268
+ end
269
+ @instance_context
270
+ end
271
+
272
+ ##
273
+ # @return [String] The SID of the Account that created the resource
274
+ def account_sid
275
+ @properties['account_sid']
276
+ end
277
+
278
+ ##
279
+ # @return [String] MessagingService SID
280
+ def messaging_service_sid
281
+ @properties['messaging_service_sid']
282
+ end
283
+
284
+ ##
285
+ # @return [String] A2P BrandRegistration Sid
286
+ def brand_registration_sid
287
+ @properties['brand_registration_sid']
288
+ end
289
+
290
+ ##
291
+ # @return [String] Campaign sid
292
+ def sid
293
+ @properties['sid']
294
+ end
295
+
296
+ ##
297
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was created
298
+ def date_created
299
+ @properties['date_created']
300
+ end
301
+
302
+ ##
303
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
304
+ def date_updated
305
+ @properties['date_updated']
306
+ end
307
+
308
+ ##
309
+ # @return [String] A short description of what this SMS campaign does
310
+ def description
311
+ @properties['description']
312
+ end
313
+
314
+ ##
315
+ # @return [Array[String]] Message samples
316
+ def message_samples
317
+ @properties['message_samples']
318
+ end
319
+
320
+ ##
321
+ # @return [campaign.Status] Campaign status
322
+ def status
323
+ @properties['status']
324
+ end
325
+
326
+ ##
327
+ # @return [String] A reason why campaign registration has failed
328
+ def failure_reason
329
+ @properties['failure_reason']
330
+ end
331
+
332
+ ##
333
+ # @return [String] A2P Campaign UseCase.
334
+ def use_case
335
+ @properties['use_case']
336
+ end
337
+
338
+ ##
339
+ # @return [Boolean] Indicate that this SMS campaign will send messages that contain links
340
+ def has_embedded_links
341
+ @properties['has_embedded_links']
342
+ end
343
+
344
+ ##
345
+ # @return [Boolean] Indicates that this SMS campaign will send messages that contain phone numbers
346
+ def has_embedded_phone
347
+ @properties['has_embedded_phone']
348
+ end
349
+
350
+ ##
351
+ # @return [String] The absolute URL of the Campaign resource
352
+ def url
353
+ @properties['url']
354
+ end
355
+
356
+ ##
357
+ # Fetch the CampaignInstance
358
+ # @return [CampaignInstance] Fetched CampaignInstance
359
+ def fetch
360
+ context.fetch
361
+ end
362
+
363
+ ##
364
+ # Delete the CampaignInstance
365
+ # @return [Boolean] true if delete succeeds, false otherwise
366
+ def delete
367
+ context.delete
368
+ end
369
+
370
+ ##
371
+ # Provide a user friendly representation
372
+ def to_s
373
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
374
+ "<Twilio.Messaging.V1.CampaignInstance #{values}>"
375
+ end
376
+
377
+ ##
378
+ # Provide a detailed, user friendly representation
379
+ def inspect
380
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
381
+ "<Twilio.Messaging.V1.CampaignInstance #{values}>"
382
+ end
383
+ end
384
+ end
385
+ end
386
+ end
387
+ end
@@ -0,0 +1,198 @@
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 Messaging < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
15
+ class UseCaseList < ListResource
16
+ ##
17
+ # Initialize the UseCaseList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [UseCaseList] UseCaseList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/a2p/UseCases"
26
+ end
27
+
28
+ ##
29
+ # Lists UseCaseInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
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(limit: nil, page_size: nil)
40
+ self.stream(limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams UseCaseInstance 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 [Integer] limit Upper limit for the number of records to return. stream()
48
+ # guarantees to never return more than limit. Default is no limit.
49
+ # @param [Integer] page_size Number of records to fetch per request, when
50
+ # not set will use the default value of 50 records. If no page_size is defined
51
+ # but a limit is defined, stream() will attempt to read the limit with the most
52
+ # efficient page size, i.e. min(limit, 1000)
53
+ # @return [Enumerable] Enumerable that will yield up to limit results
54
+ def stream(limit: nil, page_size: nil)
55
+ limits = @version.read_limits(limit, page_size)
56
+
57
+ page = self.page(page_size: limits[:page_size], )
58
+
59
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
+ end
61
+
62
+ ##
63
+ # When passed a block, yields UseCaseInstance records from the API.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ def each
67
+ limits = @version.read_limits
68
+
69
+ page = self.page(page_size: limits[:page_size], )
70
+
71
+ @version.stream(page,
72
+ limit: limits[:limit],
73
+ page_limit: limits[:page_limit]).each {|x| yield x}
74
+ end
75
+
76
+ ##
77
+ # Retrieve a single page of UseCaseInstance records from the API.
78
+ # Request is executed immediately.
79
+ # @param [String] page_token PageToken provided by the API
80
+ # @param [Integer] page_number Page Number, this value is simply for client state
81
+ # @param [Integer] page_size Number of records to return, defaults to 50
82
+ # @return [Page] Page of UseCaseInstance
83
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
84
+ params = Twilio::Values.of({
85
+ 'PageToken' => page_token,
86
+ 'Page' => page_number,
87
+ 'PageSize' => page_size,
88
+ })
89
+
90
+ response = @version.page('GET', @uri, params: params)
91
+
92
+ UseCasePage.new(@version, response, @solution)
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of UseCaseInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] target_url API-generated URL for the requested results page
99
+ # @return [Page] Page of UseCaseInstance
100
+ def get_page(target_url)
101
+ response = @version.domain.request(
102
+ 'GET',
103
+ target_url
104
+ )
105
+ UseCasePage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Provide a user friendly representation
110
+ def to_s
111
+ '#<Twilio.Messaging.V1.UseCaseList>'
112
+ end
113
+ end
114
+
115
+ ##
116
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
117
+ class UseCasePage < Page
118
+ ##
119
+ # Initialize the UseCasePage
120
+ # @param [Version] version Version that contains the resource
121
+ # @param [Response] response Response from the API
122
+ # @param [Hash] solution Path solution for the resource
123
+ # @return [UseCasePage] UseCasePage
124
+ def initialize(version, response, solution)
125
+ super(version, response)
126
+
127
+ # Path Solution
128
+ @solution = solution
129
+ end
130
+
131
+ ##
132
+ # Build an instance of UseCaseInstance
133
+ # @param [Hash] payload Payload response from the API
134
+ # @return [UseCaseInstance] UseCaseInstance
135
+ def get_instance(payload)
136
+ UseCaseInstance.new(@version, payload, )
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '<Twilio.Messaging.V1.UseCasePage>'
143
+ end
144
+ end
145
+
146
+ ##
147
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
148
+ class UseCaseInstance < InstanceResource
149
+ ##
150
+ # Initialize the UseCaseInstance
151
+ # @param [Version] version Version that contains the resource
152
+ # @param [Hash] payload payload that contains response from Twilio
153
+ # @return [UseCaseInstance] UseCaseInstance
154
+ def initialize(version, payload)
155
+ super(version)
156
+
157
+ # Marshaled Properties
158
+ @properties = {
159
+ 'name' => payload['name'],
160
+ 'code' => payload['code'],
161
+ 'description' => payload['description'],
162
+ }
163
+ end
164
+
165
+ ##
166
+ # @return [String] Human readable name
167
+ def name
168
+ @properties['name']
169
+ end
170
+
171
+ ##
172
+ # @return [String] Unique Use Case code
173
+ def code
174
+ @properties['code']
175
+ end
176
+
177
+ ##
178
+ # @return [String] Description of Use Case
179
+ def description
180
+ @properties['description']
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ "<Twilio.Messaging.V1.UseCaseInstance>"
187
+ end
188
+
189
+ ##
190
+ # Provide a detailed, user friendly representation
191
+ def inspect
192
+ "<Twilio.Messaging.V1.UseCaseInstance>"
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end