Class: Twilio::REST::Sync::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/sync/v1/service.rb,
lib/twilio-ruby/rest/sync/v1/service/document.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_map.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_list.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_stream.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_stream/stream_message.rb,
lib/twilio-ruby/rest/sync/v1/service/document/document_permission.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_permission.rb,
lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_permission.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: DocumentContext, DocumentInstance, DocumentList, DocumentPage, SyncListContext, SyncListInstance, SyncListList, SyncListPage, SyncMapContext, SyncMapInstance, SyncMapList, SyncMapPage, SyncStreamContext, SyncStreamInstance, SyncStreamList, SyncStreamPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The sid



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 192

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {
      sid: sid,
  }
  @uri = "/Services/#{@solution[:sid]}"

  # Dependents
  @documents = nil
  @sync_lists = nil
  @sync_maps = nil
  @sync_streams = nil
end

Instance Method Details

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



230
231
232
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 230

def delete
  @version.delete('delete', @uri)
end

#documents(sid = :unset) ⇒ DocumentList, DocumentContext

Access the documents

Returns:

Raises:

  • (ArgumentError)


266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 266

def documents(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return DocumentContext.new(
        @version,
        @solution[:sid],
        sid,
    )
  end

  unless @documents
    @documents = DocumentList.new(
        @version,
        service_sid: @solution[:sid],
    )
  end

  @documents
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 211

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  ServiceInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end

#sync_lists(sid = :unset) ⇒ SyncListList, SyncListContext

Access the sync_lists

Returns:

Raises:

  • (ArgumentError)


291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 291

def sync_lists(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SyncListContext.new(
        @version,
        @solution[:sid],
        sid,
    )
  end

  unless @sync_lists
    @sync_lists = SyncListList.new(
        @version,
        service_sid: @solution[:sid],
    )
  end

  @sync_lists
end

#sync_maps(sid = :unset) ⇒ SyncMapList, SyncMapContext

Access the sync_maps

Returns:

Raises:

  • (ArgumentError)


316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 316

def sync_maps(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SyncMapContext.new(
        @version,
        @solution[:sid],
        sid,
    )
  end

  unless @sync_maps
    @sync_maps = SyncMapList.new(
        @version,
        service_sid: @solution[:sid],
    )
  end

  @sync_maps
end

#sync_streams(sid = :unset) ⇒ SyncStreamList, SyncStreamContext

Access the sync_streams

Returns:

Raises:

  • (ArgumentError)


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 341

def sync_streams(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SyncStreamContext.new(
        @version,
        @solution[:sid],
        sid,
    )
  end

  unless @sync_streams
    @sync_streams = SyncStreamList.new(
        @version,
        service_sid: @solution[:sid],
    )
  end

  @sync_streams
end

#to_sObject

Provide a user friendly representation



364
365
366
367
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 364

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Sync.V1.ServiceContext #{context}>"
end

#update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • webhook_url (String) (defaults to: :unset)

    The webhook_url

  • friendly_name (String) (defaults to: :unset)

    The friendly_name

  • reachability_webhooks_enabled (Boolean) (defaults to: :unset)

    The reachability_webhooks_enabled

  • acl_enabled (Boolean) (defaults to: :unset)

    The acl_enabled

Returns:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/sync/v1/service.rb', line 241

def update(webhook_url: :unset, friendly_name: :unset, reachability_webhooks_enabled: :unset, acl_enabled: :unset)
  data = Twilio::Values.of({
      'WebhookUrl' => webhook_url,
      'FriendlyName' => friendly_name,
      'ReachabilityWebhooksEnabled' => reachability_webhooks_enabled,
      'AclEnabled' => acl_enabled,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  ServiceInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end