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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/sync/v1/service/document.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ DocumentInstance

Initialize the DocumentInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil)

    The SID of the Sync Service the resource is associated with.

  • sid (String) (defaults to: nil)

    The SID of the Document resource to fetch. Can be the Document resource’s ‘sid` or its `unique_name`.



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 276

def initialize(version, payload, service_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'unique_name' => payload['unique_name'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'url' => payload['url'],
      'links' => payload['links'],
      'revision' => payload['revision'],
      'data' => payload['data'],
      'date_expires' => Twilio.deserialize_iso8601_datetime(payload['date_expires']),
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'created_by' => payload['created_by'],
  }

  # Context
  @instance_context = nil
  @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



325
326
327
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 325

def 
  @properties['account_sid']
end

#contextDocumentContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 304

def context
  unless @instance_context
    @instance_context = DocumentContext.new(@version, @params['service_sid'], @params['sid'], )
  end
  @instance_context
end

#created_byString

Returns The identity of the Sync Document’s creator.

Returns:

  • (String)

    The identity of the Sync Document’s creator



379
380
381
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 379

def created_by
  @properties['created_by']
end

#dataHash

Returns An arbitrary, schema-less object that the Sync Document stores.

Returns:

  • (Hash)

    An arbitrary, schema-less object that the Sync Document stores



355
356
357
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 355

def data
  @properties['data']
end

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



367
368
369
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 367

def date_created
  @properties['date_created']
end

#date_expiresTime

Returns The ISO 8601 date and time in GMT when the Sync Document expires.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the Sync Document expires



361
362
363
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 361

def date_expires
  @properties['date_expires']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



373
374
375
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 373

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the DocumentInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



393
394
395
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 393

def delete
  context.delete
end

#document_permissionsdocument_permissions

Access the document_permissions

Returns:



415
416
417
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 415

def document_permissions
  context.document_permissions
end

#fetchDocumentInstance

Fetch the DocumentInstance

Returns:



386
387
388
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 386

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



428
429
430
431
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 428

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Sync.V1.DocumentInstance #{values}>"
end

Returns The URLs of resources related to the Sync Document.

Returns:

  • (String)

    The URLs of resources related to the Sync Document



343
344
345
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 343

def links
  @properties['links']
end

#revisionString

Returns The current revision of the Sync Document, represented by a string identifier.

Returns:

  • (String)

    The current revision of the Sync Document, represented by a string identifier



349
350
351
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 349

def revision
  @properties['revision']
end

#service_sidString

Returns The SID of the Sync Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Sync Service that the resource is associated with



331
332
333
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 331

def service_sid
  @properties['service_sid']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



313
314
315
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 313

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



421
422
423
424
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 421

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Sync.V1.DocumentInstance #{values}>"
end

#unique_nameString

Returns An application-defined string that uniquely identifies the resource.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource



319
320
321
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 319

def unique_name
  @properties['unique_name']
end

#update(data: :unset, ttl: :unset, if_match: :unset) ⇒ DocumentInstance

Update the DocumentInstance

Parameters:

  • data (Hash) (defaults to: :unset)

    A JSON string that represents an arbitrary, schema-less object that the Sync Document stores. Can be up to 16 KiB in length.

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

    How long, in seconds, before the Sync Document expires and is deleted (time-to-live). Can be an integer from 0 to 31,536,000 (1 year). The default value is ‘0`, which means the Document resource does not expire. The Document resource will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources’s deletion.

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

    The If-Match HTTP request header

Returns:



408
409
410
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 408

def update(data: :unset, ttl: :unset, if_match: :unset)
  context.update(data: data, ttl: ttl, if_match: if_match, )
end

#urlString

Returns The absolute URL of the Document resource.

Returns:

  • (String)

    The absolute URL of the Document resource



337
338
339
# File 'lib/twilio-ruby/rest/sync/v1/service/document.rb', line 337

def url
  @properties['url']
end