A simple ruby gem for using the DocuSign REST API with libcurl.
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 a list of your account's templates
c = @api.get '/templates'
puts c.response_code
puts JSON::parse(c.body)
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)
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 envelope recipients
h = {
signers: [{ recipientId: '1' }]
}
c = @api.delete '/envelopes/123/recipients', h.to_json
puts c.response_code
puts JSON::parse(c.body)
https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm
This project was created and is maintained by Open Listings Engineering [email protected]
Contributions are welcome via pull request. Please write tests, thanks!