Class: Phaxio::Resources::Fax

Inherits:
Phaxio::Resource show all
Defined in:
lib/phaxio/resources/fax.rb

Overview

Provides functionality for viewing and managing faxes.

Defined Under Namespace

Classes: Reference

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Phaxio::Resource

response_collection, response_record

Instance Attribute Details

#caller_idString

Returns for sent faxes only, the number set as the Caller ID when sending the fax.

Returns:

  • (String)

    for sent faxes only, the number set as the Caller ID when sending the fax.


# File 'lib/phaxio/resources/fax.rb', line 27

#completed_atTime

Returns the time the fax was completed.

Returns:

  • (Time)

    the time the fax was completed.


71
# File 'lib/phaxio/resources/fax.rb', line 71

has_time_attributes %w[created_at completed_at]

#costInteger

Returns the cost of the fax in cents.

Returns:

  • (Integer)

    the cost of the fax in cents.


# File 'lib/phaxio/resources/fax.rb', line 17

#created_atTime

Returns the time the fax was created.

Returns:

  • (Time)

    the time the fax was created.


# File 'lib/phaxio/resources/fax.rb', line 63

#direction"sent" | "received"

Returns the direction of the fax.

Returns:

  • ("sent" | "received")

    the direction of the fax.


# File 'lib/phaxio/resources/fax.rb', line 11

#error_idInteger

Returns a numeric error code that corresponds to the error message, if any.

Returns:

  • (Integer)

    a numeric error code that corresponds to the error message, if any.


# File 'lib/phaxio/resources/fax.rb', line 50

#error_messageString

Returns a more detailed description of what went wrong for a failed fax.

Returns:

  • (String)

    a more detailed description of what went wrong for a failed fax.


# File 'lib/phaxio/resources/fax.rb', line 46

#error_typeString

Returns one of the Phaxio error types. Will give you a general idea of what went wrong for a failed fax.

Returns:

  • (String)

    one of the Phaxio error types. Will give you a general idea of what went wrong for a failed fax.


# File 'lib/phaxio/resources/fax.rb', line 41

#from_numberString

Returns for received faxes only, the sender's E.164 phone number.

Returns:

  • (String)

    for received faxes only, the sender's E.164 phone number.


# File 'lib/phaxio/resources/fax.rb', line 32

#idInteger

Returns the ID associated with this fax.

Returns:

  • (Integer)

    the ID associated with this fax.


# File 'lib/phaxio/resources/fax.rb', line 8

#is_testtrue | false

Returns an indication of whether or not this is a test fax.

Returns:

  • (true | false)

    an indication of whether or not this is a test fax.


# File 'lib/phaxio/resources/fax.rb', line 23

#num_pagesInteger

Returns the number of pages in the fax.

Returns:

  • (Integer)

    the number of pages in the fax.


# File 'lib/phaxio/resources/fax.rb', line 14

#recipientsPhaxio::Resource::Collection<Phaxio::Resources::FaxRecipient>

Returns a collection of this fax's recipients.

Returns:


77
# File 'lib/phaxio/resources/fax.rb', line 77

has_collection_attributes({recipients: FaxRecipient})

#statusString

Returns the status of the fax.

Returns:

  • (String)

    the status of the fax.


# File 'lib/phaxio/resources/fax.rb', line 20

#tagsHash

Returns a hash of tag name and value pairs. If a fax was sent with tag metadata, it will appear here.

Returns:

  • (Hash)

    a hash of tag name and value pairs. If a fax was sent with tag metadata, it will appear here.


58
59
60
61
# File 'lib/phaxio/resources/fax.rb', line 58

has_normal_attributes %w[
  id direction num_pages cost status is_test caller_id from_number
  to_number error_type error_message error_id tags
]

#to_numberString

Returns for received faxes only, the Phaxio phone number that was used to receive the call.

Returns:

  • (String)

    for received faxes only, the Phaxio phone number that was used to receive the call.


# File 'lib/phaxio/resources/fax.rb', line 36

Class Method Details

.cancel(id, params = {}) ⇒ Phaxio::Resources::Fax::Reference

Cancel a fax.

Parameters:

  • id (Integer)

    The ID of the fax to cancel.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio. This action takes no unique parameters.

Returns:

Raises:

See Also:


195
196
197
198
# File 'lib/phaxio/resources/fax.rb', line 195

def cancel id, params = {}
  response = Client.request :post, cancel_fax_endpoint(id), params
  response_reference response
end

.create(params = {}) ⇒ Phaxio::Resources::Fax Also known as: send

Create and send a fax.

