Our DocuSign REST API gem is now open source

Here at Open Listings, we're fixing all of the manual, mistake-ridden processes that go into purchasing a home.

While e-signing makes the process easy for our users, it's tedious for our support team to repeatedly prepare and send documents. By automating it we free up our support team, remove unnecessary delays, and prevent potential errors.

Because our team was already using DocuSign, we decided to integrate with the DocuSign API to begin sending frequently-generated documents with the click of a button.

YADSAG?? - Yet another DocuSign API gem?

Surveying the landscape, there are plenty of ruby gems out there for integrating with the DocuSign API, but we had a hard time finding one that fit what we were looking for.

  • REST not SOAP. We have our fill of SOAP in our stack with the work we do with MLS systems. We'd rather be stateless where possible and REST just makes sense when working over HTTP.

  • Not a DSL. The DocuSign API clearly has some hard edges and is clunky in places. We'd rather not add to the complexity by also having to learn a domain specific language defined by the gem, we already know how to write JSON. It can be especially hard to debug when something is going wrong under the hood when we're another layer abstracted from their API. The DocuSign API is at least thoroughly documented, as opposed to some of the DSL's defined by these gems. And if a new API endpoint is introduced, we don't want to wait for a method to be implemented by the gem or to have to guess how the endpoint name maps to a method name in the DSL.

  • libcurl not net/http. We've found libcurl more reliable in production than net/http and the gems that use net/http require a patched version to embed documents directly into the JSON of the POST body. We didn't have to patch libcurl to get it to do what we needed.

  • Simple and small. Our gem is really straightforward and the meat of it is only about 100 lines of code. You can get authentication working and start developing really quickly.

Getting started

Require the gem in your Gemfile if you're using Rails

require 'docusign_api'  

Make a new instance of DocusignApi with your API credentials:

@api = DocusignApi.new \
  username: 'USER', \
  password: 'PASS', \
  integrator_key: 'KEY', \
  login_url: 'https://demo.docusign.net/restapi/v2/login_information'

You can also create a constant DOCUSIGN that is a hash of these, and the gem will find them there.

If you don't have an integrator key already, you can create one on the DocuSign website for your developer account, in the Admin section, under the "Integrations" heading, by clicking on the "API and Keys" link.

Note that the login url will change from the demo.docusign.net subdomain to one of DocuSign's production domains they will assign you once your integration has been certified.

When you create an instance with these credentials, the gem will automatically login to DocuSign and get your account information to set the base path for your future interactions with the API.

Then you can go ahead and start developing against the API using the exposed http verb methods, e.g.:

response = @api.get '/templates'  

The gem returns a Curl::Easy object.

> response.response_code

> JSON::parse(response.body)
More info