更新时间:2022-04-13 15:30:37
知道了这个...如果有人感兴趣,请在此处发布.谢谢!
Got this figured out... posting here in case anyone is ever interested. Thank you!
public function send($signer_name,$signer_email, $cc_name, $cc_email, $template_id,$email_subject, $extrapdf = null) {
$this->checkToken();
//create roles for signers
$signer1 = new \DocuSign\eSign\Model\Signer([
'email' => $signer_email, 'name' => $signer_name,
'role_name' => "Signer 1", 'recipient_id' => "1"
]);
$signer2 = new \DocuSign\eSign\Model\Signer([
'email' => $cc_email, 'name' => $cc_name,
'role_name' => "Signer 2", 'recipient_id' => "2"
]);
$recipients_server_template = new \DocuSign\eSign\Model\Recipients([
'signers' => [$signer1,$signer2]]);
//create composite template
$comp_template1 = new \DocuSign\eSign\Model\CompositeTemplate([
'composite_template_id' => "1",
'server_templates' => [
new \DocuSign\eSign\Model\ServerTemplate([
'sequence' => "1", 'template_id' => $template_id])
],
# Add the roles via an inlineTemplate
'inline_templates' => [
new \DocuSign\eSign\Model\InlineTemplate([
'sequence' => "1",
'recipients' => $recipients_server_template])
]
]);
//create new document to be added
$doc1_b64 = base64_encode($extrapdf);
$doc1 = new DocuSign\eSign\Model\Document([
'document_base64' => $doc1_b64,
'name' => 'HomeownershipCounseling', # can be different from
# actual file name
'file_extension' => 'pdf', 'document_id' =>'1']);
$comp_template2 = new DocuSign\eSign\Model\CompositeTemplate([
'composite_template_id' => "2",
# Add the recipients via an inlineTemplate
'inline_templates' => [
new \DocuSign\eSign\Model\InlineTemplate([
'sequence' => "2"])
],
'document' => $doc1]);
//create envelope definition
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
//set email subject on envelope
$envelop_definition->setEmailSubject($email_subject);
$envelop_definition->setCompositeTemplates(array($comp_template1, $comp_template2));
$envelop_definition->setStatus('sent');
//create new instance of envelope API
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi(self::$apiClient);
//go ahead and create the envelope at DocuSign
$results = $envelopeApi->createEnvelope(self::$accountID, $envelop_definition);
//get the created envelope Envelope ID
$envelopeId = $results['envelope_id'];
return $results;
}