public
Fork of szimek/efax
Description: Ruby library for accessing the eFax Developer service
Homepage:
Clone URL: git://github.com/drnic/efax.git
efax /
name age message
file .gitignore Sun Sep 20 21:10:50 -0700 2009 add gemspec; using jeweler; bumping to 1.0.0 be... [drnic]
file README.rdoc Thu Oct 08 19:50:15 -0700 2009 README introduces efax_inbound_post helper [radar]
file Rakefile Thu Oct 08 17:04:07 -0700 2009 Added Dr Nic as author [drnic]
file TODO Tue Feb 17 00:12:53 -0800 2009 Added TODO file and changed description [Szymon Nowak]
file VERSION Thu Oct 08 21:39:40 -0700 2009 Version bump to 1.3.2 [radar]
file efax.gemspec Thu Oct 08 21:43:37 -0700 2009 Regenerated gemspec for version 1.3.2 [drnic]
directory lib/ Thu Oct 08 21:39:12 -0700 2009 generated efax_inbound_post result can have any... [radar]
directory test/ Thu Oct 08 21:39:12 -0700 2009 generated efax_inbound_post result can have any... [radar]
README.rdoc

efax

Ruby library for accessing the eFax Developer service (www.efaxdeveloper.com).

Strange class names and their attribute names come from "eFax Developer Universal User Guide for Outbound Processing" document. You can get it on eFax Developer pages or on Scribd (www.scribd.com/doc/5382394/eFax-Developer-Universal-User-Guide-Outbound).

Usage

Outbound Faxes

First you need to provide your account id and credentials:

  EFax::Request.account_id = <your account id>
  EFax::Request.user       = <your login>
  EFax::Request.password   = <your password>

Sending an HTML page using eFax service is pretty simple:

  response = EFax::OutboundRequest.post(recipient_name, company_name, fax_number, subject, content)

The response object has the following attributes:

  response.status_code
  response.doc_id           # unique identifier of your request
  response.error_level
  response.error_message

See EFax::RequestStatus class for details on status codes.

Having ID of your request, you can get its current status:

  response = OutboundRequestStatus.post(doc_id)

The status response has the following attributes:

  response.status_code
  response.message          # "user friendly" status message

See EFax::QueryStatus class for details on status codes.

Inbound Faxes

Inbound faxes work by exposing a URL that EFax can post to when it receives a fax on your account. An example end-point in rails might look like this:

  class InboundFaxesController < AdminController
    def create
      efax = EFax::InboundPostRequest.receive_by_params(params)
      Fax.create(:file => efax.file, :name => efax.name) # etc
      render :text => efax.post_successful_message # This is important to let EFax know you successfully processed the incoming request.
    end
  end

Test Helpers

You can generate a EFax::InboundPostRequest based on optional explicit fields by using a helper method efax_inbound_post:

In your tests:

    require "efax/helpers/inbound_helpers"

    describe InboundFax do
      include EFax::Helpers::InboundHelpers

      it "should create a fax from efax data" do
        person = Person.make
        person.save
        efax = efax_inbound_post(:barcode => person.barcode_number)
        fax = InboundFax.create_from_efax!(efax)
        fax.person.should == person
      end
    end