Giter VIP home page Giter VIP logo

sfax's Introduction

SFax Ruby Gem Build Status

What does this gem do?

This gem is a ruby wrapper around the SFax API. With this gem, you can easily send and receive electronic faxes.

Installation

Add this line to your application's Gemfile:

gem 'sfax'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sfax

Usage

First and foremost, you need to sign up for an SFax account here and generate your credentials here.

After that, you can initialize the Faxer class as:

# All four fields are necessary.
# Username and api_key are used for fax processing.
# Vector and encryptiong_key are used for securing posted url.
SFax::Faxer.new(username, api_key, vector, encryption_key)

After this there are four main methods: send_fax, fax_status, receive_fax and download_fax.

send_fax accepts a file and a fax_number in the following format: +1xxxxxxxxxx. File can be a Tempfile or a url. If fax is successfully initiated, send_fax returns fax_id (a 32-digit alphanumeric id) which can be used to track the fax status.

fax_status accepts a fax_id which is returned from send_fax and returns the status of the fax with fax_id.

receive_fax accepts count, which is the number of faxes to be received. SFax returns 500 (maximum) faxes at a time, so count is capped at 500. receive_fax returns two values: If there are any received faxes, it returns an array of fax ids to be downloaded. If there are more faxes to be received, receive_fax also returns true. Otherwise it returns false along with the array of ids.

download_fax accepts a fax_id and returns the contents of the fax to be written to a file.

Best Practices

At PatientBank, we use this gem to make calls to the SFax API via jobs. While sending faxes are triggered via the user, we use cron jobs to regularly check if there are any received faxes.

For development environment, it is important to not send or receive faxes from your main fax number. One workaround is to create a new fax number (and its respective API credentials) for use in development machines.

Resources

The Basics

Generating API Credentials

SFax Sign up

Credits

This gem is inspired by the sample code SFax provides to its developers.

Contributing

  1. Fork it (https://github.com/[my-github-username]/sfax/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

sfax's People

Contributors

rswolff avatar mertcelebi avatar klinskyc avatar melnikovsansan avatar

Watchers

Dmytro Savochkin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.