twilio-ruby 5.0.0.rc3 → 5.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/lib/twilio-ruby/rest/client.rb +7 -4
- data/lib/twilio-ruby/rest/conversations/v1/conversation/completed.rb +0 -7
- data/lib/twilio-ruby/rest/conversations/v1/conversation/in_progress.rb +0 -7
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/notifications/v1/service/binding.rb +440 -0
- data/lib/twilio-ruby/rest/notifications/v1/service/notification.rb +217 -0
- data/lib/twilio-ruby/rest/notifications/v1/service.rb +478 -0
- data/lib/twilio-ruby/rest/notifications/v1.rb +35 -0
- data/lib/twilio-ruby/rest/notifications.rb +40 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +96 -5
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/ip_messaging/v1/credential_spec.rb +136 -0
- data/spec/integration/ip_messaging/v1/service/channel/member_spec.rb +133 -0
- data/spec/integration/ip_messaging/v1/service/channel_spec.rb +171 -1
- data/spec/integration/ip_messaging/v1/service/role_spec.rb +167 -1
- data/spec/integration/ip_messaging/v1/service/user_spec.rb +151 -1
- data/spec/integration/ip_messaging/v1/service_spec.rb +177 -1
- data/spec/integration/notifications/v1/service/binding_spec.rb +210 -0
- data/spec/integration/notifications/v1/service/notification_spec.rb +57 -0
- data/spec/integration/notifications/v1/service_spec.rb +244 -0
- metadata +14 -3
@@ -0,0 +1,217 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Notifications < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class NotificationList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the NotificationList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The service_sid
|
17
|
+
|
18
|
+
# @return [NotificationList] NotificationList
|
19
|
+
def initialize(version, service_sid: nil)
|
20
|
+
super(version)
|
21
|
+
|
22
|
+
# Path Solution
|
23
|
+
@solution = {
|
24
|
+
service_sid: service_sid
|
25
|
+
}
|
26
|
+
@uri = "/Services/#{@solution[:service_sid]}/Notifications"
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Retrieve a single page of NotificationInstance records from the API.
|
31
|
+
# Request is executed immediately.
|
32
|
+
# @param [String] identity The identity
|
33
|
+
# @param [String] tag The tag
|
34
|
+
# @param [String] body The body
|
35
|
+
# @param [String] priority The priority
|
36
|
+
# @param [String] ttl The ttl
|
37
|
+
# @param [String] title The title
|
38
|
+
# @param [String] sound The sound
|
39
|
+
# @param [String] action The action
|
40
|
+
# @param [String] data The data
|
41
|
+
# @param [String] apn The apn
|
42
|
+
# @param [String] gcm The gcm
|
43
|
+
|
44
|
+
# @return [NotificationInstance] Newly created NotificationInstance
|
45
|
+
def create(identity: nil, tag: nil, body: nil, priority: nil, ttl: nil, title: nil, sound: nil, action: nil, data: nil, apn: nil, gcm: nil)
|
46
|
+
data = {
|
47
|
+
'Identity' => identity,
|
48
|
+
'Tag' => tag,
|
49
|
+
'Body' => body,
|
50
|
+
'Priority' => priority,
|
51
|
+
'Ttl' => ttl,
|
52
|
+
'Title' => title,
|
53
|
+
'Sound' => sound,
|
54
|
+
'Action' => action,
|
55
|
+
'Data' => data,
|
56
|
+
'Apn' => apn,
|
57
|
+
'Gcm' => gcm,
|
58
|
+
}
|
59
|
+
|
60
|
+
payload = @version.create(
|
61
|
+
'POST',
|
62
|
+
@uri,
|
63
|
+
data: data
|
64
|
+
)
|
65
|
+
|
66
|
+
return NotificationInstance.new(
|
67
|
+
@version,
|
68
|
+
payload,
|
69
|
+
service_sid: @solution['service_sid'],
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Provide a user friendly representation
|
75
|
+
def to_s
|
76
|
+
'#<Twilio.Notifications.V1.NotificationList>'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class NotificationPage < Page
|
81
|
+
##
|
82
|
+
# Initialize the NotificationPage
|
83
|
+
# @param [Version] version Version that contains the resource
|
84
|
+
# @param [Response] response Response from the API
|
85
|
+
# @param [Hash] solution Path solution for the resource
|
86
|
+
# @param [String] service_sid The service_sid
|
87
|
+
|
88
|
+
# @return [NotificationPage] NotificationPage
|
89
|
+
def initialize(version, response, solution)
|
90
|
+
super(version, response)
|
91
|
+
|
92
|
+
# Path Solution
|
93
|
+
@solution = solution
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Build an instance of NotificationInstance
|
98
|
+
# @param [Hash] payload Payload response from the API
|
99
|
+
|
100
|
+
# @return [NotificationInstance] NotificationInstance
|
101
|
+
def get_instance(payload)
|
102
|
+
return NotificationInstance.new(
|
103
|
+
@version,
|
104
|
+
payload,
|
105
|
+
service_sid: @solution['service_sid'],
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Provide a user friendly representation
|
111
|
+
def to_s
|
112
|
+
'<Twilio.Notifications.V1.NotificationPage>'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class NotificationInstance < InstanceResource
|
117
|
+
##
|
118
|
+
# Initialize the NotificationInstance
|
119
|
+
# @param [Version] version Version that contains the resource
|
120
|
+
# @param [Hash] payload payload that contains response from Twilio
|
121
|
+
# @param [String] service_sid The service_sid
|
122
|
+
|
123
|
+
# @return [NotificationInstance] NotificationInstance
|
124
|
+
def initialize(version, payload, service_sid: nil)
|
125
|
+
super(version)
|
126
|
+
|
127
|
+
# Marshaled Properties
|
128
|
+
@properties = {
|
129
|
+
'sid' => payload['sid'],
|
130
|
+
'account_sid' => payload['account_sid'],
|
131
|
+
'service_sid' => payload['service_sid'],
|
132
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
133
|
+
'identities' => payload['identities'],
|
134
|
+
'tags' => payload['tags'],
|
135
|
+
'priority' => payload['priority'],
|
136
|
+
'ttl' => payload['ttl'].to_i,
|
137
|
+
'title' => payload['title'],
|
138
|
+
'body' => payload['body'],
|
139
|
+
'sound' => payload['sound'],
|
140
|
+
'action' => payload['action'],
|
141
|
+
'data' => payload['data'],
|
142
|
+
'apn' => payload['apn'],
|
143
|
+
'gcm' => payload['gcm'],
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
def sid
|
148
|
+
@properties['sid']
|
149
|
+
end
|
150
|
+
|
151
|
+
def account_sid
|
152
|
+
@properties['account_sid']
|
153
|
+
end
|
154
|
+
|
155
|
+
def service_sid
|
156
|
+
@properties['service_sid']
|
157
|
+
end
|
158
|
+
|
159
|
+
def date_created
|
160
|
+
@properties['date_created']
|
161
|
+
end
|
162
|
+
|
163
|
+
def identities
|
164
|
+
@properties['identities']
|
165
|
+
end
|
166
|
+
|
167
|
+
def tags
|
168
|
+
@properties['tags']
|
169
|
+
end
|
170
|
+
|
171
|
+
def priority
|
172
|
+
@properties['priority']
|
173
|
+
end
|
174
|
+
|
175
|
+
def ttl
|
176
|
+
@properties['ttl']
|
177
|
+
end
|
178
|
+
|
179
|
+
def title
|
180
|
+
@properties['title']
|
181
|
+
end
|
182
|
+
|
183
|
+
def body
|
184
|
+
@properties['body']
|
185
|
+
end
|
186
|
+
|
187
|
+
def sound
|
188
|
+
@properties['sound']
|
189
|
+
end
|
190
|
+
|
191
|
+
def action
|
192
|
+
@properties['action']
|
193
|
+
end
|
194
|
+
|
195
|
+
def data
|
196
|
+
@properties['data']
|
197
|
+
end
|
198
|
+
|
199
|
+
def apn
|
200
|
+
@properties['apn']
|
201
|
+
end
|
202
|
+
|
203
|
+
def gcm
|
204
|
+
@properties['gcm']
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# Provide a user friendly representation
|
209
|
+
def to_s
|
210
|
+
"<Twilio.Notifications.V1.NotificationInstance>"
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,478 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Notifications < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class ServiceList < ListResource
|
12
|
+
##
|
13
|
+
# Initialize the ServiceList
|
14
|
+
# @param [Version] version Version that contains the resource
|
15
|
+
|
16
|
+
# @return [ServiceList] ServiceList
|
17
|
+
def initialize(version)
|
18
|
+
super(version)
|
19
|
+
|
20
|
+
# Path Solution
|
21
|
+
@solution = {}
|
22
|
+
@uri = "/Services"
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
27
|
+
# Request is executed immediately.
|
28
|
+
# @param [String] friendly_name The friendly_name
|
29
|
+
# @param [String] apn_credential_sid The apn_credential_sid
|
30
|
+
# @param [String] gcm_credential_sid The gcm_credential_sid
|
31
|
+
# @param [String] default_apn_notification_protocol_version The
|
32
|
+
# default_apn_notification_protocol_version
|
33
|
+
# @param [String] default_gcm_notification_protocol_version The
|
34
|
+
# default_gcm_notification_protocol_version
|
35
|
+
|
36
|
+
# @return [ServiceInstance] Newly created ServiceInstance
|
37
|
+
def create(friendly_name: nil, apn_credential_sid: nil, gcm_credential_sid: nil, default_apn_notification_protocol_version: nil, default_gcm_notification_protocol_version: nil)
|
38
|
+
data = {
|
39
|
+
'FriendlyName' => friendly_name,
|
40
|
+
'ApnCredentialSid' => apn_credential_sid,
|
41
|
+
'GcmCredentialSid' => gcm_credential_sid,
|
42
|
+
'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version,
|
43
|
+
'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version,
|
44
|
+
}
|
45
|
+
|
46
|
+
payload = @version.create(
|
47
|
+
'POST',
|
48
|
+
@uri,
|
49
|
+
data: data
|
50
|
+
)
|
51
|
+
|
52
|
+
return ServiceInstance.new(
|
53
|
+
@version,
|
54
|
+
payload,
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Lists ServiceInstance records from the API as a list.
|
60
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
61
|
+
# memory before returning.
|
62
|
+
# @param [String] friendly_name The friendly_name
|
63
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
64
|
+
# guarantees to never return more than limit. Default is no limit
|
65
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
66
|
+
# the default value of 50 records. If no page_size is defined
|
67
|
+
# but a limit is defined, stream() will attempt to read the
|
68
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
69
|
+
|
70
|
+
# @return [Array] Array of up to limit results
|
71
|
+
def list(friendly_name: nil, limit: nil, page_size: nil)
|
72
|
+
self.stream(
|
73
|
+
friendly_name: friendly_name,
|
74
|
+
limit: limit,
|
75
|
+
page_size: page_size
|
76
|
+
).entries
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Streams ServiceInstance records from the API as an Enumerable.
|
81
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
82
|
+
# is reached.
|
83
|
+
# @param [String] friendly_name The friendly_name
|
84
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
85
|
+
# guarantees to never return more than limit. Default is no limit
|
86
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
87
|
+
# the default value of 50 records. If no page_size is defined
|
88
|
+
# but a limit is defined, stream() will attempt to read the
|
89
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
90
|
+
|
91
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
92
|
+
def stream(friendly_name: nil, limit: nil, page_size: nil)
|
93
|
+
limits = @version.read_limits(limit, page_size)
|
94
|
+
|
95
|
+
page = self.page(
|
96
|
+
friendly_name: friendly_name,
|
97
|
+
page_size: limits['page_size'],
|
98
|
+
)
|
99
|
+
|
100
|
+
@version.stream(page, limit: limits['limit'], page_limit: limits['page_limit'])
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# When passed a block, yields ServiceInstance records from the API.
|
105
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
106
|
+
# is reached.
|
107
|
+
# @param [String] friendly_name The friendly_name
|
108
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
109
|
+
# guarantees to never return more than limit. Default is no limit
|
110
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
111
|
+
# the default value of 50 records. If no page_size is defined
|
112
|
+
# but a limit is defined, stream() will attempt to read the
|
113
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
114
|
+
def each
|
115
|
+
limits = @version.read_limits
|
116
|
+
|
117
|
+
page = self.page(
|
118
|
+
page_size: limits['page_size'],
|
119
|
+
)
|
120
|
+
|
121
|
+
@version.stream(page,
|
122
|
+
limit: limits['limit'],
|
123
|
+
page_limit: limits['page_limit']).each {|x| yield x}
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
128
|
+
# Request is executed immediately.
|
129
|
+
# @param [String] friendly_name The friendly_name
|
130
|
+
# @param [String] page_token PageToken provided by the API
|
131
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
132
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
133
|
+
|
134
|
+
# @return [Page] Page of ServiceInstance
|
135
|
+
def page(friendly_name: nil, page_token: nil, page_number: nil, page_size: nil)
|
136
|
+
params = {
|
137
|
+
'FriendlyName' => friendly_name,
|
138
|
+
'PageToken' => page_token,
|
139
|
+
'Page' => page_number,
|
140
|
+
'PageSize' => page_size,
|
141
|
+
}
|
142
|
+
response = @version.page(
|
143
|
+
'GET',
|
144
|
+
@uri,
|
145
|
+
params
|
146
|
+
)
|
147
|
+
return ServicePage.new(@version, response, @solution)
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Constructs a ServiceContext
|
152
|
+
# @param [String] sid The sid
|
153
|
+
|
154
|
+
# @return [ServiceContext] ServiceContext
|
155
|
+
def get(sid)
|
156
|
+
ServiceContext.new(
|
157
|
+
@version,
|
158
|
+
sid: sid,
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Provide a user friendly representation
|
164
|
+
def to_s
|
165
|
+
'#<Twilio.Notifications.V1.ServiceList>'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class ServicePage < Page
|
170
|
+
##
|
171
|
+
# Initialize the ServicePage
|
172
|
+
# @param [Version] version Version that contains the resource
|
173
|
+
# @param [Response] response Response from the API
|
174
|
+
# @param [Hash] solution Path solution for the resource
|
175
|
+
|
176
|
+
# @return [ServicePage] ServicePage
|
177
|
+
def initialize(version, response, solution)
|
178
|
+
super(version, response)
|
179
|
+
|
180
|
+
# Path Solution
|
181
|
+
@solution = solution
|
182
|
+
end
|
183
|
+
|
184
|
+
##
|
185
|
+
# Build an instance of ServiceInstance
|
186
|
+
# @param [Hash] payload Payload response from the API
|
187
|
+
|
188
|
+
# @return [ServiceInstance] ServiceInstance
|
189
|
+
def get_instance(payload)
|
190
|
+
return ServiceInstance.new(
|
191
|
+
@version,
|
192
|
+
payload,
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# Provide a user friendly representation
|
198
|
+
def to_s
|
199
|
+
'<Twilio.Notifications.V1.ServicePage>'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class ServiceContext < InstanceContext
|
204
|
+
##
|
205
|
+
# Initialize the ServiceContext
|
206
|
+
# @param [Version] version Version that contains the resource
|
207
|
+
# @param [String] sid The sid
|
208
|
+
|
209
|
+
# @return [ServiceContext] ServiceContext
|
210
|
+
def initialize(version, sid)
|
211
|
+
super(version)
|
212
|
+
|
213
|
+
# Path Solution
|
214
|
+
@solution = {
|
215
|
+
sid: sid,
|
216
|
+
}
|
217
|
+
@uri = "/Services/#{@solution[:sid]}"
|
218
|
+
|
219
|
+
# Dependents
|
220
|
+
@bindings = nil
|
221
|
+
@notifications = nil
|
222
|
+
end
|
223
|
+
|
224
|
+
##
|
225
|
+
# Deletes the ServiceInstance
|
226
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
227
|
+
def delete
|
228
|
+
return @version.delete('delete', @uri)
|
229
|
+
end
|
230
|
+
|
231
|
+
##
|
232
|
+
# Fetch a ServiceInstance
|
233
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
234
|
+
def fetch
|
235
|
+
params = {}
|
236
|
+
|
237
|
+
payload = @version.fetch(
|
238
|
+
'GET',
|
239
|
+
@uri,
|
240
|
+
params,
|
241
|
+
)
|
242
|
+
|
243
|
+
return ServiceInstance.new(
|
244
|
+
@version,
|
245
|
+
payload,
|
246
|
+
sid: @solution['sid'],
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
##
|
251
|
+
# Update the ServiceInstance
|
252
|
+
# @param [String] friendly_name The friendly_name
|
253
|
+
# @param [String] apn_credential_sid The apn_credential_sid
|
254
|
+
# @param [String] gcm_credential_sid The gcm_credential_sid
|
255
|
+
# @param [String] default_apn_notification_protocol_version The
|
256
|
+
# default_apn_notification_protocol_version
|
257
|
+
# @param [String] default_gcm_notification_protocol_version The
|
258
|
+
# default_gcm_notification_protocol_version
|
259
|
+
|
260
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
261
|
+
def update(friendly_name: nil, apn_credential_sid: nil, gcm_credential_sid: nil, default_apn_notification_protocol_version: nil, default_gcm_notification_protocol_version: nil)
|
262
|
+
data = {
|
263
|
+
'FriendlyName' => friendly_name,
|
264
|
+
'ApnCredentialSid' => apn_credential_sid,
|
265
|
+
'GcmCredentialSid' => gcm_credential_sid,
|
266
|
+
'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version,
|
267
|
+
'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version,
|
268
|
+
}
|
269
|
+
|
270
|
+
payload = @version.update(
|
271
|
+
'POST',
|
272
|
+
@uri,
|
273
|
+
data: data,
|
274
|
+
)
|
275
|
+
|
276
|
+
return ServiceInstance.new(
|
277
|
+
@version,
|
278
|
+
payload,
|
279
|
+
sid: @solution['sid'],
|
280
|
+
)
|
281
|
+
end
|
282
|
+
|
283
|
+
##
|
284
|
+
# Access the bindings
|
285
|
+
# @return [BindingList] BindingList
|
286
|
+
def bindings(sid=:unset)
|
287
|
+
if sid != :unset
|
288
|
+
return BindingContext.new(
|
289
|
+
@version,
|
290
|
+
@solution[:sid],
|
291
|
+
sid,
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
unless @bindings
|
296
|
+
@bindings = BindingList.new(
|
297
|
+
@version,
|
298
|
+
service_sid: @solution[:sid],
|
299
|
+
)
|
300
|
+
end
|
301
|
+
|
302
|
+
@bindings
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# Access the notifications
|
307
|
+
# @return [NotificationList] NotificationList
|
308
|
+
def notifications
|
309
|
+
unless @notifications
|
310
|
+
@notifications = NotificationList.new(
|
311
|
+
@version,
|
312
|
+
service_sid: @solution[:sid],
|
313
|
+
)
|
314
|
+
end
|
315
|
+
|
316
|
+
@notifications
|
317
|
+
end
|
318
|
+
|
319
|
+
##
|
320
|
+
# Provide a user friendly representation
|
321
|
+
def to_s
|
322
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
323
|
+
"#<Twilio.Notifications.V1.ServiceContext #{context}>"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
class ServiceInstance < InstanceResource
|
328
|
+
##
|
329
|
+
# Initialize the ServiceInstance
|
330
|
+
# @param [Version] version Version that contains the resource
|
331
|
+
# @param [Hash] payload payload that contains response from Twilio
|
332
|
+
# @param [String] sid The sid
|
333
|
+
|
334
|
+
# @return [ServiceInstance] ServiceInstance
|
335
|
+
def initialize(version, payload, sid: nil)
|
336
|
+
super(version)
|
337
|
+
|
338
|
+
# Marshaled Properties
|
339
|
+
@properties = {
|
340
|
+
'sid' => payload['sid'],
|
341
|
+
'account_sid' => payload['account_sid'],
|
342
|
+
'friendly_name' => payload['friendly_name'],
|
343
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
344
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
345
|
+
'apn_credential_sid' => payload['apn_credential_sid'],
|
346
|
+
'gcm_credential_sid' => payload['gcm_credential_sid'],
|
347
|
+
'default_apn_notification_protocol_version' => payload['default_apn_notification_protocol_version'],
|
348
|
+
'default_gcm_notification_protocol_version' => payload['default_gcm_notification_protocol_version'],
|
349
|
+
'url' => payload['url'],
|
350
|
+
'links' => payload['links'],
|
351
|
+
}
|
352
|
+
|
353
|
+
# Context
|
354
|
+
@instance_context = nil
|
355
|
+
@params = {
|
356
|
+
'sid' => sid || @properties['sid'],
|
357
|
+
}
|
358
|
+
end
|
359
|
+
|
360
|
+
##
|
361
|
+
# Generate an instance context for the instance, the context is capable of
|
362
|
+
# performing various actions. All instance actions are proxied to the context
|
363
|
+
# @param [Version] version Version that contains the resource
|
364
|
+
|
365
|
+
# @return [ServiceContext] ServiceContext for this ServiceInstance
|
366
|
+
def context
|
367
|
+
unless @instance_context
|
368
|
+
@instance_context = ServiceContext.new(
|
369
|
+
@version,
|
370
|
+
@params['sid'],
|
371
|
+
)
|
372
|
+
end
|
373
|
+
@instance_context
|
374
|
+
end
|
375
|
+
|
376
|
+
def sid
|
377
|
+
@properties['sid']
|
378
|
+
end
|
379
|
+
|
380
|
+
def account_sid
|
381
|
+
@properties['account_sid']
|
382
|
+
end
|
383
|
+
|
384
|
+
def friendly_name
|
385
|
+
@properties['friendly_name']
|
386
|
+
end
|
387
|
+
|
388
|
+
def date_created
|
389
|
+
@properties['date_created']
|
390
|
+
end
|
391
|
+
|
392
|
+
def date_updated
|
393
|
+
@properties['date_updated']
|
394
|
+
end
|
395
|
+
|
396
|
+
def apn_credential_sid
|
397
|
+
@properties['apn_credential_sid']
|
398
|
+
end
|
399
|
+
|
400
|
+
def gcm_credential_sid
|
401
|
+
@properties['gcm_credential_sid']
|
402
|
+
end
|
403
|
+
|
404
|
+
def default_apn_notification_protocol_version
|
405
|
+
@properties['default_apn_notification_protocol_version']
|
406
|
+
end
|
407
|
+
|
408
|
+
def default_gcm_notification_protocol_version
|
409
|
+
@properties['default_gcm_notification_protocol_version']
|
410
|
+
end
|
411
|
+
|
412
|
+
def url
|
413
|
+
@properties['url']
|
414
|
+
end
|
415
|
+
|
416
|
+
def links
|
417
|
+
@properties['links']
|
418
|
+
end
|
419
|
+
|
420
|
+
##
|
421
|
+
# Deletes the ServiceInstance
|
422
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
423
|
+
def delete
|
424
|
+
@context.delete()
|
425
|
+
end
|
426
|
+
|
427
|
+
##
|
428
|
+
# Fetch a ServiceInstance
|
429
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
430
|
+
def fetch
|
431
|
+
@context.fetch()
|
432
|
+
end
|
433
|
+
|
434
|
+
##
|
435
|
+
# Update the ServiceInstance
|
436
|
+
# @param [String] friendly_name The friendly_name
|
437
|
+
# @param [String] apn_credential_sid The apn_credential_sid
|
438
|
+
# @param [String] gcm_credential_sid The gcm_credential_sid
|
439
|
+
# @param [String] default_apn_notification_protocol_version The
|
440
|
+
# default_apn_notification_protocol_version
|
441
|
+
# @param [String] default_gcm_notification_protocol_version The
|
442
|
+
# default_gcm_notification_protocol_version
|
443
|
+
|
444
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
445
|
+
def update(friendly_name: nil, apn_credential_sid: nil, gcm_credential_sid: nil, default_apn_notification_protocol_version: nil, default_gcm_notification_protocol_version: nil)
|
446
|
+
@context.update(
|
447
|
+
apn_credential_sid: apn_credential_sid,
|
448
|
+
gcm_credential_sid: gcm_credential_sid,
|
449
|
+
default_apn_notification_protocol_version: default_apn_notification_protocol_version,
|
450
|
+
default_gcm_notification_protocol_version: default_gcm_notification_protocol_version,
|
451
|
+
)
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# Access the bindings
|
456
|
+
# @return [bindings] bindings
|
457
|
+
def bindings
|
458
|
+
@context.bindings
|
459
|
+
end
|
460
|
+
|
461
|
+
##
|
462
|
+
# Access the notifications
|
463
|
+
# @return [notifications] notifications
|
464
|
+
def notifications
|
465
|
+
@context.notifications
|
466
|
+
end
|
467
|
+
|
468
|
+
##
|
469
|
+
# Provide a user friendly representation
|
470
|
+
def to_s
|
471
|
+
context = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
472
|
+
"<Twilio.Notifications.V1.ServiceInstance #{context}>"
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|