class Twilio::REST::Fax::V1::FaxList

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

Public Class Methods

new(version) click to toggle source

Initialize the FaxList @param [Version] version Version that contains the resource @return [FaxList] FaxList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/fax/v1/fax.rb
20 def initialize(version)
21   super(version)
22 
23   # Path Solution
24   @solution = {}
25   @uri = "/Faxes"
26 end

Public Instance Methods

create(to: nil, media_url: nil, quality: :unset, status_callback: :unset, from: :unset, sip_auth_username: :unset, sip_auth_password: :unset, store_media: :unset, ttl: :unset) click to toggle source

Create the FaxInstance @param [String] to The phone number to receive the fax in

{E.164}[https://www.twilio.com/docs/glossary/what-e164] format or the
recipient's SIP URI.

@param [String] media_url The URL of the PDF that contains the fax. See our

{security}[https://www.twilio.com/docs/usage/security] page for information on
how to ensure the request for your media comes from Twilio.

@param [fax.Quality] quality The {Fax Quality

value}[https://www.twilio.com/docs/fax/api/fax-resource#fax-quality-values] that
describes the fax quality. Can be: `standard`, `fine`, or `superfine` and
defaults to `fine`.

@param [String] status_callback The URL we should call using the `POST` method

to send {status
information}[https://www.twilio.com/docs/fax/api/fax-resource#fax-status-callback]
to your application when the status of the fax changes.

@param [String] from The number the fax was sent from. Can be the phone number

in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format or the SIP
`from` value. The caller ID displayed to the recipient uses this value. If this
is a phone number, it must be a Twilio number or a verified outgoing caller id
from your account. If `to` is a SIP address, this can be any alphanumeric string
(and also the characters `+`, `_`, `.`, and `-`), which will be used in the
`from` header of the SIP request.

@param [String] sip_auth_username The username to use with the

`sip_auth_password` to authenticate faxes sent to a SIP address.

@param [String] sip_auth_password The password to use with `sip_auth_username`

to authenticate faxes sent to a SIP address.

@param [Boolean] store_media Whether to store a copy of the sent media on our

servers for later retrieval. Can be: `true` or `false` and the default is
`true`.

@param [String] ttl How long in minutes from when the fax is initiated that we

should try to send the fax.

@return [FaxInstance] Created FaxInstance

    # File lib/twilio-ruby/rest/fax/v1/fax.rb
188 def create(to: nil, media_url: nil, quality: :unset, status_callback: :unset, from: :unset, sip_auth_username: :unset, sip_auth_password: :unset, store_media: :unset, ttl: :unset)
189   data = Twilio::Values.of({
190       'To' => to,
191       'MediaUrl' => media_url,
192       'Quality' => quality,
193       'StatusCallback' => status_callback,
194       'From' => from,
195       'SipAuthUsername' => sip_auth_username,
196       'SipAuthPassword' => sip_auth_password,
197       'StoreMedia' => store_media,
198       'Ttl' => ttl,
199   })
200 
201   payload = @version.create('POST', @uri, data: data)
202 
203   FaxInstance.new(@version, payload, )
204 end
each() { |x| ... } click to toggle source

When passed a block, yields FaxInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/fax/v1/fax.rb
 99 def each
100   limits = @version.read_limits
101 
102   page = self.page(page_size: limits[:page_size], )
103 
104   @version.stream(page,
105                   limit: limits[:limit],
106                   page_limit: limits[:page_limit]).each {|x| yield x}
107 end
get_page(target_url) click to toggle source

Retrieve a single page of FaxInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of FaxInstance

    # File lib/twilio-ruby/rest/fax/v1/fax.rb
147 def get_page(target_url)
148   response = @version.domain.request(
149       'GET',
150       target_url
151   )
152   FaxPage.new(@version, response, @solution)
153 end
list(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, limit: nil, page_size: nil) click to toggle source

Lists FaxInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] from Retrieve only those faxes sent from this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [String] to Retrieve only those faxes sent to this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [Time] date_created_on_or_before Retrieve only those faxes with a

`date_created` that is before or equal to this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [Time] date_created_after Retrieve only those faxes with a `date_created`

that is later than this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/fax/v1/fax.rb
49 def list(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, limit: nil, page_size: nil)
50   self.stream(
51       from: from,
52       to: to,
53       date_created_on_or_before: date_created_on_or_before,
54       date_created_after: date_created_after,
55       limit: limit,
56       page_size: page_size
57   ).entries
58 end
page(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of FaxInstance records from the API. Request is executed immediately. @param [String] from Retrieve only those faxes sent from this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [String] to Retrieve only those faxes sent to this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [Time] date_created_on_or_before Retrieve only those faxes with a

`date_created` that is before or equal to this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [Time] date_created_after Retrieve only those faxes with a `date_created`

that is later than this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of FaxInstance

    # File lib/twilio-ruby/rest/fax/v1/fax.rb
126 def page(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
127   params = Twilio::Values.of({
128       'From' => from,
129       'To' => to,
130       'DateCreatedOnOrBefore' => Twilio.serialize_iso8601_datetime(date_created_on_or_before),
131       'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after),
132       'PageToken' => page_token,
133       'Page' => page_number,
134       'PageSize' => page_size,
135   })
136 
137   response = @version.page('GET', @uri, params: params)
138 
139   FaxPage.new(@version, response, @solution)
140 end
stream(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, limit: nil, page_size: nil) click to toggle source

Streams FaxInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] from Retrieve only those faxes sent from this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [String] to Retrieve only those faxes sent to this phone number,

specified in {E.164}[https://www.twilio.com/docs/glossary/what-e164] format.

@param [Time] date_created_on_or_before Retrieve only those faxes with a

`date_created` that is before or equal to this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [Time] date_created_after Retrieve only those faxes with a `date_created`

that is later than this value, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

   # File lib/twilio-ruby/rest/fax/v1/fax.rb
81 def stream(from: :unset, to: :unset, date_created_on_or_before: :unset, date_created_after: :unset, limit: nil, page_size: nil)
82   limits = @version.read_limits(limit, page_size)
83 
84   page = self.page(
85       from: from,
86       to: to,
87       date_created_on_or_before: date_created_on_or_before,
88       date_created_after: date_created_after,
89       page_size: limits[:page_size],
90   )
91 
92   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
93 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/fax/v1/fax.rb
208 def to_s
209   '#<Twilio.Fax.V1.FaxList>'
210 end