class Twilio::REST::Sync::V1::ServiceList
Public Class Methods
Initialize the ServiceList
@param [Version] version Version
that contains the resource @return [ServiceList] ServiceList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/sync/v1/service.rb 18 def initialize(version) 19 super(version) 20 21 # Path Solution 22 @solution = {} 23 @uri = "/Services" 24 end
Public Instance Methods
Create the ServiceInstance
@param [String] friendly_name A string that you assign to describe the resource. @param [String] webhook_url The URL we should call when Sync
objects are
manipulated.
@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_url` is called if all endpoints remain offline. A reconnection from the same identity by any endpoint during this interval prevents the call to `webhook_url`.
@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] Created ServiceInstance
# File lib/twilio-ruby/rest/sync/v1/service.rb 53 def create(friendly_name: :unset, webhook_url: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset, reachability_debouncing_enabled: :unset, reachability_debouncing_window: :unset, webhooks_from_rest_enabled: :unset) 54 data = Twilio::Values.of({ 55 'FriendlyName' => friendly_name, 56 'WebhookUrl' => webhook_url, 57 'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled, 58 'AclEnabled' => acl_enabled, 59 'ReachabilityDebouncingEnabled' => reachability_debouncing_enabled, 60 'ReachabilityDebouncingWindow' => reachability_debouncing_window, 61 'WebhooksFromRestEnabled' => webhooks_from_rest_enabled, 62 }) 63 64 payload = @version.create('POST', @uri, data: data) 65 66 ServiceInstance.new(@version, payload, ) 67 end
When passed a block, yields ServiceInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/sync/v1/service.rb 107 def each 108 limits = @version.read_limits 109 110 page = self.page(page_size: limits[:page_size], ) 111 112 @version.stream(page, 113 limit: limits[:limit], 114 page_limit: limits[:page_limit]).each {|x| yield x} 115 end
Retrieve a single page of ServiceInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ServiceInstance
# File lib/twilio-ruby/rest/sync/v1/service.rb 141 def get_page(target_url) 142 response = @version.domain.request( 143 'GET', 144 target_url 145 ) 146 ServicePage.new(@version, response, @solution) 147 end
Lists ServiceInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/sync/v1/service.rb 80 def list(limit: nil, page_size: nil) 81 self.stream(limit: limit, page_size: page_size).entries 82 end
Retrieve a single page of ServiceInstance
records from the API. Request
is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of ServiceInstance
# File lib/twilio-ruby/rest/sync/v1/service.rb 124 def page(page_token: :unset, page_number: :unset, page_size: :unset) 125 params = Twilio::Values.of({ 126 'PageToken' => page_token, 127 'Page' => page_number, 128 'PageSize' => page_size, 129 }) 130 131 response = @version.page('GET', @uri, params: params) 132 133 ServicePage.new(@version, response, @solution) 134 end
Streams ServiceInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/sync/v1/service.rb 95 def stream(limit: nil, page_size: nil) 96 limits = @version.read_limits(limit, page_size) 97 98 page = self.page(page_size: limits[:page_size], ) 99 100 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 101 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service.rb 151 def to_s 152 '#<Twilio.Sync.V1.ServiceList>' 153 end