npm.io
1.8.0 • Published 9 years ago

yousign-nodejs-api-wrapper

Licence
MIT
Version
1.8.0
Deps
0
Vulns
0
Weekly
0
Stars
1

YouSign-NodeJS-API-Wrapper

A Node.js API client for the YouSign signature API. Works as a wrapper around the Yousign PHP API client

The original PHP Api : https://github.com/Yousign/yousign-api-client-php

Usage:

  1. Get a recent Node.js version (with ES6 support)
  2. Install PHP (version 7+ recommended). Make it so that you can run php by typing "php" in terminal
  3. Install this module into your project
npm i yousign-nodejs-api-wrapper --save
  1. Copy example_ysApiParameters.ini in the module's folder into your project root, rename it to ysApiParameters.ini
  2. Set your Yousign credentials into the file. Please note that if isEncryptedPassword = true your password must be in the following format : sha1(sha1(YOUR_PASSWORD)+sha1(YOUR_PASSWORD)) (with + being a concat operator). Otherwise set the boolean to false and just leave it as clear text. But that's bad mkay.
  3. Import the index.js module into your project
  4. Call the checkAuth() function (all functions are promise-based, so you can do .then and .catch on it

How to list signatures:

var ysAPIWrapper = require('yousign-nodejs-api-wrapper')

ysAPIWrapper.listSignatures("jean@dubois.org").then((res)=>{
    console.log(res)
}).catch((err)=>{
    console.error(err)
})

Available functions :

checkAuth()

Checks if the YouSign API is up and if our credentials are valid

initSignature(filesToSign, firstName, lastName, email, phone, signatures, userSuccessRedirectUrl, userCancelRedirectUrl, onSignatureStatusChangedUrl)string | object

Inits a signature and returns the url of the signing page

downloadSignaturesFiles(search, absoluteOutFolderPath)

Downloads all the files in the signature process corresponding to the search parameter provided

listSignatures(email)

Lists the existing signatures and the corresponding statuses for an email

checkAuth()

Checks if the YouSign API is up and if our credentials are valid

Kind: global function

initSignature(filesToSign, firstName, lastName, email, phone, signatures, userSuccessRedirectUrl, userCancelRedirectUrl, onSignatureStatusChangedUrl) ⇒ string | object

Inits a signature and returns the url of the signing page

Kind: global function Returns: string - iframeUrl - the url of the iframe to do the signatureobject - details - details of the signature, contains de demand ID which can be used later on

Param Type Description
filesToSign array An array of absolute paths to the documents that you wish to sign. Example : [/Users/joe/document1.pdf, /Users/joe/document2.pdf] Alternatively, you can send a string if you only have one file to sign Example : document1.pdf
firstName string Firstname of the person that will sign
lastName string Lastname of the person that will sign
email string Email of the person that will sign
phone string Phone of the person that will sign, including prefix (+33...). Must be a real Phone number as the user will receive an SMS confirmation code.
signatures array An array of objects, each object containing the following data for a signature : page, document number, pixel coordinates of the rectangle where it will appear. Example for two signatures on page 2 and 4 on the first document of the filesToSign, and on page 2 of the second document: [{rectangleCoords: "337,59,572,98", page:"2", document:"1"}, {rectangleCoords: "337,193,572,232", page:"4", document:"1"}, {rectangleCoords: "100,200,300,400", page:"2", document:"2"}], If you only have one signature, and want to put on page 1 of first document, you can send only a string of coordinates instead of an array : "337,59,572,98"
userSuccessRedirectUrl string A url where the user will be redirected to after he signs
userCancelRedirectUrl string A url where the user will be redirected to after he cancels the signature process
onSignatureStatusChangedUrl string The YouSign server will send GET requests to this url when the signature status changes. Statuses can be : init, cancel, waiting, signed, signed_complete

downloadSignaturesFiles(search, absoluteOutFolderPath)

Downloads all the files in the signature process corresponding to the search parameter provided

Kind: global function

Param Type Description
search string The YouSign search parameters. This can be the email of the person who signed, the filename... Example : john@test.com - will download all the files in a signature process with john@test.com
absoluteOutFolderPath string An absolute path to the output folder for the downloaded files (without trailing /) Example : /Users/joe/out - the folder MUST already exist and be writeable

listSignatures(email)

Lists the existing signatures and the corresponding statuses for an email

Kind: global function

Param Type Description
email string Email of the person whose signatures we want to get

Keywords