2017 © Pedro Peláez
 

library eversign-php-sdk

The official PHP SDK Wrapper for the Eversign API

image

eversign/eversign-php-sdk

The official PHP SDK Wrapper for the Eversign API

  • Wednesday, June 27, 2018
  • by eversign
  • Repository
  • 6 Watchers
  • 4 Stars
  • 1,605 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 23 Versions
  • 57 % Grown

The README.md

eversign PHP SDK

eversign PHP SDK is the official PHP Wrapper around the eversign API., (*1)

Quick Links: - Create Document Example - Use Template Example - Document Operations - Create Iframe Signature - Create Iframe Signature From Template - OAuth Flow (start) - OAuth Flow (callback), (*2)

Requirements

  • The latest version of the SDK requires PHP version 7.1 or higher.
  • Installation via Composer is recommended

Installation

  • Install Composer if you haven't already
curl -sS https://getcomposer.org/installer | php
  • Add the eversign PHP SDK as a dependency using the composer.phar CLI:
php composer.phar require eversign/eversign-php-sdk:~1.0

or add it directly to your composer.json, (*3)

{
  "require": {
    "eversign/eversign-php-sdk": "~1.0"
  }
}
  • After installing, you need to require Composer's autoloader
require 'vendor/autoload.php';

Usage

All eversign API requests are made using the Eversign\Client class, which contains all methods for creating, retrieving and saving documents. This class must be initialized with your API access key string. Where is my API access key?, (*4)

Please also specify the ID of the eversign business you would like this API request to affect. Where is my Business ID?, (*5)

$client = new Client("MY_API_KEY", $businessId);

Fetch businesses

Using the getBusinesses() function all businesses on the eversign account will be fetched and listed along with their Business IDs., (*6)

$businesses = $client->getBusinesses();
echo $businesses[0]->getBusinessId();

$client->setSelectedBusiness($businesses[0]);

If you know the businessId beforehand you can also set it with setSelectedBusinessById(businessId), (*7)

$client->setSelectedBusinessById(1337);

Create document from template [Method: Use Template]

To create a document based on an already created template you can use the class Eversign\DocumentTemplate. In order to identify which template should be used, please pass the template's ID into the setTemplateId("MY_TEMPLATE_ID") function., (*8)

Additionally, setTitle() and setMessage() can be used to set a title and message for the newly created document., (*9)

$documentTemplate = new DocumentTemplate();
$documentTemplate->setTemplateId("MY_TEMPLATE_ID");
$documentTemplate->setTitle("Form Test");
$documentTemplate->setMessage("Test Message");

Fill signing roles [Method: Use Template]

A template's signing and CC roles are filled just using the functions below. Each role is identified using the setRole() function, must carry a name and email address and is appended to the document using the appendSigner() function., (*10)

$signer = new Signer();
$signer->setRole("Testrole");
$signer->setName("John Doe");
$signer->setEmail("john.doe@eversign.com");
$documentTemplate->appendSigner($signer);

Saving the document object [Method: Use Template]

Your document object can now be saved using the createDocumentFromTemplate() function. Once this function has been called successfully, your document is created and the signing process is started., (*11)

$newlyCreatedDocument = $client->createDocumentFromTemplate($documentTemplate);
$newlyCreatedDocument->getDocumentHash();

Creating a document [Method: Create Document]

A document is created by instantiating the Eversign\Document object and setting your preferred document properties. There is a series of set methods available used to specify options for your document. All available methods can be found inside our extensive Create Document Example., (*12)

$document = new Document();
$document->setTitle("My Title");
$document->setMessage("My Message");

Adding signers to a document [Method: Create Document]

Signers are added to an existing document object by instantiating the Eversign\Signer object and appending each signer to the document object. Each signer object needs to come with a Signer ID, which is later used to assign fields to the respective signer. If no Signer ID is specified, the appendSigner() method will set a default incremented Signer ID. Each signer object also must contain a name and email address and is appended to the document using the appendSigner() method., (*13)

$signer = new Signer();
$signer->setId("1");
$signer->setName("John Doe");
$signer->setEmail("john.doe@eversign.com");
$document->appendSigner($signer);

Adding recipients (CCs) to a document [Method: Create Document]

Recipients (CCs) are added by instantiating the Eversign\Recipient object and appending each recipient to the document object. Just like signers, recipients must carry a name and email address., (*14)

$recipient = new Recipient();
$recipient->setName("John Doe");
$recipient->setEmail("john.doe@eversign.com");
$document->appendRecipient($recipient);

Adding files to the Document [Method: Create Document]

Files are added to a document by instantiating an Eversign\File object. The standard way of choosing a file to upload is appending the file's path using the setFilePath() method and then appending your file using the appendFile() method., (*15)

Uploading a file is mandatory without which the createDocument method will fail. As an alternative you may upload a blank PDF and add 'note' or 'text' field types., (*16)

