Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Last active November 5, 2025 12:47
Show Gist options
  • Save IgorDePaula/a8f837d0710d16233fc698432b28f515 to your computer and use it in GitHub Desktop.
Save IgorDePaula/a8f837d0710d16233fc698432b28f515 to your computer and use it in GitHub Desktop.
Service class for Clicksign
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class Clicksign
{
private $type = 'application/vnd.api+json';
private $documentsUrl = "envelopes/#/documents";
private $envelopesEditUrl = "envelopes/#";
private $envelopesSignWatcher = "envelopes/#/signature_watchers";
private $signersUrl = "envelopes/#/signers";
private $reqQualiUrl = 'envelopes/#/requirements';
private $notifySignersUrl = "envelopes/#/signers/@/notifications";
private $client;
public function __construct()
{
$this->api = env('CLICKSIGN_ENV') == 'production' ? 'https://clicksign.com/api/v3/' : 'https://sandbox.clicksign.com/api/v3/';
$token = env('CLICKSIGN_API_KEY');
$this->client = Http::contentType($this->type)->withHeader("Authorization", $token);
}
public function sendNotification()
{
/*$response = $this->client->post($this->api . 'envelopes', [
'data' => [
'type' => 'envelopes',
'attributes' => [
'name' => 'Envelope de Teste',
#'auto_close'=>true,
#'remind_interval'=>1,
]
]
]);
$envelope = $response->json();
dd($envelope);*/
//dd(file_get_contents(__DIR__.'/teste.pdf'));
//92decef1-dbcb-429b-ae5a-2b0f3cfed37f
/*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->documentsUrl), [
'data' => [
'type' => 'documents',
'attributes' => [
'filename' => 'Teste.pdf',
'content_base64' => 'data:application/pdf;base64,'.base64_encode(file_get_contents(__DIR__.'/teste.pdf'))
]
]
]);
//9ae4682e-de11-4608-a74b-f9a8ee844c8a
dd($response->json());;*//*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->signersUrl), [
'data' => [
'type' => 'signers',
'attributes' => [
'name' => 'Igor Carvalho de Paula',
'phone_number' => '21993886619',
'has_documentation' => false,
'communicate_events' => [
'signature_request' => 'whatsapp',
'signature_reminder' => 'none',
'document_signed' => 'whatsapp'
]
]
]
]);
dd($response->json());
//297dc588-3ee9-458a-baee-e7c3cea3bc16
//*/;
/*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->reqQualiUrl), [
'data' => [
'type' => 'requirements',
'attributes' => [
'action' => 'agree',
'role' => 'sign'
],
'relationships' => [
'document' => [
'data' => [
'type' => 'documents',
'id' => '9ae4682e-de11-4608-a74b-f9a8ee844c8a'
]
],
'signer' => [
'data' => [
'type' => 'signers',
'id' => '297dc588-3ee9-458a-baee-e7c3cea3bc16'
]
]
]
]
]);
//89d77d04-9be1-42bd-ae45-c5ec716924c2
dd($response->json());*/
/*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->reqQualiUrl), [
'data' => [
'type' => 'requirements',
'attributes' => [
'action' => 'provide_evidence',
'auth' => 'whatsapp'
],
'relationships' => [
'document' => [
'data' => [
'type' => 'documents',
'id' => '9ae4682e-de11-4608-a74b-f9a8ee844c8a'
]
],
'signer' => [
'data' => [
'type' => 'signers',
'id' => '297dc588-3ee9-458a-baee-e7c3cea3bc16'
]
]
]
]
]);
//c6317df9-bf1f-4238-8081-4564433028e2
dd($response->json());*/
/*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->reqQualiUrl), [
'data' => [
'type' => 'requirements',
'attributes' => [
'action' => 'rubricate',
'pages' => 'all'
],
'relationships' => [
'document' => [
'data' => [
'type' => 'documents',
'id' => '9ae4682e-de11-4608-a74b-f9a8ee844c8a'
]
],
'signer' => [
'data' => [
'type' => 'signers',
'id' => '297dc588-3ee9-458a-baee-e7c3cea3bc16'
]
]
]
]
]);
//d369241f-95cd-4f41-95ac-8165fa3fcfc7
dd($response->json());*/
/*$response = $this->client->patch($this->api . str_replace(['#'], ['92decef1-dbcb-429b-ae5a-2b0f3cfed37f'], $this->envelopesEditUrl), [
'data' => [
'type' => 'envelopes',
'id' => '92decef1-dbcb-429b-ae5a-2b0f3cfed37f',
'attributes' => [
'status' => 'running',
'auto_close' => true,
'default_message' => 'Você tem um documento paa assinar',
'locale' => 'pt-BR',
]
]
]);
*/
/*$response = $this->client->post($this->api . str_replace(['#', '@'], ['92decef1-dbcb-429b-ae5a-2b0f3cfed37f', '297dc588-3ee9-458a-baee-e7c3cea3bc16'], $this->notifySignersUrl), [
'data' => [
'type' => 'notifications',
'attributes' => [
'message' => null
]
]
]);
// 36bc7120-66f0-4017-a064-69d37ed209a3*/
/*$response = $this->client->post($this->api . str_replace('#', '92decef1-dbcb-429b-ae5a-2b0f3cfed37f', $this->envelopesSignWatcher), [
'data' => [
'type' => 'signature_watchers',
'attributes' => [
'email' => '[email protected]',
'kind' => 'on_finished',
'communicate_events'=>[
'signature_watcher_document_sent'=>'email',
'signature_watcher_document_signed'=>'email',
'signature_watcher_document_deadline'=>'email',
'signature_watcher_document_canceled'=>'email',
'signature_watcher_envelope_closed'=>'email',
],
'attach_documents_enabled'=>true,
],
]
]);
//d7d41333-d1c3-4e3e-9281-5a5519182fab
*/
//dd($response->json());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment