Skip to content

Instantly share code, notes, and snippets.

@bbhoss
Created July 27, 2012 23:09
Show Gist options
  • Save bbhoss/3190943 to your computer and use it in GitHub Desktop.
Save bbhoss/3190943 to your computer and use it in GitHub Desktop.
Quick library that uses HTTParty to talk to the Interfax faxing service.
# MIT License
class Interfaxer
include HTTParty
base_uri "https://rest.interfax.net"
headers 'Content-Type' => 'application/pdf'
def initialize(username, password)
self.class.basic_auth(username, password)
end
# Sends a fax to interfax
def deliver_fax(recipient, subject, body)
options = {body: body, query: {faxNumber: recipient, contact: subject, pageOrientation: 'portrait', fitToPage: 'scale'}}
response = self.class.post('/outbound/faxes', options)
if response.success?
response.headers['location'].split('/')[-1]
else
raise "Failed to send fax"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment