Build Status Coverage Status

The Infusionsoft Ruby Gem

A Ruby wrapper for the Infusionsoft API

update notes

  • v1.3.5 - Rest API is now supported (documentation incoming)
  • v1.2.2 - Catching Infusionsoft API SSL handshake issues
  • v1.2.1 - Added OAuth support
  • v1.2.0 - Added invoice_add_subscription call to mirror Infusionsoft API parameters to eventually replace invoice_add_recurring_order
  • maybe?? - Going to add Infusionsoft API authentication Oauth flow. Also, I'm thinking of rewriting parts of it to make the calls more user friendly and adding some convenience methods. If you have any suggestions, let me know.
  • 07/21/2015 - Implementation of tests and build/coverage (Thanks! @TheMetalCode)
  • v1.1.8 - Added a default user-agent in the headers. Also, give the ability to set your own user-agent in the config block.
  • v1.1.5 - Added a custom logger option. This will allow you to track all api calls/results in a separate log file. Defaults to $stdout if none is specified. To add logger specify api_logger in your config block.

Installation

gem install infusionsoft

Documentation

http://rubydoc.info/gems/infusionsoft

Setup & Configuration

  1. Rails 2.3 - add config.gem 'infusionsoft' Rails >= 3 - add 'infusionsoft' to your Gemfile
  2. Enable the API on your Infusionsoft account (if you haven't already) and generate your API Key: See Infusionsoft Doc
  3. Then create an initializer in config\initializers called infusionsoft.rb and the following
# Added to your config\initializers file
Infusionsoft.configure do |config|
  config.api_url = 'YOUR_INFUSIONSOFT_URL' # example infused.infusionsoft.com DO NOT INCLUDE https://
  config.api_key = 'YOUR_INFUSIONSOFT_API_KEY'
  config.api_logger = Logger.new("#{Rails.root}/log/infusionsoft_api.log") # optional logger file
end

OAUTH 2.0

You will need to handle and obtain the access_token on your own.

# You will need to attain the access_token first, then do the config like so:
Infusionsoft.configure do |config|
  config.use_oauth = true
  config.api_url = 'api.infusionsoft.com' # do not include https://
  config.api_key = 'ACCESS_TOKEN' # access_token
  config.api_logger = Logger.new("#{Rails.root}/log/infusionsoft_api.log") # optional logger file
end

Usage Examples

# Get a users first and last name using the DataService
Infusionsoft.data_load('Contact', contact_id, [:FirstName, :LastName])

# Get a list of custom fields
Infusionsoft.data_find_by_field('DataFormField', 100, 0, 'FormId', -1, ['Name'])
# Note, when updating custom fields they are case sensisitve and need to be prefaced with a '_'

# Update a contact with specific field values
Infusionsoft.contact_update(contact_id, { :FirstName => 'first_name', :Email => '[email protected]' })

# Add a new Contact
Infusionsoft.contact_add({:FirstName => 'first_name', :LastName => 'last_name', :Email => '[email protected]'})

# Create a blank Invoice
invoice_id = Infusionsoft.invoice_create_blank_order(contact_id, description, Date.today, lead_affiliate_id, sale_affiliate_id)

# Then add item to invoice
Infusionsoft.invoice_add_order_item(invoice_id, product_id, product_type, amount, quantity, description_here, notes)

# Then charge the invoice
Infusionsoft.invoice_charge_invoice(invoice_id, notes, credit_card_id, merchange_id, bypass_commissions)

Contributing

In the spirit of free software, everyone is encouraged to help improve this project.

Here are some ways you can contribute:

  • by using alpha, beta, and prerelease versions
  • by reporting bugs
  • by suggesting new features
  • by writing or editing documentation
  • by writing specifications
  • by writing code (no patch is too small: fix typos, add comments, clean up inconsistent whitespace)
  • by refactoring code
  • by closing issues
  • by reviewing patches

Submitting an Issue

We use the GitHub issue tracker to track bugs and features.

Supported Rubies

This library aims to support the following Ruby implementations:

If something doesn't work on one of these interpreters, it should be considered a bug.

This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be personally responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.

Todos

  • Need to fully implement testing
  • Need to add a history log for additional contributers

Copyright (c) 2019 Nathan Leavitt

See MIT LICENSE for details.