twilio-ruby 5.19.0 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +13 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/api.rb +16 -13
- data/lib/twilio-ruby/rest/api/v2010/account/address.rb +85 -88
- data/lib/twilio-ruby/rest/api/v2010/account/address/dependent_phone_number.rb +4 -4
- data/lib/twilio-ruby/rest/api/v2010/account/application.rb +135 -146
- data/lib/twilio-ruby/rest/api/v2010/account/authorized_connect_app.rb +21 -17
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +14 -8
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +150 -166
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +174 -79
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +147 -160
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +174 -79
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +174 -79
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +147 -160
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +174 -79
- data/lib/twilio-ruby/rest/api/v2010/account/connect_app.rb +51 -51
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +246 -251
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +31 -26
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb +34 -26
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +109 -112
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +108 -112
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +108 -112
- data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +21 -11
- data/lib/twilio-ruby/rest/api/v2010/account/new_key.rb +7 -6
- data/lib/twilio-ruby/rest/api/v2010/account/new_signing_key.rb +7 -6
- data/lib/twilio-ruby/rest/api/v2010/account/notification.rb +32 -25
- data/lib/twilio-ruby/rest/api/v2010/account/outgoing_caller_id.rb +36 -36
- data/lib/twilio-ruby/rest/api/v2010/account/sip.rb +2 -1
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +70 -66
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types.rb +10 -10
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_calls_mapping.rb +14 -14
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_calls_mapping/auth_calls_credential_list_mapping.rb +26 -23
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_calls_mapping/auth_calls_ip_access_control_list_mapping.rb +26 -23
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_registrations_mapping.rb +12 -12
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/auth_types/auth_registrations_mapping/auth_registrations_credential_list_mapping.rb +26 -23
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/credential_list_mapping.rb +4 -4
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain/ip_access_control_list_mapping.rb +4 -4
- data/lib/twilio-ruby/rest/api/v2010/account/token.rb +11 -9
- data/lib/twilio-ruby/rest/api/v2010/account/usage.rb +2 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +56 -47
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/all_time.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/daily.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/last_month.rb +59 -47
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/this_month.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/today.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yearly.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record/yesterday.rb +59 -44
- data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +76 -74
- data/lib/twilio-ruby/rest/authy.rb +8 -8
- data/lib/twilio-ruby/rest/authy/v1.rb +15 -15
- data/lib/twilio-ruby/rest/client.rb +16 -13
- data/lib/twilio-ruby/rest/messaging.rb +15 -0
- data/lib/twilio-ruby/rest/messaging/v1.rb +23 -0
- data/lib/twilio-ruby/rest/messaging/v1/session.rb +482 -0
- data/lib/twilio-ruby/rest/messaging/v1/session/message.rb +434 -0
- data/lib/twilio-ruby/rest/messaging/v1/session/participant.rb +458 -0
- data/lib/twilio-ruby/rest/messaging/v1/webhook.rb +285 -0
- data/lib/twilio-ruby/rest/preview.rb +8 -8
- data/lib/twilio-ruby/rest/preview/marketplace.rb +13 -13
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +3 -2
- data/lib/twilio-ruby/rest/video.rb +9 -9
- data/lib/twilio-ruby/rest/video/v1.rb +16 -16
- data/lib/twilio-ruby/rest/video/v1/composition.rb +7 -6
- data/lib/twilio-ruby/rest/video/v1/composition_hook.rb +37 -21
- data/lib/twilio-ruby/rest/video/v1/recording.rb +12 -3
- data/lib/twilio-ruby/security/request_validator.rb +2 -2
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/messaging/v1/session/message_spec.rb +238 -0
- data/spec/integration/messaging/v1/session/participant_spec.rb +256 -0
- data/spec/integration/messaging/v1/session_spec.rb +223 -0
- data/spec/integration/messaging/v1/webhook_spec.rb +92 -0
- data/spec/integration/video/v1/composition_hook_spec.rb +1 -1
- data/spec/security/request_validator_spec.rb +5 -7
- metadata +14 -2
@@ -28,6 +28,14 @@ module Twilio
|
|
28
28
|
@v1 ||= V1.new self
|
29
29
|
end
|
30
30
|
|
31
|
+
##
|
32
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
33
|
+
# @return [Twilio::REST::Authy::V1::ServiceInstance] if sid was passed.
|
34
|
+
# @return [Twilio::REST::Authy::V1::ServiceList]
|
35
|
+
def services(sid=:unset)
|
36
|
+
self.v1.services(sid)
|
37
|
+
end
|
38
|
+
|
31
39
|
##
|
32
40
|
# @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
|
33
41
|
# `form-sms` or `form-totp`.
|
@@ -37,14 +45,6 @@ module Twilio
|
|
37
45
|
self.v1.forms(form_type)
|
38
46
|
end
|
39
47
|
|
40
|
-
##
|
41
|
-
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
42
|
-
# @return [Twilio::REST::Authy::V1::ServiceInstance] if sid was passed.
|
43
|
-
# @return [Twilio::REST::Authy::V1::ServiceList]
|
44
|
-
def services(sid=:unset)
|
45
|
-
self.v1.services(sid)
|
46
|
-
end
|
47
|
-
|
48
48
|
##
|
49
49
|
# Provide a user friendly representation
|
50
50
|
def to_s
|
@@ -15,8 +15,22 @@ module Twilio
|
|
15
15
|
def initialize(domain)
|
16
16
|
super
|
17
17
|
@version = 'v1'
|
18
|
-
@forms = nil
|
19
18
|
@services = nil
|
19
|
+
@forms = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
24
|
+
# @return [Twilio::REST::Authy::V1::ServiceContext] if sid was passed.
|
25
|
+
# @return [Twilio::REST::Authy::V1::ServiceList]
|
26
|
+
def services(sid=:unset)
|
27
|
+
if sid.nil?
|
28
|
+
raise ArgumentError, 'sid cannot be nil'
|
29
|
+
elsif sid == :unset
|
30
|
+
@services ||= ServiceList.new self
|
31
|
+
else
|
32
|
+
ServiceContext.new(self, sid)
|
33
|
+
end
|
20
34
|
end
|
21
35
|
|
22
36
|
##
|
@@ -34,20 +48,6 @@ module Twilio
|
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
37
|
-
##
|
38
|
-
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
39
|
-
# @return [Twilio::REST::Authy::V1::ServiceContext] if sid was passed.
|
40
|
-
# @return [Twilio::REST::Authy::V1::ServiceList]
|
41
|
-
def services(sid=:unset)
|
42
|
-
if sid.nil?
|
43
|
-
raise ArgumentError, 'sid cannot be nil'
|
44
|
-
elsif sid == :unset
|
45
|
-
@services ||= ServiceList.new self
|
46
|
-
else
|
47
|
-
ServiceContext.new(self, sid)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
51
|
##
|
52
52
|
# Provide a user friendly representation
|
53
53
|
def to_s
|
@@ -237,7 +237,8 @@ module Twilio
|
|
237
237
|
end
|
238
238
|
|
239
239
|
##
|
240
|
-
# @param [String] sid
|
240
|
+
# @param [String] sid The unique string that that we created to identify the
|
241
|
+
# Address resource.
|
241
242
|
# @return [Twilio::REST::Api::V2010::AccountContext::AddressInstance] if sid was passed.
|
242
243
|
# @return [Twilio::REST::Api::V2010::AccountContext::AddressList]
|
243
244
|
def addresses(sid=:unset)
|
@@ -245,8 +246,8 @@ module Twilio
|
|
245
246
|
end
|
246
247
|
|
247
248
|
##
|
248
|
-
# @param [String] sid
|
249
|
-
# resource.
|
249
|
+
# @param [String] sid The unique string that that we created to identify the
|
250
|
+
# Application resource.
|
250
251
|
# @return [Twilio::REST::Api::V2010::AccountContext::ApplicationInstance] if sid was passed.
|
251
252
|
# @return [Twilio::REST::Api::V2010::AccountContext::ApplicationList]
|
252
253
|
def applications(sid=:unset)
|
@@ -254,8 +255,7 @@ module Twilio
|
|
254
255
|
end
|
255
256
|
|
256
257
|
##
|
257
|
-
# @param [String] connect_app_sid The
|
258
|
-
# authorized.
|
258
|
+
# @param [String] connect_app_sid The SID that we assigned to the Connect App.
|
259
259
|
# @return [Twilio::REST::Api::V2010::AccountContext::AuthorizedConnectAppInstance] if connect_app_sid was passed.
|
260
260
|
# @return [Twilio::REST::Api::V2010::AccountContext::AuthorizedConnectAppList]
|
261
261
|
def authorized_connect_apps(connect_app_sid=:unset)
|
@@ -263,7 +263,9 @@ module Twilio
|
|
263
263
|
end
|
264
264
|
|
265
265
|
##
|
266
|
-
# @param [String] country_code The
|
266
|
+
# @param [String] country_code The
|
267
|
+
# [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of
|
268
|
+
# the country.
|
267
269
|
# @return [Twilio::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryInstance] if country_code was passed.
|
268
270
|
# @return [Twilio::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryList]
|
269
271
|
def available_phone_numbers(country_code=:unset)
|
@@ -295,7 +297,8 @@ module Twilio
|
|
295
297
|
end
|
296
298
|
|
297
299
|
##
|
298
|
-
# @param [String] sid The unique
|
300
|
+
# @param [String] sid The unique string that that we created to identify the
|
301
|
+
# ConnectApp resource.
|
299
302
|
# @return [Twilio::REST::Api::V2010::AccountContext::ConnectAppInstance] if sid was passed.
|
300
303
|
# @return [Twilio::REST::Api::V2010::AccountContext::ConnectAppList]
|
301
304
|
def connect_apps(sid=:unset)
|
@@ -303,8 +306,8 @@ module Twilio
|
|
303
306
|
end
|
304
307
|
|
305
308
|
##
|
306
|
-
# @param [String] sid
|
307
|
-
# resource.
|
309
|
+
# @param [String] sid The unique string that that we created to identify this
|
310
|
+
# IncomingPhoneNumber resource.
|
308
311
|
# @return [Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberInstance] if sid was passed.
|
309
312
|
# @return [Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberList]
|
310
313
|
def incoming_phone_numbers(sid=:unset)
|
@@ -342,8 +345,8 @@ module Twilio
|
|
342
345
|
end
|
343
346
|
|
344
347
|
##
|
345
|
-
# @param [String] sid
|
346
|
-
# resource.
|
348
|
+
# @param [String] sid The unique string that that we created to identify the
|
349
|
+
# Notification resource.
|
347
350
|
# @return [Twilio::REST::Api::V2010::AccountContext::NotificationInstance] if sid was passed.
|
348
351
|
# @return [Twilio::REST::Api::V2010::AccountContext::NotificationList]
|
349
352
|
def notifications(sid=:unset)
|
@@ -351,8 +354,8 @@ module Twilio
|
|
351
354
|
end
|
352
355
|
|
353
356
|
##
|
354
|
-
# @param [String] sid
|
355
|
-
# resource.
|
357
|
+
# @param [String] sid The unique string that that we created to identify the
|
358
|
+
# OutgoingCallerId resource.
|
356
359
|
# @return [Twilio::REST::Api::V2010::AccountContext::OutgoingCallerIdInstance] if sid was passed.
|
357
360
|
# @return [Twilio::REST::Api::V2010::AccountContext::OutgoingCallerIdList]
|
358
361
|
def outgoing_caller_ids(sid=:unset)
|
@@ -28,6 +28,15 @@ module Twilio
|
|
28
28
|
@v1 ||= V1.new self
|
29
29
|
end
|
30
30
|
|
31
|
+
##
|
32
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
33
|
+
# resource.
|
34
|
+
# @return [Twilio::REST::Messaging::V1::SessionInstance] if sid was passed.
|
35
|
+
# @return [Twilio::REST::Messaging::V1::SessionList]
|
36
|
+
def sessions(sid=:unset)
|
37
|
+
self.v1.sessions(sid)
|
38
|
+
end
|
39
|
+
|
31
40
|
##
|
32
41
|
# @param [String] sid Unique 34 character ID of the Service.
|
33
42
|
# @return [Twilio::REST::Messaging::V1::ServiceInstance] if sid was passed.
|
@@ -36,6 +45,12 @@ module Twilio
|
|
36
45
|
self.v1.services(sid)
|
37
46
|
end
|
38
47
|
|
48
|
+
##
|
49
|
+
# @return [Twilio::REST::Messaging::V1::WebhookInstance]
|
50
|
+
def webhooks
|
51
|
+
self.v1.webhooks()
|
52
|
+
end
|
53
|
+
|
39
54
|
##
|
40
55
|
# Provide a user friendly representation
|
41
56
|
def to_s
|
@@ -15,7 +15,24 @@ module Twilio
|
|
15
15
|
def initialize(domain)
|
16
16
|
super
|
17
17
|
@version = 'v1'
|
18
|
+
@sessions = nil
|
18
19
|
@services = nil
|
20
|
+
@webhooks = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
25
|
+
# resource.
|
26
|
+
# @return [Twilio::REST::Messaging::V1::SessionContext] if sid was passed.
|
27
|
+
# @return [Twilio::REST::Messaging::V1::SessionList]
|
28
|
+
def sessions(sid=:unset)
|
29
|
+
if sid.nil?
|
30
|
+
raise ArgumentError, 'sid cannot be nil'
|
31
|
+
elsif sid == :unset
|
32
|
+
@sessions ||= SessionList.new self
|
33
|
+
else
|
34
|
+
SessionContext.new(self, sid)
|
35
|
+
end
|
19
36
|
end
|
20
37
|
|
21
38
|
##
|
@@ -32,6 +49,12 @@ module Twilio
|
|
32
49
|
end
|
33
50
|
end
|
34
51
|
|
52
|
+
##
|
53
|
+
# @return [Twilio::REST::Messaging::V1::WebhookContext]
|
54
|
+
def webhooks
|
55
|
+
@webhooks ||= WebhookContext.new self
|
56
|
+
end
|
57
|
+
|
35
58
|
##
|
36
59
|
# Provide a user friendly representation
|
37
60
|
def to_s
|
@@ -0,0 +1,482 @@
|
|
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 preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
15
|
+
class SessionList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the SessionList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [SessionList] SessionList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Sessions"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of SessionInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] messaging_service_sid The unique id of the [SMS
|
32
|
+
# Service](https://www.twilio.com/docs/sms/services/api) this session belongs to.
|
33
|
+
# @param [String] friendly_name The human-readable name of this session. Optional.
|
34
|
+
# @param [String] attributes An optional string metadata field you can use to
|
35
|
+
# store any data you wish. The string value must contain structurally valid JSON
|
36
|
+
# if specified. **Note** that if the attributes are not set "{}" will be
|
37
|
+
# returned.
|
38
|
+
# @param [Time] date_created The date that this resource was created.
|
39
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
40
|
+
# @param [String] created_by Identity of the session's creator. If the Session was
|
41
|
+
# created through the API, the value will be `system`
|
42
|
+
# @param [String] twilio_address Twilio address the participant is contacting to.
|
43
|
+
# Together with User address defines the participant.
|
44
|
+
# @param [String] user_address Address the participant is contacting from.
|
45
|
+
# Together with Twilio address defines the participant.
|
46
|
+
# @return [SessionInstance] Newly created SessionInstance
|
47
|
+
def create(messaging_service_sid: nil, friendly_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, twilio_address: :unset, user_address: :unset)
|
48
|
+
data = Twilio::Values.of({
|
49
|
+
'MessagingServiceSid' => messaging_service_sid,
|
50
|
+
'FriendlyName' => friendly_name,
|
51
|
+
'Attributes' => attributes,
|
52
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
53
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
54
|
+
'CreatedBy' => created_by,
|
55
|
+
'TwilioAddress' => twilio_address,
|
56
|
+
'UserAddress' => user_address,
|
57
|
+
})
|
58
|
+
|
59
|
+
payload = @version.create(
|
60
|
+
'POST',
|
61
|
+
@uri,
|
62
|
+
data: data
|
63
|
+
)
|
64
|
+
|
65
|
+
SessionInstance.new(@version, payload, )
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Lists SessionInstance records from the API as a list.
|
70
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
71
|
+
# memory before returning.
|
72
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
73
|
+
# guarantees to never return more than limit. Default is no limit
|
74
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
75
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
76
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
77
|
+
# efficient page size, i.e. min(limit, 1000)
|
78
|
+
# @return [Array] Array of up to limit results
|
79
|
+
def list(limit: nil, page_size: nil)
|
80
|
+
self.stream(limit: limit, page_size: page_size).entries
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Streams SessionInstance records from the API as an Enumerable.
|
85
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
86
|
+
# is reached.
|
87
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
88
|
+
# guarantees to never return more than limit. Default is no limit.
|
89
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
90
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
91
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
92
|
+
# efficient page size, i.e. min(limit, 1000)
|
93
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
94
|
+
def stream(limit: nil, page_size: nil)
|
95
|
+
limits = @version.read_limits(limit, page_size)
|
96
|
+
|
97
|
+
page = self.page(page_size: limits[:page_size], )
|
98
|
+
|
99
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# When passed a block, yields SessionInstance records from the API.
|
104
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
105
|
+
# is reached.
|
106
|
+
def each
|
107
|
+
limits = @version.read_limits
|
108
|
+
|
109
|
+
page = self.page(page_size: limits[:page_size], )
|
110
|
+
|
111
|
+
@version.stream(page,
|
112
|
+
limit: limits[:limit],
|
113
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Retrieve a single page of SessionInstance records from the API.
|
118
|
+
# Request is executed immediately.
|
119
|
+
# @param [String] page_token PageToken provided by the API
|
120
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
121
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
122
|
+
# @return [Page] Page of SessionInstance
|
123
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
124
|
+
params = Twilio::Values.of({
|
125
|
+
'PageToken' => page_token,
|
126
|
+
'Page' => page_number,
|
127
|
+
'PageSize' => page_size,
|
128
|
+
})
|
129
|
+
response = @version.page(
|
130
|
+
'GET',
|
131
|
+
@uri,
|
132
|
+
params
|
133
|
+
)
|
134
|
+
SessionPage.new(@version, response, @solution)
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Retrieve a single page of SessionInstance records from the API.
|
139
|
+
# Request is executed immediately.
|
140
|
+
# @param [String] target_url API-generated URL for the requested results page
|
141
|
+
# @return [Page] Page of SessionInstance
|
142
|
+
def get_page(target_url)
|
143
|
+
response = @version.domain.request(
|
144
|
+
'GET',
|
145
|
+
target_url
|
146
|
+
)
|
147
|
+
SessionPage.new(@version, response, @solution)
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Provide a user friendly representation
|
152
|
+
def to_s
|
153
|
+
'#<Twilio.Messaging.V1.SessionList>'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
159
|
+
class SessionPage < Page
|
160
|
+
##
|
161
|
+
# Initialize the SessionPage
|
162
|
+
# @param [Version] version Version that contains the resource
|
163
|
+
# @param [Response] response Response from the API
|
164
|
+
# @param [Hash] solution Path solution for the resource
|
165
|
+
# @return [SessionPage] SessionPage
|
166
|
+
def initialize(version, response, solution)
|
167
|
+
super(version, response)
|
168
|
+
|
169
|
+
# Path Solution
|
170
|
+
@solution = solution
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Build an instance of SessionInstance
|
175
|
+
# @param [Hash] payload Payload response from the API
|
176
|
+
# @return [SessionInstance] SessionInstance
|
177
|
+
def get_instance(payload)
|
178
|
+
SessionInstance.new(@version, payload, )
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# Provide a user friendly representation
|
183
|
+
def to_s
|
184
|
+
'<Twilio.Messaging.V1.SessionPage>'
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
190
|
+
class SessionContext < InstanceContext
|
191
|
+
##
|
192
|
+
# Initialize the SessionContext
|
193
|
+
# @param [Version] version Version that contains the resource
|
194
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
195
|
+
# resource.
|
196
|
+
# @return [SessionContext] SessionContext
|
197
|
+
def initialize(version, sid)
|
198
|
+
super(version)
|
199
|
+
|
200
|
+
# Path Solution
|
201
|
+
@solution = {sid: sid, }
|
202
|
+
@uri = "/Sessions/#{@solution[:sid]}"
|
203
|
+
|
204
|
+
# Dependents
|
205
|
+
@participants = nil
|
206
|
+
@messages = nil
|
207
|
+
end
|
208
|
+
|
209
|
+
##
|
210
|
+
# Fetch a SessionInstance
|
211
|
+
# @return [SessionInstance] Fetched SessionInstance
|
212
|
+
def fetch
|
213
|
+
params = Twilio::Values.of({})
|
214
|
+
|
215
|
+
payload = @version.fetch(
|
216
|
+
'GET',
|
217
|
+
@uri,
|
218
|
+
params,
|
219
|
+
)
|
220
|
+
|
221
|
+
SessionInstance.new(@version, payload, sid: @solution[:sid], )
|
222
|
+
end
|
223
|
+
|
224
|
+
##
|
225
|
+
# Deletes the SessionInstance
|
226
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
227
|
+
def delete
|
228
|
+
@version.delete('delete', @uri)
|
229
|
+
end
|
230
|
+
|
231
|
+
##
|
232
|
+
# Update the SessionInstance
|
233
|
+
# @param [String] friendly_name The human-readable name of this session. Optional.
|
234
|
+
# @param [String] attributes An optional string metadata field you can use to
|
235
|
+
# store any data you wish. The string value must contain structurally valid JSON
|
236
|
+
# if specified. **Note** that if the attributes are not set "{}" will be
|
237
|
+
# returned.
|
238
|
+
# @param [Time] date_created The date that this resource was created.
|
239
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
240
|
+
# @param [String] created_by Identity of the session's creator. If the Session was
|
241
|
+
# created through the API, the value will be `system`
|
242
|
+
# @return [SessionInstance] Updated SessionInstance
|
243
|
+
def update(friendly_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
|
244
|
+
data = Twilio::Values.of({
|
245
|
+
'FriendlyName' => friendly_name,
|
246
|
+
'Attributes' => attributes,
|
247
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
248
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
249
|
+
'CreatedBy' => created_by,
|
250
|
+
})
|
251
|
+
|
252
|
+
payload = @version.update(
|
253
|
+
'POST',
|
254
|
+
@uri,
|
255
|
+
data: data,
|
256
|
+
)
|
257
|
+
|
258
|
+
SessionInstance.new(@version, payload, sid: @solution[:sid], )
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Access the participants
|
263
|
+
# @return [ParticipantList]
|
264
|
+
# @return [ParticipantContext] if sid was passed.
|
265
|
+
def participants(sid=:unset)
|
266
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
267
|
+
|
268
|
+
if sid != :unset
|
269
|
+
return ParticipantContext.new(@version, @solution[:sid], sid, )
|
270
|
+
end
|
271
|
+
|
272
|
+
unless @participants
|
273
|
+
@participants = ParticipantList.new(@version, session_sid: @solution[:sid], )
|
274
|
+
end
|
275
|
+
|
276
|
+
@participants
|
277
|
+
end
|
278
|
+
|
279
|
+
##
|
280
|
+
# Access the messages
|
281
|
+
# @return [MessageList]
|
282
|
+
# @return [MessageContext] if sid was passed.
|
283
|
+
def messages(sid=:unset)
|
284
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
285
|
+
|
286
|
+
if sid != :unset
|
287
|
+
return MessageContext.new(@version, @solution[:sid], sid, )
|
288
|
+
end
|
289
|
+
|
290
|
+
unless @messages
|
291
|
+
@messages = MessageList.new(@version, session_sid: @solution[:sid], )
|
292
|
+
end
|
293
|
+
|
294
|
+
@messages
|
295
|
+
end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Provide a user friendly representation
|
299
|
+
def to_s
|
300
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
301
|
+
"#<Twilio.Messaging.V1.SessionContext #{context}>"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
307
|
+
class SessionInstance < InstanceResource
|
308
|
+
##
|
309
|
+
# Initialize the SessionInstance
|
310
|
+
# @param [Version] version Version that contains the resource
|
311
|
+
# @param [Hash] payload payload that contains response from Twilio
|
312
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
313
|
+
# resource.
|
314
|
+
# @return [SessionInstance] SessionInstance
|
315
|
+
def initialize(version, payload, sid: nil)
|
316
|
+
super(version)
|
317
|
+
|
318
|
+
# Marshaled Properties
|
319
|
+
@properties = {
|
320
|
+
'sid' => payload['sid'],
|
321
|
+
'account_sid' => payload['account_sid'],
|
322
|
+
'service_sid' => payload['service_sid'],
|
323
|
+
'messaging_service_sid' => payload['messaging_service_sid'],
|
324
|
+
'friendly_name' => payload['friendly_name'],
|
325
|
+
'attributes' => payload['attributes'],
|
326
|
+
'created_by' => payload['created_by'],
|
327
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
328
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
329
|
+
'url' => payload['url'],
|
330
|
+
'links' => payload['links'],
|
331
|
+
}
|
332
|
+
|
333
|
+
# Context
|
334
|
+
@instance_context = nil
|
335
|
+
@params = {'sid' => sid || @properties['sid'], }
|
336
|
+
end
|
337
|
+
|
338
|
+
##
|
339
|
+
# Generate an instance context for the instance, the context is capable of
|
340
|
+
# performing various actions. All instance actions are proxied to the context
|
341
|
+
# @return [SessionContext] SessionContext for this SessionInstance
|
342
|
+
def context
|
343
|
+
unless @instance_context
|
344
|
+
@instance_context = SessionContext.new(@version, @params['sid'], )
|
345
|
+
end
|
346
|
+
@instance_context
|
347
|
+
end
|
348
|
+
|
349
|
+
##
|
350
|
+
# @return [String] A 34 character string that uniquely identifies this resource.
|
351
|
+
def sid
|
352
|
+
@properties['sid']
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# @return [String] The unique id of the Account responsible for this session.
|
357
|
+
def account_sid
|
358
|
+
@properties['account_sid']
|
359
|
+
end
|
360
|
+
|
361
|
+
##
|
362
|
+
# @return [String] The unique id of the Chat Service this session belongs to.
|
363
|
+
def service_sid
|
364
|
+
@properties['service_sid']
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# @return [String] The unique id of the SMS Service this session belongs to.
|
369
|
+
def messaging_service_sid
|
370
|
+
@properties['messaging_service_sid']
|
371
|
+
end
|
372
|
+
|
373
|
+
##
|
374
|
+
# @return [String] The human-readable name of this session.
|
375
|
+
def friendly_name
|
376
|
+
@properties['friendly_name']
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# @return [String] An optional string metadata field you can use to store any data you wish.
|
381
|
+
def attributes
|
382
|
+
@properties['attributes']
|
383
|
+
end
|
384
|
+
|
385
|
+
##
|
386
|
+
# @return [String] Identity of the session's creator.
|
387
|
+
def created_by
|
388
|
+
@properties['created_by']
|
389
|
+
end
|
390
|
+
|
391
|
+
##
|
392
|
+
# @return [Time] The date that this resource was created.
|
393
|
+
def date_created
|
394
|
+
@properties['date_created']
|
395
|
+
end
|
396
|
+
|
397
|
+
##
|
398
|
+
# @return [Time] The date that this resource was last updated.
|
399
|
+
def date_updated
|
400
|
+
@properties['date_updated']
|
401
|
+
end
|
402
|
+
|
403
|
+
##
|
404
|
+
# @return [String] An absolute URL for this session.
|
405
|
+
def url
|
406
|
+
@properties['url']
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# @return [String] Absolute URLs to access the Participants and Messages for this Session.
|
411
|
+
def links
|
412
|
+
@properties['links']
|
413
|
+
end
|
414
|
+
|
415
|
+
##
|
416
|
+
# Fetch a SessionInstance
|
417
|
+
# @return [SessionInstance] Fetched SessionInstance
|
418
|
+
def fetch
|
419
|
+
context.fetch
|
420
|
+
end
|
421
|
+
|
422
|
+
##
|
423
|
+
# Deletes the SessionInstance
|
424
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
425
|
+
def delete
|
426
|
+
context.delete
|
427
|
+
end
|
428
|
+
|
429
|
+
##
|
430
|
+
# Update the SessionInstance
|
431
|
+
# @param [String] friendly_name The human-readable name of this session. Optional.
|
432
|
+
# @param [String] attributes An optional string metadata field you can use to
|
433
|
+
# store any data you wish. The string value must contain structurally valid JSON
|
434
|
+
# if specified. **Note** that if the attributes are not set "{}" will be
|
435
|
+
# returned.
|
436
|
+
# @param [Time] date_created The date that this resource was created.
|
437
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
438
|
+
# @param [String] created_by Identity of the session's creator. If the Session was
|
439
|
+
# created through the API, the value will be `system`
|
440
|
+
# @return [SessionInstance] Updated SessionInstance
|
441
|
+
def update(friendly_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
|
442
|
+
context.update(
|
443
|
+
friendly_name: friendly_name,
|
444
|
+
attributes: attributes,
|
445
|
+
date_created: date_created,
|
446
|
+
date_updated: date_updated,
|
447
|
+
created_by: created_by,
|
448
|
+
)
|
449
|
+
end
|
450
|
+
|
451
|
+
##
|
452
|
+
# Access the participants
|
453
|
+
# @return [participants] participants
|
454
|
+
def participants
|
455
|
+
context.participants
|
456
|
+
end
|
457
|
+
|
458
|
+
##
|
459
|
+
# Access the messages
|
460
|
+
# @return [messages] messages
|
461
|
+
def messages
|
462
|
+
context.messages
|
463
|
+
end
|
464
|
+
|
465
|
+
##
|
466
|
+
# Provide a user friendly representation
|
467
|
+
def to_s
|
468
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
469
|
+
"<Twilio.Messaging.V1.SessionInstance #{values}>"
|
470
|
+
end
|
471
|
+
|
472
|
+
##
|
473
|
+
# Provide a detailed, user friendly representation
|
474
|
+
def inspect
|
475
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
476
|
+
"<Twilio.Messaging.V1.SessionInstance #{values}>"
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|
482
|
+
end
|