class Phaxio::Resources::Fax
Provides functionality for viewing and managing faxes.
Constants
- FAXES_PATH
Public Class Methods
Cancel a fax. @param id [Integer]
The ID of the fax to cancel.
@param params [Hash]
A hash of parameters to send to Phaxio. This action takes no unique parameters.
@return [Phaxio::Resources::Fax::Reference]
A reference to the canceled fax.
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/cancel
# 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 and send a fax. @param params [Hash]
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.
@return [Phaxio::Resources::Fax]
The created fax.
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/create_and_send_fax @see www.phaxio.com/docs/api/v2/faxes/batching
# File lib/phaxio/resources/fax.rb, line 164 def create params = {} response = Client.request :post, faxes_endpoint, params response_reference response end
Delete a fax. May only be used with test API credentials. @param id [Integer]
The ID of the fax to delete.
@param params [Hash]
A hash of parameters to send to Phaxio. This action takes no unique parameters.
@return [true] @raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/delete_fax
# File lib/phaxio/resources/fax.rb, line 225 def delete id, params = {} Client.request :delete, fax_endpoint(id), params true end
Delete fax files. @param id [Integer]
The ID of the fax for which you want to delete files.
@param params [Hash]
A hash of parameters to send to Phaxio. This action takes no unique parameters.
@return [true] @raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/delete_fax_file
# File lib/phaxio/resources/fax.rb, line 239 def delete_file id, params = {} Client.request :delete, fax_file_endpoint(id), params true end
Get fax content file or thumbnail. @param id [Integer]
The ID of the fax for which you want to get a file.
@param params [Hash]
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.
@return [File]
The requested fax file.
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/get_fax_file
# File lib/phaxio/resources/fax.rb, line 256 def file id, params = {} Client.request :get, fax_file_endpoint(id), params end
Get fax info. @param id [Integer]
The ID of the fax to retrieve information about.
@param params [Hash]
A hash of parameters to send to Phaxio. This action takes no unique parameters.
@return [Phaxio::Resource::Fax] The requested fax. @raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/get_fax
# 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
@macro paging List faxes in date range. @param params [Hash]
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.
@return [Phaxio::Resource::Collection<Phaxio::Resources::Fax>]
The collection of faxes matching your request.
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/list_faxes
# File lib/phaxio/resources/fax.rb, line 124 def list params = {} response = Client.request :get, faxes_endpoint, params response_collection response end
Resend a fax. @param id [Integer]
The ID of the fax to resend.
@param params [Hash]
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.
@return [Phaxio::Resources::Fax::Reference]
A reference to the resent fax.
@raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/resend
# 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 receiving a fax. May only be used with test API credentials. @param params [Hash]
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.
@return [true] @raise [Phaxio::Error::PhaxioError] @see www.phaxio.com/docs/api/v2/faxes/test_receive
# File lib/phaxio/resources/fax.rb, line 273 def test_receive params = {} Client.request :post, faxes_endpoint, test_receive_params(params) true end
Private Class Methods
# File lib/phaxio/resources/fax.rb, line 296 def cancel_fax_endpoint id "#{fax_endpoint(id)}/cancel" end
# File lib/phaxio/resources/fax.rb, line 288 def fax_endpoint id "#{FAXES_PATH}/#{id}" end
# File lib/phaxio/resources/fax.rb, line 292 def fax_file_endpoint id "#{fax_endpoint(id)}/file" end
# File lib/phaxio/resources/fax.rb, line 284 def faxes_endpoint FAXES_PATH end
# File lib/phaxio/resources/fax.rb, line 300 def resend_fax_endpoint id "#{fax_endpoint(id)}/resend" end
# File lib/phaxio/resources/fax.rb, line 280 def response_reference response Reference.new response['id'] end
# File lib/phaxio/resources/fax.rb, line 304 def test_receive_params params {direction: 'received'}.merge(params) end