Parameters:

  • params (Hash) (defaults to: {})

    Any parameters to send to Phaxio. At least one to number is required, as well as at least one file or content_url.

    • to [String | Array<String>] - One or more phone numbers in E.164 format where this fax should be sent.

    • file [File | Array<File>] - The fax file(s) to be sent.

    • content_url [String, Array<String>] - URL(s) to be rendered and sent as the fax content. If the file param is included as well, URL content will come first in the transmitted files.

    • header_text [String] - Text that will be displayed at the top of each page of the fax. 50-character maximum. Defaults to “-”.

    • batch_delay [Integer] - Enabled batching and specifies the amount of time, in seconds, before the batch is fired. Max is 3600 (one hour).

    • batch_collision_avoidance [true | false] - When batch_delay is set, the fax will be blocked until the receiving machine is no longer busy.

    • callback_url [String] - You can specify a callback URL that will override one set globally in your account.

    • cancel_timeout [Integer] - Number of minutes after which the fax will be canceled if it hasn't yet completed. Must be between 3 and 60. Additionally, for faxes with batch_delay set, it must be at least 3 minutes after the batch_delay. If not, it will be automatically extended when batching.

    • tag [Hash<String: Object>] - A tag that contains metadata relevant to your application. For example, you may wish to tag a fax with an order id in your application. You could pass Phaxio the following parameter: tag: {order_id: 1234}. You may specify up to 10 tags.

Returns:

Raises:

See Also:


164
165
166
167
# File 'lib/phaxio/resources/fax.rb', line 164

def create params = {}
  response = Client.request :post, faxes_endpoint, params
  response_reference response
end

.delete(id, params = {}) ⇒ true

Delete a fax. May only be used with test API credentials.

Parameters:

  • id (Integer)

    The ID of the fax to delete.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio. This action takes no unique parameters.

Returns:

  • (true)

Raises:

See Also:


225
226
227
228
# File 'lib/phaxio/resources/fax.rb', line 225

def delete id, params = {}
  Client.request :delete, fax_endpoint(id), params
  true
end

.delete_file(id, params = {}) ⇒ true

Delete fax files.

Parameters:

  • id (Integer)

    The ID of the fax for which you want to delete files.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio. This action takes no unique parameters.

Returns:

  • (true)

Raises:

See Also:


239
240
241
242
# File 'lib/phaxio/resources/fax.rb', line 239

def delete_file id, params = {}
  Client.request :delete, fax_file_endpoint(id), params
  true
end

.file(id, params = {}) ⇒ File

Get fax content file or thumbnail.

Parameters:

  • id (Integer)

    The ID of the fax for which you want to get a file.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio.

    • thumbnail [“s” | “l”] - If set to “s” (small) or “l” (large), a thumbnail of the requested size will be returned. If unset, returns a PDF of the fax image.

Returns:

  • (File)

    The requested fax file.

Raises:

See Also:


256
257
258
# File 'lib/phaxio/resources/fax.rb', line 256

def file id, params = {}
  Client.request :get, fax_file_endpoint(id), params
end

.get(id, params = {}) ⇒ Phaxio::Resource::Fax Also known as: retrieve, find

Get fax info.

Parameters:

  • id (Integer)

    The ID of the fax to retrieve information about.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio. This action takes no unique parameters.

Returns:

  • (Phaxio::Resource::Fax)

    The requested fax.

Raises:

See Also:


178
179
180
181
# File 'lib/phaxio/resources/fax.rb', line 178

def get id, params = {}
  response = Client.request :get, fax_endpoint(id.to_i), params
  response_record response
end

.list(params = {}) ⇒ Phaxio::Resource::Collection<Phaxio::Resources::Fax>

Note:

This action accepts paging parameters:

  • per_page [Integer] - The maximum number of results to return per call (i.e. “page”). Max 1000.

  • page [Integer] - The page number to return for the request. 1-based.

List faxes in date range.

Parameters:

  • params (Hash) (defaults to: {})

    Any parameters to send to Phaxio.

    • direction [String] - Either “sent” or “received”. Limits results to faxes with the specified direction.

    • status [String] - Limits results to faxes with the specified status.

    • phone_number [String] - A phone number in E.164 format that you want to use to filter results. The phone number must be an exact match, not a number fragment.

    • tag [Hash<String: String>] - A tag name and value that you want to use to filter results.

Returns:

Raises:

See Also:


124
125
126
127
# File 'lib/phaxio/resources/fax.rb', line 124

def list params = {}
  response = Client.request :get, faxes_endpoint, params
  response_collection response
end

.resend(id, params = {}) ⇒ Phaxio::Resources::Fax::Reference

Resend a fax.

Parameters:

  • id (Integer)

    The ID of the fax to resend.

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio.

    • callback_url [String] - This parameter may be used to set a different callback URL for the new fax.

Returns:

Raises:

See Also:


211
212
213
214
# File 'lib/phaxio/resources/fax.rb', line 211

def resend id, params = {}
  response = Client.request :post, resend_fax_endpoint(id), params
  response_reference response
end

.test_receive(params = {}) ⇒ true

Test receiving a fax. May only be used with test API credentials.

Parameters:

  • params (Hash) (defaults to: {})

    A hash of parameters to send to Phaxio.

    • file [File] - A PDF file to simulate receiving.

    • from_number [String] - The phone number of the simulated sender in E.164 format. Default is the public Phaxio phone number.

    • to_number [String] - The phone number, in E.164 format, that is receiving the fax. Specifically, a Phaxio phone number in your account that is “receiving” the fax, or the public Phaxio phone number. Default is the public Phaxio phone number.

Returns:

  • (true)

Raises:

See Also:


273
274
275
276
# File 'lib/phaxio/resources/fax.rb', line 273

def test_receive params = {}
  Client.request :post, faxes_endpoint, test_receive_params(params)
  true
end