Class: Telapi::Fax

Inherits:
Resource
  • Object
show all
Defined in:
lib/telapi/fax.rb

Overview

Wraps TelAPI Fax Fax functionality

Class Method Summary collapse

Methods inherited from Resource

#attributes, #initialize

Methods included from Network

api_uri, default_options, delete, post, response_format

Constructor Details

This class inherits a constructor from Telapi::Resource

Class Method Details

.create(to, from, url, optional_params = {}) ⇒ Object

Creates a Fax, returning a Telapi::Fax object See www.telapi.com/docs/api/rest/faxes/send/

Required params:

to

mobile phone number

from

TelAPI or mobile phone number

url

valid URL of the media file to be faxed

Optional params:

status_callback

valid URL

status_callback

(POST) or GET



39
40
41
42
43
# File 'lib/telapi/fax.rb', line 39

def create(to, from, url, optional_params = {})
  opts = { :To => to, :From => from, :Url => url }.merge(optional_params)
  response = Network.post(['Faxes'], opts)
  Fax.new(response)
end

.get(id) ⇒ Object

Returns a specific Telapi::Fax object given its id See www.telapi.com/docs/api/rest/faxes/view/



23
24
25
26
# File 'lib/telapi/fax.rb', line 23

def get(id)
  response = Network.get(['Faxes', id])
  Fax.new(response)
end

.list(optional_params = {}) ⇒ Object

Returns a resource collection containing Telapi::Fax objects See www.telapi.com/docs/api/rest/faxes/list/

Optional params is a hash containing:

To

mobile phone number

From

TelAPI or mobile phone number

StartTime

date in the following format: YYYY-MM-DD

Status

sending, queued, receiving, comm-error, call-dropped

Page

integer greater than 0

PageSize

integer greater than 0



16
17
18
19
# File 'lib/telapi/fax.rb', line 16

def list(optional_params = {})
  response = Network.get(['Faxes'], optional_params)
  ResourceCollection.new(response, 'faxes', self)
end