Skip to content

ruby gem for using the DocuSign REST API with libcurl

License

Notifications You must be signed in to change notification settings

opendoor-labs/docusign_api

Repository files navigation

docusign_api

A simple ruby gem for using the DocuSign REST API with libcurl.

Usage

Add to your Gemfile:

gem 'docusign_api'

Initialize with your credentials, either inline or set a constant called DOCUSIGN

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

Use the API, the DocusignApi instance will return a curb response.

The library will log you in when initialized and will prefix the pathname with the correct endpoint for your account determined by the login process.

Examples:

GET

Get a list of your account's templates

  c = @api.get '/templates'

  puts c.response_code
  puts JSON::parse(c.body)

POST

Create an envelope from a template

  h = {
    emailSubject: email_subject,
    status: 'created',
    templateRoles: [],
    compositeTemplates: [{
      serverTemplates: [
        {
          sequence: '1',
          templateId: template_id
        }
      ],
      document: {
        name: 'document name',
        documentId: document_id,
        documentBase64: Base64.encode64(File.read(pdf)),
        documentFields: [
          { name: 'field1', value: 'value1' },
          { name: 'field2', value: 'value2' }
        ]
      }
    }]
  }

  c = @api.post '/envelopes', h.to_json

  puts c.response_code
  puts JSON::parse(c.body)

PUT

Change envelope recipients

  h = {
    signers: { roleName: 'signer', email: '[email protected]', name: 'Recipient Name', recipientId: '1' }
  }
  c = @api.put '/envelopes/123/recipients', h.to_json

  puts c.response_code
  puts JSON::parse(c.body)

DELETE

Delete envelope recipients

  h = {
    signers: [{ recipientId: '1' }]
  }
  c = @api.delete '/envelopes/123/recipients', h.to_json

  puts c.response_code
  puts JSON::parse(c.body)

DocuSign REST API Docs

https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm

Source Code

This project was created and is maintained by Open Listings Engineering [email protected]

Contributing

Contributions are welcome via pull request. Please write tests, thanks!

About

ruby gem for using the DocuSign REST API with libcurl

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages