Я не очень опытный программист, и мне было очень трудно заставить интеграцию DocuSign API работать так, как хотел мой клиент.Моя проблема заключалась в том, чтобы найти стабильное решение для повторной отправки контракта тому же Получателю в случае его потери.Мне потребовалось некоторое время, чтобы найти что-то, что всегда будет создавать новое электронное письмо, а не только время от времени.В моем случае добавление заметки сделало трюк.
Вот код на тот случай, если кто-нибудь может его использовать:
class DocuSignSample
{
public function ResendEmail($args)
{
global $docusign_args;
$username = $docusign_args['username'];
$password = $docusign_args['password'];
$integrator_key = $docusign_args['integrator_key'];
// change to production (www.docusign.net) before going live
$host = $docusign_args['host'];
// create configuration object and configure custom auth header
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
$accountId = null;
try
{
//*** STEP 1 - Login API: get first Account ID and baseURL
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object
$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)
$apiClient = new DocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
// Set Up Recipient Data, Update note with current date
$Recipient = new \stdClass();
$Recipient->RecipientId='1'; // In my case it is always No. 1
$Recipient->Email=$args['signer_email'];
$Recipient->name=$args['signer_name'];
$Recipient->Note='Resent on '.date("d.m.Y")." at ".date("H:i:s");
// Set Up Options - Put Recipients in Array
$options->Signers[] = $Recipient;
$options->resend_envelope='true';
$options->status='signed';
$options=json_encode($options);
// Update the Envelope Recipients
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
$results = $envelopeApi->updateRecipients($accountId, $args['envelope_id'],$options);
// Get Envelope Recipients Details
$results2 = $envelopeApi->listRecipients($accountId, $args['envelope_id']);
echo "<br><br>";
print_r($results2);
if(!empty($results))
{
return "$results";
}
}
}
}
}
catch (DocuSign\eSign\ApiException $ex)
{
$error= $ex->getResponseBody()->errorCode . " " . $ex->getResponseBody()->message;
echo "$error";
}
}
}