twilio-ruby 5.40.1 → 5.40.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.
- checksums.yaml +4 -4
- data/CHANGES.md +27 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/framework/version.rb +2 -7
- data/lib/twilio-ruby/rest/conversations.rb +52 -0
- data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
- data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
- data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
- data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
- data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
- data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
- data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
- data/lib/twilio-ruby/rest/events.rb +8 -0
- data/lib/twilio-ruby/rest/events/v1.rb +15 -0
- data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
- data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
- data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
- data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
- data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
- data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
- data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
- data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/framework/version_spec.rb +42 -0
- data/spec/holodeck/holodeck.rb +3 -3
- data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
- data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
- data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
- data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
- data/spec/integration/conversations/v1/credential_spec.rb +219 -0
- data/spec/integration/conversations/v1/notification_spec.rb +107 -0
- data/spec/integration/conversations/v1/role_spec.rb +249 -0
- data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
- data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
- data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
- data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
- data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
- data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
- data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
- data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
- data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
- data/spec/integration/conversations/v1/service_spec.rb +174 -0
- data/spec/integration/conversations/v1/user_spec.rb +220 -0
- data/spec/integration/events/v1/event_type_spec.rb +133 -0
- data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
- data/spec/integration/supersim/v1/sim_spec.rb +23 -0
- metadata +50 -2
@@ -29,6 +29,9 @@ module Twilio
|
|
29
29
|
# Create the ConversationInstance
|
30
30
|
# @param [String] friendly_name The human-readable name of this conversation,
|
31
31
|
# limited to 256 characters. Optional.
|
32
|
+
# @param [String] unique_name An application-defined string that uniquely
|
33
|
+
# identifies the resource. It can be used to address the resource in place of the
|
34
|
+
# resource's `sid` in the URL.
|
32
35
|
# @param [Time] date_created The date that this resource was created.
|
33
36
|
# @param [Time] date_updated The date that this resource was last updated.
|
34
37
|
# @param [String] messaging_service_sid The unique id of the [SMS
|
@@ -47,9 +50,10 @@ module Twilio
|
|
47
50
|
# @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
|
48
51
|
# X-Twilio-Webhook-Enabled HTTP request header
|
49
52
|
# @return [ConversationInstance] Created ConversationInstance
|
50
|
-
def create(friendly_name: :unset, date_created: :unset, date_updated: :unset, messaging_service_sid: :unset, attributes: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
|
53
|
+
def create(friendly_name: :unset, unique_name: :unset, date_created: :unset, date_updated: :unset, messaging_service_sid: :unset, attributes: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
|
51
54
|
data = Twilio::Values.of({
|
52
55
|
'FriendlyName' => friendly_name,
|
56
|
+
'UniqueName' => unique_name,
|
53
57
|
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
54
58
|
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
55
59
|
'MessagingServiceSid' => messaging_service_sid,
|
@@ -190,7 +194,7 @@ module Twilio
|
|
190
194
|
# Initialize the ConversationContext
|
191
195
|
# @param [Version] version Version that contains the resource
|
192
196
|
# @param [String] sid A 34 character string that uniquely identifies this
|
193
|
-
# resource.
|
197
|
+
# resource. Can also be the `unique_name` of the Conversation.
|
194
198
|
# @return [ConversationContext] ConversationContext
|
195
199
|
def initialize(version, sid)
|
196
200
|
super(version)
|
@@ -342,7 +346,7 @@ module Twilio
|
|
342
346
|
# @param [Version] version Version that contains the resource
|
343
347
|
# @param [Hash] payload payload that contains response from Twilio
|
344
348
|
# @param [String] sid A 34 character string that uniquely identifies this
|
345
|
-
# resource.
|
349
|
+
# resource. Can also be the `unique_name` of the Conversation.
|
346
350
|
# @return [ConversationInstance] ConversationInstance
|
347
351
|
def initialize(version, payload, sid: nil)
|
348
352
|
super(version)
|
@@ -354,6 +358,7 @@ module Twilio
|
|
354
358
|
'messaging_service_sid' => payload['messaging_service_sid'],
|
355
359
|
'sid' => payload['sid'],
|
356
360
|
'friendly_name' => payload['friendly_name'],
|
361
|
+
'unique_name' => payload['unique_name'],
|
357
362
|
'attributes' => payload['attributes'],
|
358
363
|
'state' => payload['state'],
|
359
364
|
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
@@ -409,6 +414,12 @@ module Twilio
|
|
409
414
|
@properties['friendly_name']
|
410
415
|
end
|
411
416
|
|
417
|
+
##
|
418
|
+
# @return [String] An application-defined string that uniquely identifies the resource
|
419
|
+
def unique_name
|
420
|
+
@properties['unique_name']
|
421
|
+
end
|
422
|
+
|
412
423
|
##
|
413
424
|
# @return [String] An optional string metadata field you can use to store any data you wish.
|
414
425
|
def attributes
|
@@ -446,7 +457,7 @@ module Twilio
|
|
446
457
|
end
|
447
458
|
|
448
459
|
##
|
449
|
-
# @return [String] Absolute URLs to access the Participants of this Conversation.
|
460
|
+
# @return [String] Absolute URLs to access the Participants, Messages and Webhooks of this Conversation.
|
450
461
|
def links
|
451
462
|
@properties['links']
|
452
463
|
end
|
@@ -18,7 +18,8 @@ module Twilio
|
|
18
18
|
##
|
19
19
|
# Initialize the DeliveryReceiptList
|
20
20
|
# @param [Version] version Version that contains the resource
|
21
|
-
# @param [String] conversation_sid The
|
21
|
+
# @param [String] conversation_sid The unique id of the
|
22
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
22
23
|
# @param [String] message_sid The sid of the message within a
|
23
24
|
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
|
24
25
|
# @return [DeliveryReceiptList] DeliveryReceiptList
|
@@ -162,7 +163,7 @@ module Twilio
|
|
162
163
|
# @param [String] conversation_sid The unique id of the
|
163
164
|
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
164
165
|
# @param [String] message_sid The sid of the message within a
|
165
|
-
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
|
166
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to.
|
166
167
|
# @param [String] sid A 34 character string that uniquely identifies this
|
167
168
|
# resource.
|
168
169
|
# @return [DeliveryReceiptContext] DeliveryReceiptContext
|
@@ -211,7 +212,8 @@ module Twilio
|
|
211
212
|
# Initialize the DeliveryReceiptInstance
|
212
213
|
# @param [Version] version Version that contains the resource
|
213
214
|
# @param [Hash] payload payload that contains response from Twilio
|
214
|
-
# @param [String] conversation_sid The
|
215
|
+
# @param [String] conversation_sid The unique id of the
|
216
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this message.
|
215
217
|
# @param [String] message_sid The sid of the message within a
|
216
218
|
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) the delivery receipt belongs to
|
217
219
|
# @param [String] sid A 34 character string that uniquely identifies this
|
@@ -222,9 +224,10 @@ module Twilio
|
|
222
224
|
|
223
225
|
# Marshaled Properties
|
224
226
|
@properties = {
|
227
|
+
'account_sid' => payload['account_sid'],
|
228
|
+
'conversation_sid' => payload['conversation_sid'],
|
225
229
|
'sid' => payload['sid'],
|
226
230
|
'message_sid' => payload['message_sid'],
|
227
|
-
'conversation_sid' => payload['conversation_sid'],
|
228
231
|
'channel_message_sid' => payload['channel_message_sid'],
|
229
232
|
'participant_sid' => payload['participant_sid'],
|
230
233
|
'status' => payload['status'],
|
@@ -259,6 +262,18 @@ module Twilio
|
|
259
262
|
@instance_context
|
260
263
|
end
|
261
264
|
|
265
|
+
##
|
266
|
+
# @return [String] The unique id of the Account responsible for this participant.
|
267
|
+
def account_sid
|
268
|
+
@properties['account_sid']
|
269
|
+
end
|
270
|
+
|
271
|
+
##
|
272
|
+
# @return [String] The unique id of the Conversation for this message.
|
273
|
+
def conversation_sid
|
274
|
+
@properties['conversation_sid']
|
275
|
+
end
|
276
|
+
|
262
277
|
##
|
263
278
|
# @return [String] A 34 character string that uniquely identifies this resource.
|
264
279
|
def sid
|
@@ -271,12 +286,6 @@ module Twilio
|
|
271
286
|
@properties['message_sid']
|
272
287
|
end
|
273
288
|
|
274
|
-
##
|
275
|
-
# @return [String] The conversation_sid
|
276
|
-
def conversation_sid
|
277
|
-
@properties['conversation_sid']
|
278
|
-
end
|
279
|
-
|
280
289
|
##
|
281
290
|
# @return [String] A messaging channel-specific identifier for the message delivered to participant
|
282
291
|
def channel_message_sid
|
@@ -0,0 +1,427 @@
|
|
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
|
+
##
|
14
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
15
|
+
class CredentialList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the CredentialList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [CredentialList] CredentialList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Credentials"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Create the CredentialInstance
|
30
|
+
# @param [credential.PushType] type The type of push-notification service the
|
31
|
+
# credential is for. Can be: `fcm`, `gcm`, or `apn`.
|
32
|
+
# @param [String] friendly_name A descriptive string that you create to describe
|
33
|
+
# the new resource. It can be up to 64 characters long.
|
34
|
+
# @param [String] certificate [APN only] The URL encoded representation of the
|
35
|
+
# certificate. For example,
|
36
|
+
# `-----BEGIN CERTIFICATE-----
|
37
|
+
# MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A==
|
38
|
+
# -----END CERTIFICATE-----`.
|
39
|
+
# @param [String] private_key [APN only] The URL encoded representation of the
|
40
|
+
# private key. For example,
|
41
|
+
# `-----BEGIN RSA PRIVATE KEY-----
|
42
|
+
# MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG...
|
43
|
+
# -----END RSA PRIVATE KEY-----`.
|
44
|
+
# @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox
|
45
|
+
# APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
46
|
+
# @param [String] api_key [GCM only] The API key for the project that was obtained
|
47
|
+
# from the Google Developer console for your GCM Service application credential.
|
48
|
+
# @param [String] secret [FCM only] The **Server key** of your project from the
|
49
|
+
# Firebase console, found under Settings / Cloud messaging.
|
50
|
+
# @return [CredentialInstance] Created CredentialInstance
|
51
|
+
def create(type: nil, friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset)
|
52
|
+
data = Twilio::Values.of({
|
53
|
+
'Type' => type,
|
54
|
+
'FriendlyName' => friendly_name,
|
55
|
+
'Certificate' => certificate,
|
56
|
+
'PrivateKey' => private_key,
|
57
|
+
'Sandbox' => sandbox,
|
58
|
+
'ApiKey' => api_key,
|
59
|
+
'Secret' => secret,
|
60
|
+
})
|
61
|
+
|
62
|
+
payload = @version.create('POST', @uri, data: data)
|
63
|
+
|
64
|
+
CredentialInstance.new(@version, payload, )
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Lists CredentialInstance records from the API as a list.
|
69
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
70
|
+
# memory before returning.
|
71
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
72
|
+
# guarantees to never return more than limit. Default is no limit
|
73
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
74
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
75
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
76
|
+
# efficient page size, i.e. min(limit, 1000)
|
77
|
+
# @return [Array] Array of up to limit results
|
78
|
+
def list(limit: nil, page_size: nil)
|
79
|
+
self.stream(limit: limit, page_size: page_size).entries
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Streams CredentialInstance records from the API as an Enumerable.
|
84
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
85
|
+
# is reached.
|
86
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
87
|
+
# guarantees to never return more than limit. Default is no limit.
|
88
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
89
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
90
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
91
|
+
# efficient page size, i.e. min(limit, 1000)
|
92
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
93
|
+
def stream(limit: nil, page_size: nil)
|
94
|
+
limits = @version.read_limits(limit, page_size)
|
95
|
+
|
96
|
+
page = self.page(page_size: limits[:page_size], )
|
97
|
+
|
98
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# When passed a block, yields CredentialInstance records from the API.
|
103
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
104
|
+
# is reached.
|
105
|
+
def each
|
106
|
+
limits = @version.read_limits
|
107
|
+
|
108
|
+
page = self.page(page_size: limits[:page_size], )
|
109
|
+
|
110
|
+
@version.stream(page,
|
111
|
+
limit: limits[:limit],
|
112
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
113
|
+
end
|
114
|
+
|
115
|
+
##
|
116
|
+
# Retrieve a single page of CredentialInstance records from the API.
|
117
|
+
# Request is executed immediately.
|
118
|
+
# @param [String] page_token PageToken provided by the API
|
119
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
120
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
121
|
+
# @return [Page] Page of CredentialInstance
|
122
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
123
|
+
params = Twilio::Values.of({
|
124
|
+
'PageToken' => page_token,
|
125
|
+
'Page' => page_number,
|
126
|
+
'PageSize' => page_size,
|
127
|
+
})
|
128
|
+
|
129
|
+
response = @version.page('GET', @uri, params: params)
|
130
|
+
|
131
|
+
CredentialPage.new(@version, response, @solution)
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Retrieve a single page of CredentialInstance records from the API.
|
136
|
+
# Request is executed immediately.
|
137
|
+
# @param [String] target_url API-generated URL for the requested results page
|
138
|
+
# @return [Page] Page of CredentialInstance
|
139
|
+
def get_page(target_url)
|
140
|
+
response = @version.domain.request(
|
141
|
+
'GET',
|
142
|
+
target_url
|
143
|
+
)
|
144
|
+
CredentialPage.new(@version, response, @solution)
|
145
|
+
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# Provide a user friendly representation
|
149
|
+
def to_s
|
150
|
+
'#<Twilio.Conversations.V1.CredentialList>'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
156
|
+
class CredentialPage < Page
|
157
|
+
##
|
158
|
+
# Initialize the CredentialPage
|
159
|
+
# @param [Version] version Version that contains the resource
|
160
|
+
# @param [Response] response Response from the API
|
161
|
+
# @param [Hash] solution Path solution for the resource
|
162
|
+
# @return [CredentialPage] CredentialPage
|
163
|
+
def initialize(version, response, solution)
|
164
|
+
super(version, response)
|
165
|
+
|
166
|
+
# Path Solution
|
167
|
+
@solution = solution
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Build an instance of CredentialInstance
|
172
|
+
# @param [Hash] payload Payload response from the API
|
173
|
+
# @return [CredentialInstance] CredentialInstance
|
174
|
+
def get_instance(payload)
|
175
|
+
CredentialInstance.new(@version, payload, )
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# Provide a user friendly representation
|
180
|
+
def to_s
|
181
|
+
'<Twilio.Conversations.V1.CredentialPage>'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
187
|
+
class CredentialContext < InstanceContext
|
188
|
+
##
|
189
|
+
# Initialize the CredentialContext
|
190
|
+
# @param [Version] version Version that contains the resource
|
191
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
192
|
+
# resource.
|
193
|
+
# @return [CredentialContext] CredentialContext
|
194
|
+
def initialize(version, sid)
|
195
|
+
super(version)
|
196
|
+
|
197
|
+
# Path Solution
|
198
|
+
@solution = {sid: sid, }
|
199
|
+
@uri = "/Credentials/#{@solution[:sid]}"
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# Update the CredentialInstance
|
204
|
+
# @param [credential.PushType] type The type of push-notification service the
|
205
|
+
# credential is for. Can be: `fcm`, `gcm`, or `apn`.
|
206
|
+
# @param [String] friendly_name A descriptive string that you create to describe
|
207
|
+
# the new resource. It can be up to 64 characters long.
|
208
|
+
# @param [String] certificate [APN only] The URL encoded representation of the
|
209
|
+
# certificate. For example,
|
210
|
+
# `-----BEGIN CERTIFICATE-----
|
211
|
+
# MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A==
|
212
|
+
# -----END CERTIFICATE-----`.
|
213
|
+
# @param [String] private_key [APN only] The URL encoded representation of the
|
214
|
+
# private key. For example,
|
215
|
+
# `-----BEGIN RSA PRIVATE KEY-----
|
216
|
+
# MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG...
|
217
|
+
# -----END RSA PRIVATE KEY-----`.
|
218
|
+
# @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox
|
219
|
+
# APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
220
|
+
# @param [String] api_key [GCM only] The API key for the project that was obtained
|
221
|
+
# from the Google Developer console for your GCM Service application credential.
|
222
|
+
# @param [String] secret [FCM only] The **Server key** of your project from the
|
223
|
+
# Firebase console, found under Settings / Cloud messaging.
|
224
|
+
# @return [CredentialInstance] Updated CredentialInstance
|
225
|
+
def update(type: :unset, friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset)
|
226
|
+
data = Twilio::Values.of({
|
227
|
+
'Type' => type,
|
228
|
+
'FriendlyName' => friendly_name,
|
229
|
+
'Certificate' => certificate,
|
230
|
+
'PrivateKey' => private_key,
|
231
|
+
'Sandbox' => sandbox,
|
232
|
+
'ApiKey' => api_key,
|
233
|
+
'Secret' => secret,
|
234
|
+
})
|
235
|
+
|
236
|
+
payload = @version.update('POST', @uri, data: data)
|
237
|
+
|
238
|
+
CredentialInstance.new(@version, payload, sid: @solution[:sid], )
|
239
|
+
end
|
240
|
+
|
241
|
+
##
|
242
|
+
# Delete the CredentialInstance
|
243
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
244
|
+
def delete
|
245
|
+
@version.delete('DELETE', @uri)
|
246
|
+
end
|
247
|
+
|
248
|
+
##
|
249
|
+
# Fetch the CredentialInstance
|
250
|
+
# @return [CredentialInstance] Fetched CredentialInstance
|
251
|
+
def fetch
|
252
|
+
payload = @version.fetch('GET', @uri)
|
253
|
+
|
254
|
+
CredentialInstance.new(@version, payload, sid: @solution[:sid], )
|
255
|
+
end
|
256
|
+
|
257
|
+
##
|
258
|
+
# Provide a user friendly representation
|
259
|
+
def to_s
|
260
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
261
|
+
"#<Twilio.Conversations.V1.CredentialContext #{context}>"
|
262
|
+
end
|
263
|
+
|
264
|
+
##
|
265
|
+
# Provide a detailed, user friendly representation
|
266
|
+
def inspect
|
267
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
268
|
+
"#<Twilio.Conversations.V1.CredentialContext #{context}>"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
##
|
273
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
274
|
+
class CredentialInstance < InstanceResource
|
275
|
+
##
|
276
|
+
# Initialize the CredentialInstance
|
277
|
+
# @param [Version] version Version that contains the resource
|
278
|
+
# @param [Hash] payload payload that contains response from Twilio
|
279
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
280
|
+
# resource.
|
281
|
+
# @return [CredentialInstance] CredentialInstance
|
282
|
+
def initialize(version, payload, sid: nil)
|
283
|
+
super(version)
|
284
|
+
|
285
|
+
# Marshaled Properties
|
286
|
+
@properties = {
|
287
|
+
'sid' => payload['sid'],
|
288
|
+
'account_sid' => payload['account_sid'],
|
289
|
+
'friendly_name' => payload['friendly_name'],
|
290
|
+
'type' => payload['type'],
|
291
|
+
'sandbox' => payload['sandbox'],
|
292
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
293
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
294
|
+
'url' => payload['url'],
|
295
|
+
}
|
296
|
+
|
297
|
+
# Context
|
298
|
+
@instance_context = nil
|
299
|
+
@params = {'sid' => sid || @properties['sid'], }
|
300
|
+
end
|
301
|
+
|
302
|
+
##
|
303
|
+
# Generate an instance context for the instance, the context is capable of
|
304
|
+
# performing various actions. All instance actions are proxied to the context
|
305
|
+
# @return [CredentialContext] CredentialContext for this CredentialInstance
|
306
|
+
def context
|
307
|
+
unless @instance_context
|
308
|
+
@instance_context = CredentialContext.new(@version, @params['sid'], )
|
309
|
+
end
|
310
|
+
@instance_context
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# @return [String] A 34 character string that uniquely identifies this resource.
|
315
|
+
def sid
|
316
|
+
@properties['sid']
|
317
|
+
end
|
318
|
+
|
319
|
+
##
|
320
|
+
# @return [String] The unique id of the Account responsible for this credential.
|
321
|
+
def account_sid
|
322
|
+
@properties['account_sid']
|
323
|
+
end
|
324
|
+
|
325
|
+
##
|
326
|
+
# @return [String] The human-readable name of this credential.
|
327
|
+
def friendly_name
|
328
|
+
@properties['friendly_name']
|
329
|
+
end
|
330
|
+
|
331
|
+
##
|
332
|
+
# @return [credential.PushType] The type of push-notification service the credential is for.
|
333
|
+
def type
|
334
|
+
@properties['type']
|
335
|
+
end
|
336
|
+
|
337
|
+
##
|
338
|
+
# @return [String] [APN only] Whether to send the credential to sandbox APNs.
|
339
|
+
def sandbox
|
340
|
+
@properties['sandbox']
|
341
|
+
end
|
342
|
+
|
343
|
+
##
|
344
|
+
# @return [Time] The date that this resource was created.
|
345
|
+
def date_created
|
346
|
+
@properties['date_created']
|
347
|
+
end
|
348
|
+
|
349
|
+
##
|
350
|
+
# @return [Time] The date that this resource was last updated.
|
351
|
+
def date_updated
|
352
|
+
@properties['date_updated']
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# @return [String] An absolute URL for this credential.
|
357
|
+
def url
|
358
|
+
@properties['url']
|
359
|
+
end
|
360
|
+
|
361
|
+
##
|
362
|
+
# Update the CredentialInstance
|
363
|
+
# @param [credential.PushType] type The type of push-notification service the
|
364
|
+
# credential is for. Can be: `fcm`, `gcm`, or `apn`.
|
365
|
+
# @param [String] friendly_name A descriptive string that you create to describe
|
366
|
+
# the new resource. It can be up to 64 characters long.
|
367
|
+
# @param [String] certificate [APN only] The URL encoded representation of the
|
368
|
+
# certificate. For example,
|
369
|
+
# `-----BEGIN CERTIFICATE-----
|
370
|
+
# MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.....A==
|
371
|
+
# -----END CERTIFICATE-----`.
|
372
|
+
# @param [String] private_key [APN only] The URL encoded representation of the
|
373
|
+
# private key. For example,
|
374
|
+
# `-----BEGIN RSA PRIVATE KEY-----
|
375
|
+
# MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG...
|
376
|
+
# -----END RSA PRIVATE KEY-----`.
|
377
|
+
# @param [Boolean] sandbox [APN only] Whether to send the credential to sandbox
|
378
|
+
# APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
|
379
|
+
# @param [String] api_key [GCM only] The API key for the project that was obtained
|
380
|
+
# from the Google Developer console for your GCM Service application credential.
|
381
|
+
# @param [String] secret [FCM only] The **Server key** of your project from the
|
382
|
+
# Firebase console, found under Settings / Cloud messaging.
|
383
|
+
# @return [CredentialInstance] Updated CredentialInstance
|
384
|
+
def update(type: :unset, friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset)
|
385
|
+
context.update(
|
386
|
+
type: type,
|
387
|
+
friendly_name: friendly_name,
|
388
|
+
certificate: certificate,
|
389
|
+
private_key: private_key,
|
390
|
+
sandbox: sandbox,
|
391
|
+
api_key: api_key,
|
392
|
+
secret: secret,
|
393
|
+
)
|
394
|
+
end
|
395
|
+
|
396
|
+
##
|
397
|
+
# Delete the CredentialInstance
|
398
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
399
|
+
def delete
|
400
|
+
context.delete
|
401
|
+
end
|
402
|
+
|
403
|
+
##
|
404
|
+
# Fetch the CredentialInstance
|
405
|
+
# @return [CredentialInstance] Fetched CredentialInstance
|
406
|
+
def fetch
|
407
|
+
context.fetch
|
408
|
+
end
|
409
|
+
|
410
|
+
##
|
411
|
+
# Provide a user friendly representation
|
412
|
+
def to_s
|
413
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
414
|
+
"<Twilio.Conversations.V1.CredentialInstance #{values}>"
|
415
|
+
end
|
416
|
+
|
417
|
+
##
|
418
|
+
# Provide a detailed, user friendly representation
|
419
|
+
def inspect
|
420
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
421
|
+
"<Twilio.Conversations.V1.CredentialInstance #{values}>"
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|