class Twilio::REST::Sync::V1::ServiceContext
Public Class Methods
Initialize the ServiceContext
@param [Version] version Version
that contains the resource @param [String] sid The SID of the Service resource to fetch. @return [ServiceContext] ServiceContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/sync/v1/service.rb 191 def initialize(version, sid) 192 super(version) 193 194 # Path Solution 195 @solution = {sid: sid, } 196 @uri = "/Services/#{@solution[:sid]}" 197 198 # Dependents 199 @documents = nil 200 @sync_lists = nil 201 @sync_maps = nil 202 @sync_streams = nil 203 end
Public Instance Methods
Delete the ServiceInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/sync/v1/service.rb 217 def delete 218 @version.delete('DELETE', @uri) 219 end
Access the documents @return [DocumentList] @return [DocumentContext] if sid was passed.
# File lib/twilio-ruby/rest/sync/v1/service.rb 268 def documents(sid=:unset) 269 raise ArgumentError, 'sid cannot be nil' if sid.nil? 270 271 if sid != :unset 272 return DocumentContext.new(@version, @solution[:sid], sid, ) 273 end 274 275 unless @documents 276 @documents = DocumentList.new(@version, service_sid: @solution[:sid], ) 277 end 278 279 @documents 280 end
Fetch the ServiceInstance
@return [ServiceInstance] Fetched ServiceInstance
# File lib/twilio-ruby/rest/sync/v1/service.rb 208 def fetch 209 payload = @version.fetch('GET', @uri) 210 211 ServiceInstance.new(@version, payload, sid: @solution[:sid], ) 212 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service.rb 345 def inspect 346 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 347 "#<Twilio.Sync.V1.ServiceContext #{context}>" 348 end
Access the sync_lists
@return [SyncListList] @return [SyncListContext] if sid was passed.
# File lib/twilio-ruby/rest/sync/v1/service.rb 286 def sync_lists(sid=:unset) 287 raise ArgumentError, 'sid cannot be nil' if sid.nil? 288 289 if sid != :unset 290 return SyncListContext.new(@version, @solution[:sid], sid, ) 291 end 292 293 unless @sync_lists 294 @sync_lists = SyncListList.new(@version, service_sid: @solution[:sid], ) 295 end 296 297 @sync_lists 298 end
Access the sync_maps
@return [SyncMapList] @return [SyncMapContext] if sid was passed.
# File lib/twilio-ruby/rest/sync/v1/service.rb 304 def sync_maps(sid=:unset) 305 raise ArgumentError, 'sid cannot be nil' if sid.nil? 306 307 if sid != :unset 308 return SyncMapContext.new(@version, @solution[:sid], sid, ) 309 end 310 311 unless @sync_maps 312 @sync_maps = SyncMapList.new(@version, service_sid: @solution[:sid], ) 313 end 314 315 @sync_maps 316 end
Access the sync_streams
@return [SyncStreamList] @return [SyncStreamContext] if sid was passed.
# File lib/twilio-ruby/rest/sync/v1/service.rb 322 def sync_streams(sid=:unset) 323 raise ArgumentError, 'sid cannot be nil' if sid.nil? 324 325 if sid != :unset 326 return SyncStreamContext.new(@version, @solution[:sid], sid, ) 327 end 328 329 unless @sync_streams 330 @sync_streams = SyncStreamList.new(@version, service_sid: @solution[:sid], ) 331 end 332 333 @sync_streams 334 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service.rb 338 def to_s 339 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 340 "#<Twilio.Sync.V1.ServiceContext #{context}>" 341 end
Update the ServiceInstance
@param [String] webhook_url The URL we should call when Sync
objects are
manipulated.
@param [String] friendly_name A string that you assign to describe the resource. @param [Boolean] reachability_webhooks_enabled Whether the service instance
should call `webhook_url` when client endpoints connect to Sync. The default is `false`.
@param [Boolean] acl_enabled Whether token identities in the Service must be
granted access to Sync objects by using the {Permissions}[https://www.twilio.com/docs/sync/api/sync-permissions] resource.
@param [Boolean] reachability_debouncing_enabled Whether every
`endpoint_disconnected` event should occur after a configurable delay. The default is `false`, where the `endpoint_disconnected` event occurs immediately after disconnection. When `true`, intervening reconnections can prevent the `endpoint_disconnected` event.
@param [String] reachability_debouncing_window The reachability event delay in
milliseconds if `reachability_debouncing_enabled` = `true`. Must be between 1,000 and 30,000 and defaults to 5,000. This is the number of milliseconds after the last running client disconnects, and a Sync identity is declared offline, before the webhook is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the webhook from being called.
@param [Boolean] webhooks_from_rest_enabled Whether the Service instance should
call `webhook_url` when the REST API is used to update Sync objects. The default is `false`.
@return [ServiceInstance] Updated ServiceInstance
# File lib/twilio-ruby/rest/sync/v1/service.rb 248 def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset, webhooks_from_rest_enabled: :unset) 249 data = Twilio::Values.of({ 250 'WebhookUrl' => webhook_url, 251 'FriendlyName' => friendly_name, 252 'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled, 253 'AclEnabled' => acl_enabled, 254 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled, 255 'ReachabilityDebouncingWindow' => reachability_debouncing_window, 256 'WebhooksFromRestEnabled' => webhooks_from_rest_enabled, 257 }) 258 259 payload = @version.update('POST', @uri, data: data) 260 261 ServiceInstance.new(@version, payload, sid: @solution[:sid], ) 262 end