olsgreen/adobe-sign-api

Adobe Sign client for PHP

0.1 2021-02-05 07:50 UTC

This package is auto-updated.

Last update: 2024-11-05 16:04:22 UTC


README

Latest Version Tests Software License

This package provides a means easily of interacting with the Adobe Sign API v6.

Installation

Add the client to your project using composer.

composer require olsgreen/adobe-sign-api

Usage

The client assumes you have and access token from the Adobe Sign oAuth flow, I have written a separate package to deal with this, see olsgreen/oauth2-adobe-sign.

Create a new API client instance & authenticate

// Create an instance of the client.
$api = new \Olsgreen\AdobeSign\Client($your_access_token, ['data_center' => 'us2']);

Uploading a file

// Upload a document from a path
$transientDocumentId = $api->documents()->uploadFile('/path/to/my/file.pdf');

// Upload a stream, resource or binary data.
$data = fopen('/path/to/my/file.pdf', 'r');
$transientDocumentId = $api->documents()->upload('file.pdf', 'application/pdf', $data);

Building, creating and sending an Agreement using builders

use \Olsgreen\AdobeSign\Api\Builders\Factory;
use \Olsgreen\AdobeSign\Api\Enums\SignatureTypes;
use \Olsgreen\AdobeSign\Api\Enums\AgreementStates;
use \Olsgreen\AdobeSign\Api\Enums\ParticipantRoles;
...

// Create the base agreement object.
$agreement = Factory::createAgreementInfoBuilder()
    ->setName('Test Agreement')
    ->setSignatureType(SignatureTypes::TYPE_ESIGN)
    ->setState(AgreementStates::IN_PROCESS);

// Add the PDF file for signing to the agreement using the 
// $transientDocumentId from the document upload example above.
$agreement->fileInfos()->add(
    Factory::createFileInfoBuilder()
        ->setLabel('Test File')
        ->setTransientDocumentId($transientDocumentId)
);

// Create a participant set for the signer.
$participantSetsInfo = Factory::createParticipantSetInfoBuilder()
    ->setOrder(1)
    ->setRole(ParticipantRoles::SIGNER);

// Add a participant to the set.
$participantSetsInfo->memberInfos()->add(
    Factory::createParticipantInfoBuilder()
        ->setEmail('signer@domain.com')
);

// Add the participant set to the agreement.
$agreement->participantSetsInfo()->add($participantSetsInfo);

// Create the agreement via the API.
$agreementId = $api->agreements()->create($agreement);

Get an Agreements Signing URLs

// Gets the signing URLs from the API.
$urls = $api->agreements()->getSigningUrls($agreementId);

// Will output similar to:
// [
//     ['email' => 'signer1@domain.com', 'esignUrl' => 'https://secure.adobesign.com/sign1'],
//     ['email' => 'signer2@domain.com', 'esignUrl' => 'https://secure.adobesign.com/sign2']
// ]

Create a Webhook

use \Olsgreen\AdobeSign\Api\Builders\WebhookInfoBuilder;
use \Olsgreen\AdobeSign\Api\Enums\WebhookScopes;
use \Olsgreen\AdobeSign\Api\Enums\WebhookEventNames;

...

$webhook = WebhookInfoBuilder::create()
    ->setName('Test Webhook')
    ->setScope(WebhookScopes::USER)
    ->setUrl('https://mydomain.com/hooks/adobe-sign')
    ->setWebhookSubscriptionEvents([
        WebhookEventNames::AGREEMENT_ALL
    ]);

$webhookId = $api->webhooks()->create($webhook);