Skip to content

The Official SignNow PHP SDK library for interacting with SignNow REST API. Sign documents, request e-signatures, and build role-based workflows with multiple signers using this client.

License

Notifications You must be signed in to change notification settings

WeAreSweet/SignNowPHPSDK

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SignNow API PHP Client

Simple API Client to integrate SignNow with your application or website. Sign documents, request e-signatures, and build role-based workflows with multiple signers: https://www.signnow.com/developers

Table of Contents

  1. Requirements
  2. Install
  3. Setting up
  4. Entity manager
  5. Examples & use cases

Requirements

PHP 7.1 or newer

Install

composer require signnow/api-php-sdk

Setting up

Register an annotation loader:

AnnotationRegistry::registerLoader('class_exists');

Prepare options for the Guzzle client. We recommend the following configuration:

$stack = HandlerStack::create();
$stack->setHandler(new CurlMultiHandler());
$stack->push(new AuthorizationMiddleware(new BasicToken($token))));
$stack->push(new ResponseCheckerMiddleware());
$options = [
    'base_uri'        => $host,
    'headers'         => ['Content-Type' => 'application/json'],
    'connect_timeout' => 30,
    'request_timeout' => 30,
    'handler'         => $stack,
];

Or you can use builder for configuring the default options:

$options = (new OptionBuilder())
    ->setUri($uri)
    ->useAuthorization($token)
    ->getOptions();

Create the instance of Entity Manager:

$entityManager = (new EntityManagerFactory())->createEntityManager($options);

Setup update http method for Entity Manager:

$entityManager->setUpdateHttpMethod(Request::METHOD_PUT);

Entity manager

Entity manager is the main class which controls communication with 3rd party REST API where JSON is used as main data type. It's responsible for saving objects to and fetching objects from the API.

Each entity is described by:

  • API resource url (via HttpEntity annotation),
  • API payload (via properties and theirs types),
  • API response type (via ResponseType annotation, optional).

Examples & use cases

Upload Document to SignNow

$uploadFile = (new Document\Upload(new \SplFileInfo('realFilePath')));
$document = $entityManager->create($uploadFile);

Download Document from SignNow

$document = $entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed']);

OAuth 2.0

Request Access Token

$entityManager->create(new TokenRequestPassword($username, $password));

Verify Access Token

$entityManager->get(Token::class);

Refresh Access Token

$entityManager->create(new TokenRequestRefresh($refresh_token));

Document

Upload document

$entityManager->create(new Document\Upload(new \SplFileInfo($filePath)));

Upload document with text tags & convert them to fillable fields

$entityManager->create(new Document\FieldExtract(new \SplFileInfo($filePath)));

Retrieve document

$entityManager->get(Document\Document::class, ['id' => $document_id]);

Delete document

$entityManager->delete(Document\Document::class, ['id' => $document_id]);

Download document

$entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed']);
// type can be 'collapsed' or 'zip' 

// if need table containing the document's history set with_history=1
$entityManager->get(Document\Download::class, ['id' => $document_id], ['type' => 'collapsed', 'with_history' => 1]);

Create a single-use link for document downloading

$entityManager->create(new Document\DownloadLink(), ['id' => $document_id])

Create a role-based invite to sign a document

$to[] = new Recipient($recipient_email, $role, $roleId, $order);
$invite = new Invite($email, $to, $cc);
$entityManager->create($invite, ['documentId' => $document_id]);

Create a simple free form invite to sign a document

$invite = (new Invite())
            ->setDocumentId($document_id)
            ->setTo($to)
            ->setFrom($from)
            ->setCc([])
            ->setSubject($subject)
            ->setMessage($message);
              
$entityManager->create($invite, ["documentId" => $document_id]);

Cancel an invite to sign a document

$entityManager
    ->setUpdateHttpMethod(Request::METHOD_PUT)
    ->update(new CancelInvite(), ['documentId' => $document_id]);

Create a signing link

$entityManager->create(new SigningLink($document_id));

Add fillable fields to a document

$signature = (new SignatureField())
    ->setName('My Signature')
    ->setPageNumber(0)
    ->setRole('role 1')
    ->setRequired(true)
    ->setHeight(20)
    ->setWidth(10)
    ->setX(5)
    ->setY(10);

$text = (new TextField())
    ->setName('My text')
    ->setLabel('Some label')
    ->setPrefilledText('prefilled text')
    ->setPageNumber(0)
    ->setRole('role 1')
    ->setRequired(true)
    ->setHeight(20)
    ->setWidth(10)
    ->setX(100)
    ->setY(150);

$document = (new Document\Document())
    ->setId($document_id)
    ->setFields([$signature, $text]);
               
$entityManager->update($document);

Template

Create a template

$template = (new Template\Template())
    ->setDocumentId($document_id)
    ->setDocumentName($document_name);
 
$entityManager->create($template);

Generate a document from template (Copy template)

$templateCopy = (new Template\Copy())
        ->setTemplateId($template_id)
        ->setDocumentName($document_name);

$entityManager->create($templateCopy);

Document group

Retrieve document group

$entityManager->get(DocumentGroup\DocumentGroup::class, ['id' => $document_group_id])

Delete document group

$entityManager->delete(DocumentGroup\DocumentGroup::class, ['id' => $document_group_id])

Cancel document group invite

$entityManager->create(
    new DocumentGroup\GroupInvite\Cancel(),
    [
        'documentGroupId' => $documentGroupId,
        'groupInviteId' => $groupInviteId
    ]
);

Event subscriptions

Get User Event Subscriptions

$entityManager->get(new EventSubscription\GetEventSubscriptions());

Create User Event Subscription

$entityManager->create(
    (new EventSubscription\CreateEventSubscription())
    ->setEvent('document.update')
    ->setCallbackUrl('https://google.com.ua')
);

Delete User Event Subscription

$entityManager->delete(
    new EventSubscription\DeleteEventSubscription(),
    ['uniqueId' => $uniqueId]
);

About

The Official SignNow PHP SDK library for interacting with SignNow REST API. Sign documents, request e-signatures, and build role-based workflows with multiple signers using this client.

https://www.signnow.com/developers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%