Class: Twilio::REST::Fax::V1::FaxInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/fax/v1/fax.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ FaxInstance

Initialize the FaxInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    The Twilio-provided string that uniquely identifies the Fax resource to fetch.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 352

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'from' => payload['from'],
      'to' => payload['to'],
      'quality' => payload['quality'],
      'media_sid' => payload['media_sid'],
      'media_url' => payload['media_url'],
      'num_pages' => payload['num_pages'] == nil ? payload['num_pages'] : payload['num_pages'].to_i,
      'duration' => payload['duration'] == nil ? payload['duration'] : payload['duration'].to_i,
      'status' => payload['status'],
      'direction' => payload['direction'],
      'api_version' => payload['api_version'],
      'price' => payload['price'].to_f,
      'price_unit' => payload['price_unit'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'links' => payload['links'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'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



401
402
403
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 401

def 
  @properties['account_sid']
end

#api_versionString

Returns The API version used to transmit the fax.

Returns:

  • (String)

    The API version used to transmit the fax



461
462
463
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 461

def api_version
  @properties['api_version']
end

#contextFaxContext

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

Returns:

  • (FaxContext)

    FaxContext for this FaxInstance



386
387
388
389
390
391
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 386

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

#date_createdTime

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

Returns:

  • (Time)

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



479
480
481
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 479

def date_created
  @properties['date_created']
end

#date_updatedTime

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

Returns:

  • (Time)

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



485
486
487
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 485

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the FaxInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



520
521
522
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 520

def delete
  context.delete
end

#directionfax.Direction

Returns The direction of the fax.

Returns:

  • (fax.Direction)

    The direction of the fax



455
456
457
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 455

def direction
  @properties['direction']
end

#durationString

Returns The time it took to transmit the fax.

Returns:

  • (String)

    The time it took to transmit the fax



443
444
445
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 443

def duration
  @properties['duration']
end

#fetchFaxInstance

Fetch a FaxInstance

Returns:



504
505
506
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 504

def fetch
  context.fetch
end

#fromString

Returns The number the fax was sent from.

Returns:

  • (String)

    The number the fax was sent from



407
408
409
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 407

def from
  @properties['from']
end

#inspectObject

Provide a detailed, user friendly representation



540
541
542
543
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 540

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

Returns The URLs of the fax’s related resources.

Returns:

  • (String)

    The URLs of the fax’s related resources



491
492
493
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 491

def links
  @properties['links']
end

#mediamedia

Access the media

Returns:



527
528
529
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 527

def media
  context.media
end

#media_sidString

Returns The SID of the FaxMedia resource that is associated with the Fax.

Returns:

  • (String)

    The SID of the FaxMedia resource that is associated with the Fax



425
426
427
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 425

def media_sid
  @properties['media_sid']
end

#media_urlString

Returns The Twilio-hosted URL that can be used to download fax media.

Returns:

  • (String)

    The Twilio-hosted URL that can be used to download fax media



431
432
433
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 431

def media_url
  @properties['media_url']
end

#num_pagesString

Returns The number of pages contained in the fax document.

Returns:

  • (String)

    The number of pages contained in the fax document



437
438
439
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 437

def num_pages
  @properties['num_pages']
end

#priceString

Returns The fax transmission price.

Returns:

  • (String)

    The fax transmission price



467
468
469
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 467

def price
  @properties['price']
end

#price_unitString

Returns The ISO 4217 currency used for billing.

Returns:

  • (String)

    The ISO 4217 currency used for billing



473
474
475
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 473

def price_unit
  @properties['price_unit']
end

#qualityfax.Quality

Returns The quality of the fax.

Returns:

  • (fax.Quality)

    The quality of the fax



419
420
421
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 419

def quality
  @properties['quality']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



395
396
397
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 395

def sid
  @properties['sid']
end

#statusfax.Status

Returns The status of the fax.

Returns:

  • (fax.Status)

    The status of the fax



449
450
451
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 449

def status
  @properties['status']
end

#toString

Returns The phone number that received the fax.

Returns:

  • (String)

    The phone number that received the fax



413
414
415
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 413

def to
  @properties['to']
end

#to_sObject

Provide a user friendly representation



533
534
535
536
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 533

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

#update(status: :unset) ⇒ FaxInstance

Update the FaxInstance

Parameters:

  • status (fax.UpdateStatus) (defaults to: :unset)

    The new status of the resource. Can be only ‘canceled`. This may fail if transmission has already started.

Returns:



513
514
515
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 513

def update(status: :unset)
  context.update(status: status, )
end

#urlString

Returns The absolute URL of the fax resource.

Returns:

  • (String)

    The absolute URL of the fax resource



497
498
499
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 497

def url
  @properties['url']
end