twilio-ruby 5.0.0.rc16 → 5.0.0.rc17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS.md +1 -0
- data/CHANGES.md +1 -1
- data/README.md +2 -2
- data/lib/twilio-ruby/jwt/access_token.rb +23 -1
- data/lib/twilio-ruby/rest/api.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account.rb +19 -11
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +29 -5
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +25 -0
- data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +406 -0
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +2 -6
- data/lib/twilio-ruby/rest/{notifications.rb → chat.rb} +6 -6
- data/lib/twilio-ruby/rest/{notifications → chat}/v1.rb +3 -3
- data/lib/twilio-ruby/rest/{notifications → chat}/v1/credential.rb +5 -5
- data/lib/twilio-ruby/rest/chat/v1/service.rb +501 -0
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +468 -0
- data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +351 -0
- data/lib/twilio-ruby/rest/{api/v2010/account/sms/sms_message.rb → chat/v1/service/channel/message.rb} +120 -168
- data/lib/twilio-ruby/rest/chat/v1/service/role.rb +373 -0
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +378 -0
- data/lib/twilio-ruby/rest/client.rb +19 -8
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +3 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +2 -6
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +5 -1
- data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +5 -0
- data/lib/twilio-ruby/rest/notify.rb +44 -0
- data/lib/twilio-ruby/rest/notify/v1.rb +44 -0
- data/lib/twilio-ruby/rest/notify/v1/credential.rb +375 -0
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service.rb +5 -5
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/binding.rb +5 -5
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/notification.rb +4 -4
- data/lib/twilio-ruby/rest/preview.rb +11 -0
- data/lib/twilio-ruby/rest/preview/sync.rb +35 -0
- data/lib/twilio-ruby/rest/preview/sync/service.rb +458 -0
- data/lib/twilio-ruby/rest/preview/sync/service/document.rb +376 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +375 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +409 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +375 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +411 -0
- data/lib/twilio-ruby/rest/preview/wireless/device.rb +6 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +55 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +29 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +294 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +32 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +374 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/api/v2010/account/conference/participant_spec.rb +6 -6
- data/spec/integration/api/v2010/account/recording_spec.rb +10 -1
- data/spec/integration/api/v2010/account/{sms/short_code_spec.rb → short_code_spec.rb} +0 -7
- data/spec/integration/api/v2010/account/sip/credential_list/credential_spec.rb +3 -7
- data/spec/integration/chat/v1/credential_spec.rb +223 -0
- data/spec/integration/chat/v1/service/channel/member_spec.rb +213 -0
- data/spec/integration/chat/v1/service/channel/message_spec.rb +100 -0
- data/spec/integration/chat/v1/service/channel_spec.rb +259 -0
- data/spec/integration/chat/v1/service/role_spec.rb +263 -0
- data/spec/integration/chat/v1/service/user_spec.rb +242 -0
- data/spec/integration/chat/v1/service_spec.rb +263 -0
- data/spec/integration/ip_messaging/v1/service/role_spec.rb +2 -3
- data/spec/integration/ip_messaging/v1/service/user_spec.rb +2 -3
- data/spec/integration/lookups/v1/phone_number_spec.rb +5 -0
- data/spec/integration/{notifications → notify}/v1/credential_spec.rb +24 -24
- data/spec/integration/{notifications → notify}/v1/service/binding_spec.rb +29 -29
- data/spec/integration/{notifications → notify}/v1/service/notification_spec.rb +5 -5
- data/spec/integration/{notifications → notify}/v1/service_spec.rb +32 -32
- data/spec/integration/preview/sync/service/document_spec.rb +92 -0
- data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +100 -0
- data/spec/integration/preview/sync/service/sync_list_spec.rb +73 -0
- data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +101 -0
- data/spec/integration/preview/sync/service/sync_map_spec.rb +73 -0
- data/spec/integration/preview/sync/service_spec.rb +84 -0
- data/spec/integration/taskrouter/v1/workspace/task_channel_spec.rb +127 -0
- data/spec/integration/taskrouter/v1/workspace/task_spec.rb +8 -0
- data/spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb +201 -0
- data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +2 -3
- data/spec/integration/taskrouter/v1/workspace_spec.rb +8 -0
- data/spec/jwt/access_token_spec.rb +27 -0
- metadata +84 -42
- data/lib/twilio-ruby/rest/api/v2010/account/sms.rb +0 -134
- data/lib/twilio-ruby/rest/api/v2010/account/sms/short_code.rb +0 -408
- data/spec/integration/api/v2010/account/sms/sms_message_spec.rb +0 -275
- data/spec/integration/api/v2010/account/sms_spec.rb +0 -10
@@ -14,8 +14,8 @@ module Twilio
|
|
14
14
|
##
|
15
15
|
# Initializes the Twilio Client
|
16
16
|
def initialize(username=nil, password=nil, account_sid=nil, http_client=Twilio::HTTP::Client.new)
|
17
|
-
@username = username || Twilio.
|
18
|
-
@password = password || Twilio.
|
17
|
+
@username = username || Twilio.account_sid
|
18
|
+
@password = password || Twilio.auth_token
|
19
19
|
@account_sid = account_sid || @username
|
20
20
|
@auth_token = @password
|
21
21
|
@auth = [@username, @password]
|
@@ -23,10 +23,11 @@ module Twilio
|
|
23
23
|
|
24
24
|
# Domains
|
25
25
|
@api = nil
|
26
|
+
@chat = nil
|
26
27
|
@ip_messaging = nil
|
27
28
|
@lookups = nil
|
28
29
|
@monitor = nil
|
29
|
-
@
|
30
|
+
@notify = nil
|
30
31
|
@preview = nil
|
31
32
|
@pricing = nil
|
32
33
|
@taskrouter = nil
|
@@ -71,6 +72,12 @@ module Twilio
|
|
71
72
|
@api ||= Api.new self
|
72
73
|
end
|
73
74
|
|
75
|
+
##
|
76
|
+
# Access the Chat Twilio Domain
|
77
|
+
def chat
|
78
|
+
@chat ||= Chat.new self
|
79
|
+
end
|
80
|
+
|
74
81
|
##
|
75
82
|
# Access the IpMessaging Twilio Domain
|
76
83
|
def ip_messaging
|
@@ -90,9 +97,9 @@ module Twilio
|
|
90
97
|
end
|
91
98
|
|
92
99
|
##
|
93
|
-
# Access the
|
94
|
-
def
|
95
|
-
@
|
100
|
+
# Access the Notify Twilio Domain
|
101
|
+
def notify
|
102
|
+
@notify ||= Notify.new self
|
96
103
|
end
|
97
104
|
|
98
105
|
##
|
@@ -175,6 +182,10 @@ module Twilio
|
|
175
182
|
return self.account.new_signing_keys
|
176
183
|
end
|
177
184
|
|
185
|
+
def notifications
|
186
|
+
return self.account.notifications
|
187
|
+
end
|
188
|
+
|
178
189
|
def outgoing_caller_ids
|
179
190
|
return self.account.outgoing_caller_ids
|
180
191
|
end
|
@@ -199,8 +210,8 @@ module Twilio
|
|
199
210
|
return self.account.sip
|
200
211
|
end
|
201
212
|
|
202
|
-
def
|
203
|
-
return self.account.
|
213
|
+
def short_codes
|
214
|
+
return self.account.short_codes
|
204
215
|
end
|
205
216
|
|
206
217
|
def tokens
|
@@ -33,11 +33,13 @@ module Twilio
|
|
33
33
|
# Request is executed immediately.
|
34
34
|
# @param [String] body The body
|
35
35
|
# @param [String] from The from
|
36
|
+
# @param [String] attributes The attributes
|
36
37
|
# @return [MessageInstance] Newly created MessageInstance
|
37
|
-
def create(body: nil, from: nil)
|
38
|
+
def create(body: nil, from: nil, attributes: nil)
|
38
39
|
data = {
|
39
40
|
'Body' => body,
|
40
41
|
'From' => from,
|
42
|
+
'Attributes' => attributes,
|
41
43
|
}
|
42
44
|
|
43
45
|
payload = @version.create(
|
@@ -222,12 +222,10 @@ module Twilio
|
|
222
222
|
|
223
223
|
##
|
224
224
|
# Update the RoleInstance
|
225
|
-
# @param [String] friendly_name The friendly_name
|
226
225
|
# @param [String] permission The permission
|
227
226
|
# @return [RoleInstance] Updated RoleInstance
|
228
|
-
def update(
|
227
|
+
def update(permission: nil)
|
229
228
|
data = {
|
230
|
-
'FriendlyName' => friendly_name,
|
231
229
|
'Permission' => permission,
|
232
230
|
}
|
233
231
|
|
@@ -353,12 +351,10 @@ module Twilio
|
|
353
351
|
|
354
352
|
##
|
355
353
|
# Update the RoleInstance
|
356
|
-
# @param [String] friendly_name The friendly_name
|
357
354
|
# @param [String] permission The permission
|
358
355
|
# @return [RoleInstance] Updated RoleInstance
|
359
|
-
def update(
|
356
|
+
def update(permission: nil)
|
360
357
|
context.update(
|
361
|
-
friendly_name: friendly_name,
|
362
358
|
permission: permission,
|
363
359
|
)
|
364
360
|
end
|
@@ -30,11 +30,15 @@ module Twilio
|
|
30
30
|
# Request is executed immediately.
|
31
31
|
# @param [String] identity The identity
|
32
32
|
# @param [String] role_sid The role_sid
|
33
|
+
# @param [String] attributes The attributes
|
34
|
+
# @param [String] friendly_name The friendly_name
|
33
35
|
# @return [UserInstance] Newly created UserInstance
|
34
|
-
def create(identity: nil, role_sid: nil)
|
36
|
+
def create(identity: nil, role_sid: nil, attributes: nil, friendly_name: nil)
|
35
37
|
data = {
|
36
38
|
'Identity' => identity,
|
37
39
|
'RoleSid' => role_sid,
|
40
|
+
'Attributes' => attributes,
|
41
|
+
'FriendlyName' => friendly_name,
|
38
42
|
}
|
39
43
|
|
40
44
|
payload = @version.create(
|
@@ -123,6 +123,7 @@ module Twilio
|
|
123
123
|
|
124
124
|
# Marshaled Properties
|
125
125
|
@properties = {
|
126
|
+
'caller_name' => payload['caller_name'],
|
126
127
|
'country_code' => payload['country_code'],
|
127
128
|
'phone_number' => payload['phone_number'],
|
128
129
|
'national_format' => payload['national_format'],
|
@@ -152,6 +153,10 @@ module Twilio
|
|
152
153
|
@instance_context
|
153
154
|
end
|
154
155
|
|
156
|
+
def caller_name
|
157
|
+
@properties['caller_name']
|
158
|
+
end
|
159
|
+
|
155
160
|
def country_code
|
156
161
|
@properties['country_code']
|
157
162
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Notify < Domain
|
10
|
+
##
|
11
|
+
# Initialize the Notify Domain
|
12
|
+
def initialize(twilio)
|
13
|
+
super
|
14
|
+
|
15
|
+
@base_url = 'https://notify.twilio.com'
|
16
|
+
@host = 'notify.twilio.com'
|
17
|
+
@port = 443
|
18
|
+
|
19
|
+
# Versions
|
20
|
+
@v1 = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Version v1 of notify
|
25
|
+
def v1
|
26
|
+
@v1 ||= V1.new self
|
27
|
+
end
|
28
|
+
|
29
|
+
def credentials
|
30
|
+
self.v1.credentials
|
31
|
+
end
|
32
|
+
|
33
|
+
def services
|
34
|
+
self.v1.services
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Provide a user friendly representation
|
39
|
+
def to_s
|
40
|
+
'#<Twilio::REST::Notify>'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Notify
|
10
|
+
class V1 < Version
|
11
|
+
##
|
12
|
+
# Initialize the V1 version of Notify
|
13
|
+
def initialize(domain)
|
14
|
+
super
|
15
|
+
@version = 'v1'
|
16
|
+
@credentials = nil
|
17
|
+
@services = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def credentials(sid=:unset)
|
21
|
+
if sid == :unset
|
22
|
+
@credentials ||= CredentialList.new self
|
23
|
+
else
|
24
|
+
CredentialContext.new(self, sid)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def services(sid=:unset)
|
29
|
+
if sid == :unset
|
30
|
+
@services ||= ServiceList.new self
|
31
|
+
else
|
32
|
+
ServiceContext.new(self, sid)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Provide a user friendly representation
|
38
|
+
def to_s
|
39
|
+
'<Twilio::REST::Notify::V1>'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,375 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Notify < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class CredentialList < ListResource
|
12
|
+
##
|
13
|
+
# Initialize the CredentialList
|
14
|
+
# @param [Version] version Version that contains the resource
|
15
|
+
# @return [CredentialList] CredentialList
|
16
|
+
def initialize(version)
|
17
|
+
super(version)
|
18
|
+
|
19
|
+
# Path Solution
|
20
|
+
@solution = {}
|
21
|
+
@uri = "/Credentials"
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Lists CredentialInstance records from the API as a list.
|
26
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
27
|
+
# memory before returning.
|
28
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
29
|
+
# guarantees to never return more than limit. Default is no limit
|
30
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
31
|
+
# the default value of 50 records. If no page_size is defined
|
32
|
+
# but a limit is defined, stream() will attempt to read the
|
33
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
34
|
+
# @return [Array] Array of up to limit results
|
35
|
+
def list(limit: nil, page_size: nil)
|
36
|
+
self.stream(
|
37
|
+
limit: limit,
|
38
|
+
page_size: page_size
|
39
|
+
).entries
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Streams CredentialInstance records from the API as an Enumerable.
|
44
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
45
|
+
# is reached.
|
46
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
47
|
+
# guarantees to never return more than limit. Default is no limit
|
48
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
49
|
+
# the default value of 50 records. If no page_size is defined
|
50
|
+
# but a limit is defined, stream() will attempt to read the
|
51
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
52
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
53
|
+
def stream(limit: nil, page_size: nil)
|
54
|
+
limits = @version.read_limits(limit, page_size)
|
55
|
+
|
56
|
+
page = self.page(
|
57
|
+
page_size: limits[:page_size],
|
58
|
+
)
|
59
|
+
|
60
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# When passed a block, yields CredentialInstance records from the API.
|
65
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
66
|
+
# is reached.
|
67
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
68
|
+
# guarantees to never return more than limit. Default is no limit
|
69
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
70
|
+
# the default value of 50 records. If no page_size is defined
|
71
|
+
# but a limit is defined, stream() will attempt to read the
|
72
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
73
|
+
def each
|
74
|
+
limits = @version.read_limits
|
75
|
+
|
76
|
+
page = self.page(
|
77
|
+
page_size: limits[:page_size],
|
78
|
+
)
|
79
|
+
|
80
|
+
@version.stream(page,
|
81
|
+
limit: limits[:limit],
|
82
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Retrieve a single page of CredentialInstance records from the API.
|
87
|
+
# Request is executed immediately.
|
88
|
+
# @param [String] page_token PageToken provided by the API
|
89
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
90
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
91
|
+
# @return [Page] Page of CredentialInstance
|
92
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
93
|
+
params = {
|
94
|
+
'PageToken' => page_token,
|
95
|
+
'Page' => page_number,
|
96
|
+
'PageSize' => page_size,
|
97
|
+
}
|
98
|
+
response = @version.page(
|
99
|
+
'GET',
|
100
|
+
@uri,
|
101
|
+
params
|
102
|
+
)
|
103
|
+
return CredentialPage.new(@version, response, @solution)
|
104
|
+
end
|
105
|
+
|
106
|
+
##
|
107
|
+
# Retrieve a single page of CredentialInstance records from the API.
|
108
|
+
# Request is executed immediately.
|
109
|
+
# @param [credential.PushService] type The type
|
110
|
+
# @param [String] friendly_name The friendly_name
|
111
|
+
# @param [String] certificate The certificate
|
112
|
+
# @param [String] private_key The private_key
|
113
|
+
# @param [Boolean] sandbox The sandbox
|
114
|
+
# @param [String] api_key The api_key
|
115
|
+
# @return [CredentialInstance] Newly created CredentialInstance
|
116
|
+
def create(type: nil, friendly_name: nil, certificate: nil, private_key: nil, sandbox: nil, api_key: nil)
|
117
|
+
data = {
|
118
|
+
'Type' => type,
|
119
|
+
'FriendlyName' => friendly_name,
|
120
|
+
'Certificate' => certificate,
|
121
|
+
'PrivateKey' => private_key,
|
122
|
+
'Sandbox' => sandbox,
|
123
|
+
'ApiKey' => api_key,
|
124
|
+
}
|
125
|
+
|
126
|
+
payload = @version.create(
|
127
|
+
'POST',
|
128
|
+
@uri,
|
129
|
+
data: data
|
130
|
+
)
|
131
|
+
|
132
|
+
return CredentialInstance.new(
|
133
|
+
@version,
|
134
|
+
payload,
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Provide a user friendly representation
|
140
|
+
def to_s
|
141
|
+
'#<Twilio.Notify.V1.CredentialList>'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class CredentialPage < Page
|
146
|
+
##
|
147
|
+
# Initialize the CredentialPage
|
148
|
+
# @param [Version] version Version that contains the resource
|
149
|
+
# @param [Response] response Response from the API
|
150
|
+
# @param [Hash] solution Path solution for the resource
|
151
|
+
# @return [CredentialPage] CredentialPage
|
152
|
+
def initialize(version, response, solution)
|
153
|
+
super(version, response)
|
154
|
+
|
155
|
+
# Path Solution
|
156
|
+
@solution = solution
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Build an instance of CredentialInstance
|
161
|
+
# @param [Hash] payload Payload response from the API
|
162
|
+
# @return [CredentialInstance] CredentialInstance
|
163
|
+
def get_instance(payload)
|
164
|
+
return CredentialInstance.new(
|
165
|
+
@version,
|
166
|
+
payload,
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Provide a user friendly representation
|
172
|
+
def to_s
|
173
|
+
'<Twilio.Notify.V1.CredentialPage>'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
class CredentialContext < InstanceContext
|
178
|
+
##
|
179
|
+
# Initialize the CredentialContext
|
180
|
+
# @param [Version] version Version that contains the resource
|
181
|
+
# @param [String] sid The sid
|
182
|
+
# @return [CredentialContext] CredentialContext
|
183
|
+
def initialize(version, sid)
|
184
|
+
super(version)
|
185
|
+
|
186
|
+
# Path Solution
|
187
|
+
@solution = {
|
188
|
+
sid: sid,
|
189
|
+
}
|
190
|
+
@uri = "/Credentials/#{@solution[:sid]}"
|
191
|
+
end
|
192
|
+
|
193
|
+
##
|
194
|
+
# Fetch a CredentialInstance
|
195
|
+
# @return [CredentialInstance] Fetched CredentialInstance
|
196
|
+
def fetch
|
197
|
+
params = {}
|
198
|
+
|
199
|
+
payload = @version.fetch(
|
200
|
+
'GET',
|
201
|
+
@uri,
|
202
|
+
params,
|
203
|
+
)
|
204
|
+
|
205
|
+
return CredentialInstance.new(
|
206
|
+
@version,
|
207
|
+
payload,
|
208
|
+
sid: @solution[:sid],
|
209
|
+
)
|
210
|
+
end
|
211
|
+
|
212
|
+
##
|
213
|
+
# Update the CredentialInstance
|
214
|
+
# @param [String] friendly_name The friendly_name
|
215
|
+
# @param [String] certificate The certificate
|
216
|
+
# @param [String] private_key The private_key
|
217
|
+
# @param [Boolean] sandbox The sandbox
|
218
|
+
# @param [String] api_key The api_key
|
219
|
+
# @return [CredentialInstance] Updated CredentialInstance
|
220
|
+
def update(friendly_name: nil, certificate: nil, private_key: nil, sandbox: nil, api_key: nil)
|
221
|
+
data = {
|
222
|
+
'FriendlyName' => friendly_name,
|
223
|
+
'Certificate' => certificate,
|
224
|
+
'PrivateKey' => private_key,
|
225
|
+
'Sandbox' => sandbox,
|
226
|
+
'ApiKey' => api_key,
|
227
|
+
}
|
228
|
+
|
229
|
+
payload = @version.update(
|
230
|
+
'POST',
|
231
|
+
@uri,
|
232
|
+
data: data,
|
233
|
+
)
|
234
|
+
|
235
|
+
return CredentialInstance.new(
|
236
|
+
@version,
|
237
|
+
payload,
|
238
|
+
sid: @solution[:sid],
|
239
|
+
)
|
240
|
+
end
|
241
|
+
|
242
|
+
##
|
243
|
+
# Deletes the CredentialInstance
|
244
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
245
|
+
def delete
|
246
|
+
return @version.delete('delete', @uri)
|
247
|
+
end
|
248
|
+
|
249
|
+
##
|
250
|
+
# Provide a user friendly representation
|
251
|
+
def to_s
|
252
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
253
|
+
"#<Twilio.Notify.V1.CredentialContext #{context}>"
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
class CredentialInstance < InstanceResource
|
258
|
+
##
|
259
|
+
# Initialize the CredentialInstance
|
260
|
+
# @param [Version] version Version that contains the resource
|
261
|
+
# @param [Hash] payload payload that contains response from Twilio
|
262
|
+
# @param [String] sid The sid
|
263
|
+
# @return [CredentialInstance] CredentialInstance
|
264
|
+
def initialize(version, payload, sid: nil)
|
265
|
+
super(version)
|
266
|
+
|
267
|
+
# Marshaled Properties
|
268
|
+
@properties = {
|
269
|
+
'sid' => payload['sid'],
|
270
|
+
'account_sid' => payload['account_sid'],
|
271
|
+
'friendly_name' => payload['friendly_name'],
|
272
|
+
'type' => payload['type'],
|
273
|
+
'sandbox' => payload['sandbox'],
|
274
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
275
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
276
|
+
'url' => payload['url'],
|
277
|
+
}
|
278
|
+
|
279
|
+
# Context
|
280
|
+
@instance_context = nil
|
281
|
+
@params = {
|
282
|
+
'sid' => sid || @properties['sid'],
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Generate an instance context for the instance, the context is capable of
|
288
|
+
# performing various actions. All instance actions are proxied to the context
|
289
|
+
# @param [Version] version Version that contains the resource
|
290
|
+
# @return [CredentialContext] CredentialContext for this CredentialInstance
|
291
|
+
def context
|
292
|
+
unless @instance_context
|
293
|
+
@instance_context = CredentialContext.new(
|
294
|
+
@version,
|
295
|
+
@params['sid'],
|
296
|
+
)
|
297
|
+
end
|
298
|
+
@instance_context
|
299
|
+
end
|
300
|
+
|
301
|
+
def sid
|
302
|
+
@properties['sid']
|
303
|
+
end
|
304
|
+
|
305
|
+
def account_sid
|
306
|
+
@properties['account_sid']
|
307
|
+
end
|
308
|
+
|
309
|
+
def friendly_name
|
310
|
+
@properties['friendly_name']
|
311
|
+
end
|
312
|
+
|
313
|
+
def type
|
314
|
+
@properties['type']
|
315
|
+
end
|
316
|
+
|
317
|
+
def sandbox
|
318
|
+
@properties['sandbox']
|
319
|
+
end
|
320
|
+
|
321
|
+
def date_created
|
322
|
+
@properties['date_created']
|
323
|
+
end
|
324
|
+
|
325
|
+
def date_updated
|
326
|
+
@properties['date_updated']
|
327
|
+
end
|
328
|
+
|
329
|
+
def url
|
330
|
+
@properties['url']
|
331
|
+
end
|
332
|
+
|
333
|
+
##
|
334
|
+
# Fetch a CredentialInstance
|
335
|
+
# @return [CredentialInstance] Fetched CredentialInstance
|
336
|
+
def fetch
|
337
|
+
context.fetch
|
338
|
+
end
|
339
|
+
|
340
|
+
##
|
341
|
+
# Update the CredentialInstance
|
342
|
+
# @param [String] friendly_name The friendly_name
|
343
|
+
# @param [String] certificate The certificate
|
344
|
+
# @param [String] private_key The private_key
|
345
|
+
# @param [Boolean] sandbox The sandbox
|
346
|
+
# @param [String] api_key The api_key
|
347
|
+
# @return [CredentialInstance] Updated CredentialInstance
|
348
|
+
def update(friendly_name: nil, certificate: nil, private_key: nil, sandbox: nil, api_key: nil)
|
349
|
+
context.update(
|
350
|
+
friendly_name: friendly_name,
|
351
|
+
certificate: certificate,
|
352
|
+
private_key: private_key,
|
353
|
+
sandbox: sandbox,
|
354
|
+
api_key: api_key,
|
355
|
+
)
|
356
|
+
end
|
357
|
+
|
358
|
+
##
|
359
|
+
# Deletes the CredentialInstance
|
360
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
361
|
+
def delete
|
362
|
+
context.delete
|
363
|
+
end
|
364
|
+
|
365
|
+
##
|
366
|
+
# Provide a user friendly representation
|
367
|
+
def to_s
|
368
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
369
|
+
"<Twilio.Notify.V1.CredentialInstance #{values}>"
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|