forked from eversign/eversign-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-document-from-template.php
35 lines (27 loc) · 1.03 KB
/
create-document-from-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once '../vendor/autoload.php';
$config = require('./config.php');
use Eversign\Client;
use Eversign\DocumentTemplate;
use Eversign\Field;
use Eversign\Signer;
$client = new Client($config['accessKey'], $config['businessId']);
$documentTemplate = new DocumentTemplate();
// $documentTemplate->setSandbox(true);
$documentTemplate->setTemplateId($config['templateId']);
$documentTemplate->setTitle('Form Test');
$documentTemplate->setMessage('Test Message ');
// Create a signer for the document via the role specified in the template
$signer = new Signer();
$signer->setRole('Client');
$signer->setName('John Doe');
$signer->setEmail($config['signerEmail']);
$documentTemplate->appendSigner($signer);
//Fill out custom fields
$field = new Field();
$field->setIdentifier($config['fieldIdentifier']);
$field->setValue('value 1');
$documentTemplate->appendField($field);
//Creating a new Document from a Template
$newlyCreatedDocument = $client->createDocumentFromTemplate($documentTemplate);
echo $newlyCreatedDocument->getDocumentHash();