Created
July 27, 2012 23:09
-
-
Save bbhoss/3190943 to your computer and use it in GitHub Desktop.
Quick library that uses HTTParty to talk to the Interfax faxing service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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