$file = new File();
$file->setName("My File");
$file->setFilePath(getcwd() . "/file.pdf");
$document->appendFile($file);

Adding fields [Method: Create Document]

There is a number of fields that can be added to a document, each coming with different options and parameters. (View Full list of fields »), (*17)

A field is appended to the document using the appendFormField($signatureField, $fileIndex) method. The first function parameter is the field object, and the second parameter must contain the index of the file it should be added to. If your field should be placed onto the first uploaded file, set this parameter to 0. This parameter also default to 0., (*18)

Signature and Initials fields are required to be assigned to a specific signer. Fields are assigned to a signer by passing the Signer ID into the setSigner() function., (*19)

$signatureField = new SignatureField();
$signatureField->setFileIndex(0);
$signatureField->setPage(2);
$signatureField->setX(30);
$signatureField->setY(150);
$signatureField->setRequired(true);
$signatureField->setSigner("1");
$document->appendFormField($signatureField, $fileIndex);

A full example containing instructions and methods for each available field type can be found here: Create Document Example, (*20)

Available field types, (*21)

Please find below all available field types:, (*22)

Field Type Class
date_signed Eversign\DateSignedField
signature Eversign\SignatureField
initials Eversign\InitialsField
note Eversign\NoteField
text Eversign\TextField
checkbox Eversign\CheckboxField
radio Eversign\RadioField
dropdown Eversign\DropdownField
attachment Eversign\AttachmentField

Saving a document [Method: Create Document]

A document is saved and sent out by passing the final document object into the createDocument method. The API will return the entire document object array in response., (*23)

$newDocument = $client->createDocument($document);
$newDocument->getDocumentHash();

Loading a document

Class: Document, (*24)

A document is loaded by passing its document hash into the getDocumentByHash() method., (*25)

$document = $client->getDocumentByHash("MY_HASH");

Downloading the raw or final document

Class: Client, (*26)

A document can be downloaded either in its raw or in its final (completed) state. In both cases, the respective method must contain the document object and a path to save the PDF document to. When downloading a final document, you can choose to attach the document's Audit Trail by setting the third parameter to true., (*27)

$client->downloadFinalDocumentToPath($document, "final.pdf", $attachAuditTrail);
$client->downloadRawDocumentToPath($document, "raw.pdf");

Get a list of documents or templates

Class: Client, (*28)

The Client class is also capable fo listing all available documents templates based on their status. Each method below returns an array of document objects., (*29)

$client->getAllDocuments();
$client->getCompletedDocuments();
$client->getDraftDocuments();
$client->getCanceledDocuments();
$client->getActionRequiredDocuments();
$client->getWaitingForOthersDocuments();

$client->getTemplates();
$client->getArchivedTemplates();
$client->getDraftTemplates();

Delete or cancel a document

Class: Client, (*30)

A document is cancelled or deleted using the methods below., (*31)

$client->deleteDocument($document);
$client->cancelDocument($document);

Contact us

Any feedback? Please feel free to contact our support team., (*32)

Development

# Install composer dependencies
docker run --rm -v $(pwd):/app composer/composer install

# run docker compose
docker-compose up -d

# point your browser to localhost:8080
curl http://localhost:8080

# run tests
docker-compose exec eversign-sdk-php vendor/bin/phpunit sdk/Eversign/Test/ClientTest.php --colors=never

The Versions

27/06 2018

dev-master

9999999-dev

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

27/06 2018

1.10.1

1.10.1.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

04/06 2018

1.10.0

1.10.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

01/06 2018

1.9.0

1.9.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

25/04 2018

1.8.0

1.8.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

24/04 2018

1.7.1

1.7.1.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

31/01 2018

1.7.0

1.7.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

31/01 2018

1.6.0

1.6.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

05/12 2017

1.5.0

1.5.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

04/12 2017

1.4.2

1.4.2.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

10/11 2017

1.4.1

1.4.1.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

03/11 2017

1.4.0

1.4.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

03/11 2017

dev-feature/oauth

dev-feature/oauth

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

03/11 2017

1.3.0

1.3.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

02/11 2017

1.2.0

1.2.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

02/11 2017

dev-feature/iframe

dev-feature/iframe

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

02/11 2017

dev-feature/set-selected-business-by-id

dev-feature/set-selected-business-by-id

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

10/07 2017

1.1.0

1.1.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

30/06 2017

1.0.2

1.0.2.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

26/06 2017

v1.0.1

1.0.1.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

26/06 2017

dev-bugfix/error-array-key

dev-bugfix/error-array-key

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

12/05 2017

v1.0.0

1.0.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

The Development Requires

by apilayer
by Patrick Leeb

04/05 2017

v0.1.0

0.1.0.0

The official PHP SDK Wrapper for the Eversign API

  Sources   Download

MIT

The Requires

 

by apilayer
by Patrick Leeb