voiceml 0.8.1 → 0.9.2

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.
@@ -0,0 +1,610 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'common'
4
+ require_relative 'voice_v1' # V1Pageable lives here; Conversations v1 reuses the same `meta` envelope
5
+
6
+ module VoiceML
7
+ # Twilio Conversations v1 (conversations.twilio.com/v1) resources.
8
+ #
9
+ # Same /v1 conventions as Voice v1: Basic-auth account resolution, ISO-8601 dates,
10
+ # `meta` list envelope (V1Pageable). 15 resources for v0.9.0:
11
+ # - Conversation (CH...), ConversationMessage (IM...), ConversationParticipant (MB...)
12
+ # - ConversationMessageReceipt (DY...), ConversationScopedWebhook (WH...)
13
+ # - Role (RL...), User (US...), Credential (CR...)
14
+ # - Configuration, ConfigurationWebhook, ConfigAddress (IG...)
15
+ # - ParticipantConversation, ConversationWithParticipants, UserConversation
16
+ # - Service (IS...) + ServiceConversation (CH..., service-scoped)
17
+
18
+ # ConversationsV1Conversation — `CH...`.
19
+ class ConversationsV1Conversation
20
+ ATTRIBUTES = %w[
21
+ account_sid chat_service_sid messaging_service_sid sid friendly_name
22
+ unique_name attributes state date_created date_updated timers url links bindings
23
+ ].freeze
24
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
25
+ def initialize(attrs = {})
26
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
27
+ end
28
+ def self.from_hash(h); h.nil? ? nil : new(h); end
29
+ end
30
+
31
+ class ConversationsV1ConversationList
32
+ include V1Pageable
33
+ attr_reader :conversations
34
+ def initialize(hash = {})
35
+ assign_meta_fields(hash)
36
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1Conversation.from_hash(h) }
37
+ end
38
+ end
39
+
40
+ # ConversationsV1ConversationMessage — `IM...`.
41
+ class ConversationsV1ConversationMessage
42
+ ATTRIBUTES = %w[
43
+ account_sid conversation_sid sid index author body media attributes
44
+ participant_sid date_created date_updated url delivery links content_sid
45
+ ].freeze
46
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
47
+ def initialize(attrs = {})
48
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
49
+ end
50
+ def self.from_hash(h); h.nil? ? nil : new(h); end
51
+ end
52
+
53
+ class ConversationsV1ConversationMessageList
54
+ include V1Pageable
55
+ attr_reader :messages
56
+ def initialize(hash = {})
57
+ assign_meta_fields(hash)
58
+ @messages = (hash['messages'] || []).map { |h| ConversationsV1ConversationMessage.from_hash(h) }
59
+ end
60
+ end
61
+
62
+ # ConversationsV1ConversationParticipant — `MB...`.
63
+ class ConversationsV1ConversationParticipant
64
+ ATTRIBUTES = %w[
65
+ account_sid conversation_sid sid identity attributes messaging_binding
66
+ role_sid date_created date_updated url last_read_message_index last_read_timestamp
67
+ ].freeze
68
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
69
+ def initialize(attrs = {})
70
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
71
+ end
72
+ def self.from_hash(h); h.nil? ? nil : new(h); end
73
+ end
74
+
75
+ class ConversationsV1ConversationParticipantList
76
+ include V1Pageable
77
+ attr_reader :participants
78
+ def initialize(hash = {})
79
+ assign_meta_fields(hash)
80
+ @participants = (hash['participants'] || []).map { |h| ConversationsV1ConversationParticipant.from_hash(h) }
81
+ end
82
+ end
83
+
84
+ # ConversationsV1ConversationMessageReceipt — `DY...`.
85
+ class ConversationsV1ConversationMessageReceipt
86
+ ATTRIBUTES = %w[
87
+ account_sid conversation_sid sid message_sid channel_message_sid
88
+ participant_sid status error_code date_created date_updated url
89
+ ].freeze
90
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
91
+ def initialize(attrs = {})
92
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
93
+ end
94
+ def self.from_hash(h); h.nil? ? nil : new(h); end
95
+ end
96
+
97
+ class ConversationsV1ConversationMessageReceiptList
98
+ include V1Pageable
99
+ attr_reader :delivery_receipts
100
+ def initialize(hash = {})
101
+ assign_meta_fields(hash)
102
+ @delivery_receipts = (hash['delivery_receipts'] || []).map { |h| ConversationsV1ConversationMessageReceipt.from_hash(h) }
103
+ end
104
+ end
105
+
106
+ # ConversationsV1ConversationScopedWebhook — `WH...`.
107
+ class ConversationsV1ConversationScopedWebhook
108
+ ATTRIBUTES = %w[
109
+ sid account_sid conversation_sid target url configuration date_created date_updated
110
+ ].freeze
111
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
112
+ def initialize(attrs = {})
113
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
114
+ end
115
+ def self.from_hash(h); h.nil? ? nil : new(h); end
116
+ end
117
+
118
+ class ConversationsV1ConversationScopedWebhookList
119
+ include V1Pageable
120
+ attr_reader :webhooks
121
+ def initialize(hash = {})
122
+ assign_meta_fields(hash)
123
+ @webhooks = (hash['webhooks'] || []).map { |h| ConversationsV1ConversationScopedWebhook.from_hash(h) }
124
+ end
125
+ end
126
+
127
+ # ConversationsV1Role — `RL...`.
128
+ class ConversationsV1Role
129
+ ATTRIBUTES = %w[
130
+ sid account_sid chat_service_sid friendly_name type permissions
131
+ date_created date_updated url
132
+ ].freeze
133
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
134
+ def initialize(attrs = {})
135
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
136
+ end
137
+ def self.from_hash(h); h.nil? ? nil : new(h); end
138
+ end
139
+
140
+ class ConversationsV1RoleList
141
+ include V1Pageable
142
+ attr_reader :roles
143
+ def initialize(hash = {})
144
+ assign_meta_fields(hash)
145
+ @roles = (hash['roles'] || []).map { |h| ConversationsV1Role.from_hash(h) }
146
+ end
147
+ end
148
+
149
+ # ConversationsV1User — `US...`.
150
+ class ConversationsV1User
151
+ ATTRIBUTES = %w[
152
+ sid account_sid chat_service_sid role_sid identity friendly_name attributes
153
+ is_online is_notifiable date_created date_updated url links
154
+ ].freeze
155
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
156
+ def initialize(attrs = {})
157
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
158
+ end
159
+ def self.from_hash(h); h.nil? ? nil : new(h); end
160
+ end
161
+
162
+ class ConversationsV1UserList
163
+ include V1Pageable
164
+ attr_reader :users
165
+ def initialize(hash = {})
166
+ assign_meta_fields(hash)
167
+ @users = (hash['users'] || []).map { |h| ConversationsV1User.from_hash(h) }
168
+ end
169
+ end
170
+
171
+ # ConversationsV1Credential — `CR...` (push Credential — distinct from SipCredential).
172
+ class ConversationsV1Credential
173
+ ATTRIBUTES = %w[
174
+ sid account_sid friendly_name type sandbox date_created date_updated url
175
+ ].freeze
176
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
177
+ def initialize(attrs = {})
178
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
179
+ end
180
+ def self.from_hash(h); h.nil? ? nil : new(h); end
181
+ end
182
+
183
+ class ConversationsV1CredentialList
184
+ include V1Pageable
185
+ attr_reader :credentials
186
+ def initialize(hash = {})
187
+ assign_meta_fields(hash)
188
+ @credentials = (hash['credentials'] || []).map { |h| ConversationsV1Credential.from_hash(h) }
189
+ end
190
+ end
191
+
192
+ # ConversationsV1Configuration — account-level Conversations defaults.
193
+ class ConversationsV1Configuration
194
+ ATTRIBUTES = %w[
195
+ account_sid default_chat_service_sid default_messaging_service_sid
196
+ default_inactive_timer default_closed_timer url links
197
+ ].freeze
198
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
199
+ def initialize(attrs = {})
200
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
201
+ end
202
+ def self.from_hash(h); h.nil? ? nil : new(h); end
203
+ end
204
+
205
+ # ConversationsV1ConfigurationWebhook — account-global webhook config.
206
+ class ConversationsV1ConfigurationWebhook
207
+ ATTRIBUTES = %w[
208
+ account_sid method filters pre_webhook_url post_webhook_url target url
209
+ ].freeze
210
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
211
+ def initialize(attrs = {})
212
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
213
+ end
214
+ def self.from_hash(h); h.nil? ? nil : new(h); end
215
+ end
216
+
217
+ # ConversationsV1ConfigAddress — `IG...`.
218
+ class ConversationsV1ConfigAddress
219
+ ATTRIBUTES = %w[
220
+ sid account_sid type address friendly_name auto_creation
221
+ date_created date_updated url address_country
222
+ ].freeze
223
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
224
+ def initialize(attrs = {})
225
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
226
+ end
227
+ def self.from_hash(h); h.nil? ? nil : new(h); end
228
+ end
229
+
230
+ class ConversationsV1ConfigAddressList
231
+ include V1Pageable
232
+ attr_reader :addresses
233
+ def initialize(hash = {})
234
+ assign_meta_fields(hash)
235
+ @addresses = (hash['addresses'] || []).map { |h| ConversationsV1ConfigAddress.from_hash(h) }
236
+ end
237
+ end
238
+
239
+ # ConversationsV1ParticipantConversation — read-only join of Participant + Conversation.
240
+ class ConversationsV1ParticipantConversation
241
+ ATTRIBUTES = %w[
242
+ account_sid chat_service_sid participant_sid participant_user_sid
243
+ participant_identity participant_messaging_binding conversation_sid
244
+ conversation_unique_name conversation_friendly_name conversation_attributes
245
+ conversation_date_created conversation_date_updated conversation_created_by
246
+ conversation_state conversation_timers links
247
+ ].freeze
248
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
249
+ def initialize(attrs = {})
250
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
251
+ end
252
+ def self.from_hash(h); h.nil? ? nil : new(h); end
253
+ end
254
+
255
+ class ConversationsV1ParticipantConversationList
256
+ include V1Pageable
257
+ attr_reader :conversations
258
+ def initialize(hash = {})
259
+ assign_meta_fields(hash)
260
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1ParticipantConversation.from_hash(h) }
261
+ end
262
+ end
263
+
264
+ # ConversationsV1ConversationWithParticipants — single-call conversation + initial participants.
265
+ # Returned by POST /v1/ConversationWithParticipants; field-identical to ConversationsV1Conversation.
266
+ class ConversationsV1ConversationWithParticipants
267
+ ATTRIBUTES = %w[
268
+ account_sid chat_service_sid messaging_service_sid sid friendly_name
269
+ unique_name attributes state date_created date_updated timers links bindings url
270
+ ].freeze
271
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
272
+ def initialize(attrs = {})
273
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
274
+ end
275
+ def self.from_hash(h); h.nil? ? nil : new(h); end
276
+ end
277
+
278
+ # ConversationsV1UserConversation — a user's view of a conversation they belong to.
279
+ class ConversationsV1UserConversation
280
+ ATTRIBUTES = %w[
281
+ account_sid chat_service_sid conversation_sid unread_messages_count
282
+ last_read_message_index participant_sid user_sid friendly_name conversation_state
283
+ timers attributes date_created date_updated created_by notification_level
284
+ unique_name url links
285
+ ].freeze
286
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
287
+ def initialize(attrs = {})
288
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
289
+ end
290
+ def self.from_hash(h); h.nil? ? nil : new(h); end
291
+ end
292
+
293
+ class ConversationsV1UserConversationList
294
+ include V1Pageable
295
+ attr_reader :conversations
296
+ def initialize(hash = {})
297
+ assign_meta_fields(hash)
298
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1UserConversation.from_hash(h) }
299
+ end
300
+ end
301
+
302
+ # ConversationsV1Service — `IS...`. Conversation service.
303
+ class ConversationsV1Service
304
+ ATTRIBUTES = %w[
305
+ sid account_sid friendly_name date_created date_updated url links
306
+ ].freeze
307
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
308
+ def initialize(attrs = {})
309
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
310
+ end
311
+ def self.from_hash(h); h.nil? ? nil : new(h); end
312
+ end
313
+
314
+ class ConversationsV1ServiceList
315
+ include V1Pageable
316
+ attr_reader :services
317
+ def initialize(hash = {})
318
+ assign_meta_fields(hash)
319
+ @services = (hash['services'] || []).map { |h| ConversationsV1Service.from_hash(h) }
320
+ end
321
+ end
322
+
323
+ # ConversationsV1ServiceConversation — service-scoped Conversation; field-identical to
324
+ # ConversationsV1Conversation. Twilio's service_conversation mirrors conversation.
325
+ class ConversationsV1ServiceConversation
326
+ ATTRIBUTES = %w[
327
+ account_sid chat_service_sid messaging_service_sid sid friendly_name
328
+ unique_name attributes state date_created date_updated timers url links bindings
329
+ ].freeze
330
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
331
+ def initialize(attrs = {})
332
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
333
+ end
334
+ def self.from_hash(h); h.nil? ? nil : new(h); end
335
+ end
336
+
337
+ class ConversationsV1ServiceConversationList
338
+ include V1Pageable
339
+ attr_reader :conversations
340
+ def initialize(hash = {})
341
+ assign_meta_fields(hash)
342
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1ServiceConversation.from_hash(h) }
343
+ end
344
+ end
345
+
346
+ # ============================================================================
347
+ # Phase 4 — service-scoped sub-resources under /v1/Services/{ChatServiceSid}/.
348
+ # Field-shape mirrors the account-level equivalents; `chat_service_sid` is
349
+ # included on every record.
350
+ # ============================================================================
351
+
352
+ # ConversationsV1ServiceConversationMessage — `IM...`, scoped to a Service.
353
+ class ConversationsV1ServiceConversationMessage
354
+ ATTRIBUTES = %w[
355
+ account_sid chat_service_sid conversation_sid sid index author body media
356
+ attributes participant_sid date_created date_updated url delivery links content_sid
357
+ ].freeze
358
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
359
+ def initialize(attrs = {})
360
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
361
+ end
362
+ def self.from_hash(h); h.nil? ? nil : new(h); end
363
+ end
364
+
365
+ class ConversationsV1ServiceConversationMessageList
366
+ include V1Pageable
367
+ attr_reader :messages
368
+ def initialize(hash = {})
369
+ assign_meta_fields(hash)
370
+ @messages = (hash['messages'] || []).map { |h| ConversationsV1ServiceConversationMessage.from_hash(h) }
371
+ end
372
+ end
373
+
374
+ # ConversationsV1ServiceConversationParticipant — `MB...`, scoped to a Service.
375
+ class ConversationsV1ServiceConversationParticipant
376
+ ATTRIBUTES = %w[
377
+ account_sid chat_service_sid conversation_sid sid identity attributes
378
+ messaging_binding role_sid date_created date_updated url
379
+ last_read_message_index last_read_timestamp
380
+ ].freeze
381
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
382
+ def initialize(attrs = {})
383
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
384
+ end
385
+ def self.from_hash(h); h.nil? ? nil : new(h); end
386
+ end
387
+
388
+ class ConversationsV1ServiceConversationParticipantList
389
+ include V1Pageable
390
+ attr_reader :participants
391
+ def initialize(hash = {})
392
+ assign_meta_fields(hash)
393
+ @participants = (hash['participants'] || []).map { |h| ConversationsV1ServiceConversationParticipant.from_hash(h) }
394
+ end
395
+ end
396
+
397
+ # ConversationsV1ServiceConversationMessageReceipt — `DY...`, scoped to a Service.
398
+ class ConversationsV1ServiceConversationMessageReceipt
399
+ ATTRIBUTES = %w[
400
+ account_sid chat_service_sid conversation_sid sid message_sid
401
+ channel_message_sid participant_sid status error_code
402
+ date_created date_updated url
403
+ ].freeze
404
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
405
+ def initialize(attrs = {})
406
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
407
+ end
408
+ def self.from_hash(h); h.nil? ? nil : new(h); end
409
+ end
410
+
411
+ class ConversationsV1ServiceConversationMessageReceiptList
412
+ include V1Pageable
413
+ attr_reader :delivery_receipts
414
+ def initialize(hash = {})
415
+ assign_meta_fields(hash)
416
+ @delivery_receipts = (hash['delivery_receipts'] || []).map { |h| ConversationsV1ServiceConversationMessageReceipt.from_hash(h) }
417
+ end
418
+ end
419
+
420
+ # ConversationsV1ServiceConversationScopedWebhook — `WH...`, scoped to a Service.
421
+ class ConversationsV1ServiceConversationScopedWebhook
422
+ ATTRIBUTES = %w[
423
+ sid account_sid chat_service_sid conversation_sid target url configuration
424
+ date_created date_updated
425
+ ].freeze
426
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
427
+ def initialize(attrs = {})
428
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
429
+ end
430
+ def self.from_hash(h); h.nil? ? nil : new(h); end
431
+ end
432
+
433
+ class ConversationsV1ServiceConversationScopedWebhookList
434
+ include V1Pageable
435
+ attr_reader :webhooks
436
+ def initialize(hash = {})
437
+ assign_meta_fields(hash)
438
+ @webhooks = (hash['webhooks'] || []).map { |h| ConversationsV1ServiceConversationScopedWebhook.from_hash(h) }
439
+ end
440
+ end
441
+
442
+ # ConversationsV1ServiceConversationWithParticipants — service-scoped
443
+ # single-call conv + participants; field-identical to ServiceConversation.
444
+ class ConversationsV1ServiceConversationWithParticipants
445
+ ATTRIBUTES = %w[
446
+ account_sid chat_service_sid messaging_service_sid sid friendly_name
447
+ unique_name attributes state date_created date_updated timers links bindings url
448
+ ].freeze
449
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
450
+ def initialize(attrs = {})
451
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
452
+ end
453
+ def self.from_hash(h); h.nil? ? nil : new(h); end
454
+ end
455
+
456
+ # ConversationsV1ServiceParticipantConversation — read-only join, service-scoped.
457
+ class ConversationsV1ServiceParticipantConversation
458
+ ATTRIBUTES = %w[
459
+ account_sid chat_service_sid participant_sid participant_user_sid
460
+ participant_identity participant_messaging_binding conversation_sid
461
+ conversation_unique_name conversation_friendly_name conversation_attributes
462
+ conversation_date_created conversation_date_updated conversation_created_by
463
+ conversation_state conversation_timers links
464
+ ].freeze
465
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
466
+ def initialize(attrs = {})
467
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
468
+ end
469
+ def self.from_hash(h); h.nil? ? nil : new(h); end
470
+ end
471
+
472
+ class ConversationsV1ServiceParticipantConversationList
473
+ include V1Pageable
474
+ attr_reader :conversations
475
+ def initialize(hash = {})
476
+ assign_meta_fields(hash)
477
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1ServiceParticipantConversation.from_hash(h) }
478
+ end
479
+ end
480
+
481
+ # ConversationsV1ServiceUserConversation — a user's view of a service-scoped conversation.
482
+ class ConversationsV1ServiceUserConversation
483
+ ATTRIBUTES = %w[
484
+ account_sid chat_service_sid conversation_sid unread_messages_count
485
+ last_read_message_index participant_sid user_sid friendly_name
486
+ conversation_state timers attributes date_created date_updated created_by
487
+ notification_level unique_name url links
488
+ ].freeze
489
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
490
+ def initialize(attrs = {})
491
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
492
+ end
493
+ def self.from_hash(h); h.nil? ? nil : new(h); end
494
+ end
495
+
496
+ class ConversationsV1ServiceUserConversationList
497
+ include V1Pageable
498
+ attr_reader :conversations
499
+ def initialize(hash = {})
500
+ assign_meta_fields(hash)
501
+ @conversations = (hash['conversations'] || []).map { |h| ConversationsV1ServiceUserConversation.from_hash(h) }
502
+ end
503
+ end
504
+
505
+ # ConversationsV1ServiceRole — `RL...`, scoped to a Service.
506
+ class ConversationsV1ServiceRole
507
+ ATTRIBUTES = %w[
508
+ sid account_sid chat_service_sid friendly_name type permissions
509
+ date_created date_updated url
510
+ ].freeze
511
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
512
+ def initialize(attrs = {})
513
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
514
+ end
515
+ def self.from_hash(h); h.nil? ? nil : new(h); end
516
+ end
517
+
518
+ class ConversationsV1ServiceRoleList
519
+ include V1Pageable
520
+ attr_reader :roles
521
+ def initialize(hash = {})
522
+ assign_meta_fields(hash)
523
+ @roles = (hash['roles'] || []).map { |h| ConversationsV1ServiceRole.from_hash(h) }
524
+ end
525
+ end
526
+
527
+ # ConversationsV1ServiceUser — `US...`, scoped to a Service.
528
+ class ConversationsV1ServiceUser
529
+ ATTRIBUTES = %w[
530
+ sid account_sid chat_service_sid role_sid identity friendly_name attributes
531
+ is_online is_notifiable date_created date_updated url links
532
+ ].freeze
533
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
534
+ def initialize(attrs = {})
535
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
536
+ end
537
+ def self.from_hash(h); h.nil? ? nil : new(h); end
538
+ end
539
+
540
+ class ConversationsV1ServiceUserList
541
+ include V1Pageable
542
+ attr_reader :users
543
+ def initialize(hash = {})
544
+ assign_meta_fields(hash)
545
+ @users = (hash['users'] || []).map { |h| ConversationsV1ServiceUser.from_hash(h) }
546
+ end
547
+ end
548
+
549
+ # ConversationsV1ServiceBinding — `BS...`, push-notification binding (read/delete only).
550
+ class ConversationsV1ServiceBinding
551
+ ATTRIBUTES = %w[
552
+ sid account_sid chat_service_sid credential_sid date_created date_updated
553
+ endpoint identity binding_type message_types url
554
+ ].freeze
555
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
556
+ def initialize(attrs = {})
557
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
558
+ end
559
+ def self.from_hash(h); h.nil? ? nil : new(h); end
560
+ end
561
+
562
+ class ConversationsV1ServiceBindingList
563
+ include V1Pageable
564
+ attr_reader :bindings
565
+ def initialize(hash = {})
566
+ assign_meta_fields(hash)
567
+ @bindings = (hash['bindings'] || []).map { |h| ConversationsV1ServiceBinding.from_hash(h) }
568
+ end
569
+ end
570
+
571
+ # ConversationsV1ServiceConfiguration — per-service singleton (fetch+update).
572
+ class ConversationsV1ServiceConfiguration
573
+ ATTRIBUTES = %w[
574
+ chat_service_sid default_conversation_creator_role_sid
575
+ default_conversation_role_sid default_chat_service_role_sid
576
+ url links reachability_enabled
577
+ ].freeze
578
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
579
+ def initialize(attrs = {})
580
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
581
+ end
582
+ def self.from_hash(h); h.nil? ? nil : new(h); end
583
+ end
584
+
585
+ # ConversationsV1ServiceNotification — per-service push-notification config singleton.
586
+ class ConversationsV1ServiceNotification
587
+ ATTRIBUTES = %w[
588
+ account_sid chat_service_sid new_message added_to_conversation
589
+ removed_from_conversation log_enabled url
590
+ ].freeze
591
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
592
+ def initialize(attrs = {})
593
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
594
+ end
595
+ def self.from_hash(h); h.nil? ? nil : new(h); end
596
+ end
597
+
598
+ # ConversationsV1ServiceWebhookConfiguration — per-service webhook config singleton.
599
+ class ConversationsV1ServiceWebhookConfiguration
600
+ ATTRIBUTES = %w[
601
+ account_sid chat_service_sid pre_webhook_url post_webhook_url
602
+ filters method url
603
+ ].freeze
604
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
605
+ def initialize(attrs = {})
606
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
607
+ end
608
+ def self.from_hash(h); h.nil? ? nil : new(h); end
609
+ end
610
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'common'
4
+
5
+ module VoiceML
6
+ # Twilio-compatible MMS Media item. VoiceML's outbound SMS gateway is
7
+ # text-only today (no MMS), so this model exists primarily for response-
8
+ # shape conformance and to round-trip migrated tooling. `parent_sid` ties
9
+ # the media back to its parent Message (SM... sid).
10
+ class Media
11
+ ATTRIBUTES = %w[
12
+ sid account_sid parent_sid content_type
13
+ date_created date_updated uri
14
+ ].freeze
15
+
16
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
17
+
18
+ def initialize(attrs = {})
19
+ ATTRIBUTES.each do |field|
20
+ value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
21
+ instance_variable_set("@#{field}", value)
22
+ end
23
+ end
24
+
25
+ def self.from_hash(hash)
26
+ return nil if hash.nil?
27
+
28
+ new(hash)
29
+ end
30
+ end
31
+
32
+ # Paginated `GET /Messages/{Sid}/Media` response. Twilio's envelope key is
33
+ # `media_list` (not `media`) — the SDK preserves that on the wire.
34
+ class MediaList
35
+ include Pageable
36
+
37
+ attr_reader :media_list
38
+
39
+ def initialize(hash = {})
40
+ assign_page_fields(hash)
41
+ @media_list = (hash['media_list'] || []).map { |m| Media.from_hash(m) }
42
+ end
43
+
44
+ def self.from_hash(hash)
45
+ new(hash || {})
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'common'
4
+ require_relative 'voice_v1' # V1Pageable lives here; Messaging v1 reuses the same `meta` envelope
5
+
6
+ module VoiceML
7
+ # Twilio Messaging v1 (messaging.twilio.com/v1) resources.
8
+ #
9
+ # A Messaging Service (`MG...`) shares the `/v1/Services` path shape with the
10
+ # Conversations Service (`IS...`); the two are disambiguated on the wire by host
11
+ # (`messaging.voicetel.com` vs `conversations.voicetel.com`). This SDK routes
12
+ # `client.messaging_v1.*` at the messaging host automatically — see VoiceML::Hosts.
13
+
14
+ # MessagingService — `MG...`. The feature-toggle fields are accept-and-echo on
15
+ # VoiceML; the service's operative role is gating scheduled sends.
16
+ class MessagingService
17
+ ATTRIBUTES = %w[
18
+ sid account_sid friendly_name date_created date_updated
19
+ inbound_request_url inbound_method fallback_url fallback_method status_callback
20
+ sticky_sender mms_converter smart_encoding scan_message_content
21
+ fallback_to_long_code area_code_geomatch synchronous_validation validity_period
22
+ url usecase use_inbound_webhook_on_number
23
+ ].freeze
24
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
25
+ def initialize(attrs = {})
26
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs[f] || attrs[f.to_sym]) }
27
+ end
28
+ def self.from_hash(h); h.nil? ? nil : new(h); end
29
+ end
30
+
31
+ # List envelope for `GET /v1/Services` on the messaging host.
32
+ class MessagingServiceList
33
+ include V1Pageable
34
+ attr_reader :services
35
+ def initialize(hash = {})
36
+ assign_meta_fields(hash)
37
+ @services = (hash['services'] || []).map { |h| MessagingService.from_hash(h) }
38
+ end
39
+ end
40
+ end