Code Monkey home page Code Monkey logo

hello_sign's Introduction

HelloSign

A Ruby interface to the HelloSign API.

Gem Version Build Status Dependency Status Code Climate Coverage Status

Installation

gem install hello_sign

Configuration

HelloSign uses the HTTP Basic Access Authentication scheme to authenticate API users.

To configure the client, simply execute the following with your credentials:

HelloSign.configure do |hs|
  hs.email_address = '[email protected]'
  hs.password      = 'hal_9000'
end

Those credentials will be used when making each request that requires authentication.

Thread safety

Applications that make requests on behalf of multiple HelloSign users should avoid global configuration. Instead, instantiate a client directly.

hello_sign = HelloSign::Client.new(email_address: '[email protected]', password: 'hal_9000')

A client instantiated in this way responds to the same methods as the HelloSign constant.

Usage

All JSON-encoded responses from the HelloSign API are converted to a hash equivalent with symbols for keys before being returned.

Create an account

HelloSign.account.create(email_address: '[email protected]', password: 'hal_9000')

Authentication is not required to make this request.

Fetch account settings

HelloSign.account.settings.show

Update account settings

HelloSign.account.settings.update(callback_url: 'https://callmemaybe.com')

Send a request

HelloSign.signature_request.deliver do |request|
  request.title   = 'Contract'
  request.subject = 'Here is the contract for you to sign!'
  request.message = 'You should definitely sign this.'
  request.ccs     = ['[email protected]', '[email protected]']
  request.signers = [
    {name: 'Jack', email_address: '[email protected]'},
    {name: 'Jill', email_address: '[email protected]'}
  ]
  request.files   = [
    {filename: 'path/to/contract.pdf'},
    {filename: 'details.txt', io: text_file},
    {filename: 'path/to/directions.txt', mime: 'text/xml'},
    {io: image, mime: 'image/jpeg'}
  ]
end
Specifying files

There are a couple ways to specify a file when sending a signature request:

  • Provide a path to the file's location on disk using filename.
  • Pass a Ruby IO object using io (e.g. text_file and image above).

Other things to keep in mind:

  • If a filename isn't provided, a generic one will be inferred.
  • If no mime key is specified, the MIME type will be inferred by the file extension. If a MIME type cannot be inferred, it will default to text/plain.
  • When using any method of file specification, the MIME type can always be overriden using the mime key.

Send a request using a reusable form

HelloSign.signature_request.deliver(form: 'form_id') do |request|
  request.title         = 'Contract'
  request.subject       = 'Here is the contract for you to sign!'
  request.message       = 'You should definitely sign this.'
  request.ccs           = [
    {email_address: '[email protected]', role: 'lawyer'},
    {email_address: '[email protected]', role: 'accountant'}
  ]
  request.signers       = [
    {name: 'Jack', email_address: '[email protected]', role: 'consultant'},
    {name: 'Jill', email_address: '[email protected]', role: 'client'}
  ]
  request.custom_fields = [
    {name: 'cost', value: '$20,000'},
    {name: 'time', value: 'two weeks'}
  ]
end

Fetch the status on a request

HelloSign.signature_request('abc123').status

Fetch a list of all requests

HelloSign.signature_request.list
HelloSign.signature_request.list(page: 5)

Defaults to page one when no page number is provided.

Send a reminder

HelloSign.signature_request('abc123').remind(email_address: '[email protected]')

Cancel a request

HelloSign.signature_request('abc123').cancel

Fetch a final copy

HelloSign.signature_request('abc123').final_copy

Fetch a list of all forms

HelloSign.reusable_form.list
HelloSign.reusable_form.list(page: 5)

Defaults to page one when no page number is provided.

Fetch details on a form

HelloSign.reusable_form('abc123').show

Grant access to a form

HelloSign.reusable_form('abc123').grant_access(email_address: '[email protected]')
HelloSign.reusable_form('abc123').grant_access(account_id: '123456')

Revoke access to a form

HelloSign.reusable_form('abc123').revoke_access(email_address: '[email protected]')
HelloSign.reusable_form('abc123').revoke_access(account_id: '123456')

Create a team

HelloSign.team.create(name: 'The Browncoats')

Fetch team details

HelloSign.team.show

Update team details

HelloSign.team.update(name: 'The Reavers')

Delete a team

HelloSign.team.destroy

Add a member to the team

HelloSign.team.add_member(email_address: '[email protected]')
HelloSign.team.add_member(account_id: '123456')

Remove a member from the team

HelloSign.team.remove_member(email_address: '[email protected]')
HelloSign.team.remove_member(account_id: '123456')

Create a draft

HelloSign.unclaimed_draft.create do |draft|
  draft.files = [
    {filename: 'path/to/test.txt'},
    {filename: 'test.jpg', io: image}
  ]
end

See the related notes on specifying files.

When an error is returned from the HelloSign API, an associated exception is raised.

Supported Ruby interpreters

This gem officially supports and is tested against the following Ruby interpreters:

  • MRI 1.9.2
  • MRI 1.9.3
  • MRI 2.0.0
  • JRuby in 1.9 mode
  • Rubinius in 1.9 mode

Contributing

Pull requests are welcome, but consider asking for a feature or bug fix first through the issue tracker. When contributing code, please squash sloppy commits aggressively and follow Tim Pope's guidelines for commit messages.

Copyright

Copyright (c) 2013 Craig Little. See LICENSE for details.

hello_sign's People

Contributors

craiglittle avatar jgarber avatar

Watchers

 avatar  avatar  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.