No release in over 3 years
Low commit activity in last 3 years
Clicksign webhook engine for rails apps
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Clicksign::Webhooks

Gem Version Build Status Maintainability Test Coverage

To fully understand Clicksign webhooks system, click here

Installation

Add this line to your application's Gemfile:

gem 'clicksign-webhooks'

And then execute:

$ bundle

Or install it yourself as:

$ gem install clicksign-webhooks

Usage

First, mount this engine on your app.

Rails.application.routes.draw do
  ...
  mount Clicksign::Webhooks::Engine => "/clicksign-webhooks"
  ...
end

Depending on your version of rails, use either rails routes -g clicksign-webhooks or rake routes | grep clicksign-webhooks, to see the path:

$ rake routes | grep clicksign-webhooks
Routes for Clicksign::Webhooks::Engine:
 event POST /event(.:format) clicksign/webhooks/events#create

Your rails app able to receive a POST at /clicksign-webhooks/event.

Then create a initializer using a Proc to each possible event:

Clicksign::Webhooks.configure do |config|
  # Setup HMAC
  config.hmac = ENV['CLICKSIGN_HMAC_KEY']

  # You have to setup one Proc for each event
  # Available events are described below
  config.on_upload = ->(event) {
    # Do something with sent event parameters
  }

  # ...
end

The argument event is a Hash:

  {
     "event":{
        "name":"add_signer",
        "data":{
           "user":{
              "email":"...",
              "name":"..."
           },
           "account":{
              "key":"..."
           },
           "signers":[
              {
                 "key":"...",
                 "email":"...",
                 "created_at":"...",
                 "sign_as":"witness",
                 "auths":["email"],
                 "phone_number":"...",
                 "phone_number_hash":"..."
              }
           ]
        },
        "occurred_at":"..."
     },
     "document":{...},
     "signers":[...],
     "events":[{...}]
  }
Available event callbacks:
  • on_upload
  • on_add_signer
  • on_remove_signer
  • on_sign
  • on_close
  • on_auto_close
  • on_deadline
  • on_cancel
  • on_update_deadline
  • on_update_auto_close

Contributing

Feel free to contribute. Pull requests are welcome.

License

The gem is available as open source under the terms of the MIT License.