PHP code example of edmarr2 / d4sign-laravel

1. Go to this page and download the library: Download edmarr2/d4sign-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edmarr2 / d4sign-laravel example snippets

 artisan vendor:publish --tag=d4sign-config

$docs = D4Sign::documents()->find();

$docs = D4Sign::documents()->find("{UUID-DOCUMENT}");

$docs = D4Sign::documents()->safe("{UUID-SAFE}");

$docs = D4Sign::documents()->safe("{UUID-SAFE}");

$docs = D4Sign::documents()->status("{ID-FASE}");

$path_file = '/pasta/arquivo.pdf';
$id_doc = D4Sign::documents()->upload('{UUID-SAFE}', $path_file);

$signers = [
    ["email" => "[email protected]", "act" => '1', "foreign" => '0', "certificadoicpbr" => '0', "assinatura_presencial" => '0', "embed_methodauth" => 'email', "embed_smsnumber" => ''],
    ["email" => "[email protected]", "act" => '1', "foreign" => '0', "certificadoicpbr" => '0',"assinatura_presencial" => '0', "embed_methodauth" => 'sms', "embed_smsnumber" => '+5511953020202']
];

$return = D4Sign::documents()->createList("{UUID-DOCUMENT}", $signers);

$docs = D4Sign::documents()->listSignatures("{UUID-DOCUMENT}");

$message = 'Prezados, segue o contrato eletrônico para assinatura.';
$workflow = 0; //Todos podem assinar ao mesmo tempo;
$skip_email = 1; //Não disparar email com link de assinatura (usando EMBED ou Assinatura Presencial);

$doc = D4Sign::documents()->sendToSigner("{UUID-DOCUMENT}",$message, $skip_email, $workflow);

$docs = D4Sign::documents()->cancel("{UUID-DOCUMENT}");

$email = '[email protected]';
$return = D4Sign::documents()->resend('{UUID-DOCUMENT}', $email);

//Você poderá fazer download do ZIP ou apenas do PDF setando o último parametro.
$url_final = D4Sign::documents()->getFileUrl('{UUID-DOCUMENT}','zip');
//print_r($url_final);

$arquivo = file_get_contents($url_final->url);

//CASO VOCÊ ESTEJA FAZENDO O DOWNLOAD APENAS DO PDF, NÃO ESQUEÇA DE ALTERAR O CONTENT-TYPE PARA application/pdf E O NOME DO ARQUIVO PARA .PDF
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$url_final->name.".zip"."\"");
echo $arquivo;

$webhook = D4Sign::documents()->webhookList("{UUID-DOCUMENT}");

$url = 'http://seudominio.com.br/post.php';
$webhook = D4Sign::documents()->webhookAdd("{UUID-DOCUMENT}",$url);