Class: Twilio::REST::Preview::Sync::ServiceContext::DocumentInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/sync/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

  • account_sid (String)

    The SID of the Account that created this Document resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 312

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_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  || @properties['service_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns:

  • (String)


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

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:



339
340
341
342
343
344
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 339

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

#created_byString

Returns:

  • (String)


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

def created_by
    @properties['created_by']
end

#dataHash

Returns:

  • (Hash)


390
391
392
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 390

def data
    @properties['data']
end

#date_createdTime

Returns:

  • (Time)


396
397
398
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 396

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns:

  • (Time)


402
403
404
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 402

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the DocumentInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#document_permissionsdocument_permissions

Access the document_permissions

Returns:



447
448
449
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 447

def document_permissions
    context.document_permissions
end

#fetchDocumentInstance

Fetch the DocumentInstance

Returns:



423
424
425
426
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 423

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



460
461
462
463
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 460

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

Returns:

  • (Hash)


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

def links
    @properties['links']
end

#revisionString

Returns:

  • (String)


384
385
386
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 384

def revision
    @properties['revision']
end

#service_sidString

Returns:

  • (String)


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

def service_sid
    @properties['service_sid']
end

#sidString

Returns:

  • (String)


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

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



453
454
455
456
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 453

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

#unique_nameString

Returns:

  • (String)


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

def unique_name
    @properties['unique_name']
end

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

Update the DocumentInstance

Parameters:

  • data (Object) (defaults to: nil)
  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:



433
434
435
436
437
438
439
440
441
442
# File 'lib/twilio-ruby/rest/preview/sync/service/document.rb', line 433

def update(
    data: nil, 
    if_match: :unset
)

    context.update(
        data: data, 
        if_match: if_match, 
    )
end

#urlString

Returns:

  • (String)


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

def url
    @properties['url']
end