Class: Twilio::REST::Fax::V1::FaxContext

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

Overview

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

Defined Under Namespace

Classes: FaxMediaContext, FaxMediaInstance, FaxMediaList, FaxMediaPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ FaxContext

Initialize the FaxContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

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


253
254
255
256
257
258
259
260
261
262
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 253

def initialize(version, sid)
  super(version)

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

  # Dependents
  @media = nil
end

Instance Method Details

#deleteBoolean

Delete the FaxInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


291
292
293
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 291

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

#fetchFaxInstance

Fetch the FaxInstance

Returns:


267
268
269
270
271
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 267

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

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

#inspectObject

Provide a detailed, user friendly representation


322
323
324
325
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 322

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

#media(sid = :unset) ⇒ FaxMediaList, FaxMediaContext

Access the media

Returns:

Raises:

  • (ArgumentError)

299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 299

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

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

  unless @media
    @media = FaxMediaList.new(@version, fax_sid: @solution[:sid], )
  end

  @media
end

#to_sObject

Provide a user friendly representation


315
316
317
318
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 315

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Fax.V1.FaxContext #{context}>"
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:


280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 280

def update(status: :unset)
  data = Twilio::Values.of({'Status' => status, })

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

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