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)

    A 34 character string that uniquely identifies this fax.



242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 242

def initialize(version, sid)
  super(version)

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

  # Dependents
  @media = nil
end

Instance Method Details

#deleteBoolean

Deletes the FaxInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

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

#fetchFaxInstance

Fetch a FaxInstance

Returns:



256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 256

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

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

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

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

Access the media

Returns:

Raises:

  • (ArgumentError)


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

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



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

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 updated status of this fax. The only valid option is ‘canceled`. This may fail if the status has already started transmission.

Returns:



274
275
276
277
278
279
280
281
282
283
284
# File 'lib/twilio-ruby/rest/fax/v1/fax.rb', line 274

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