Skip to content

Commit

Permalink
namespace et webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviernival committed Sep 5, 2024
1 parent 4a7b738 commit 371fa1f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@
# site officiel de Yousign la doc :

https://developers.yousign.com/docs/introduction-new

# Installation
via composer
```
composer require oliviernival/yousign-client-api-v3-2024
```
# Utilisation

```
<?php
require_once '/path/to/vendor/autoload.php';
$client = new NvlYousignClientApiV3\NvlYousignClientV3();
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"Oliviernival\\YousignClientApiV32024\\": "src/"
"NvlYousignClientApiV3\\": "src/"
}
},
"authors": [
Expand Down
33 changes: 32 additions & 1 deletion src/NvlYousignClientV3.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace OlivierNvlYousignClientApiV3;
namespace NvlYousignClientApiV3;


class NvlYousignClientV3
Expand Down Expand Up @@ -480,4 +480,35 @@ public function activateSignatureRequest()
return $this->ActivateSignatureResponse;
}

public function createWebhook($params)
{
// data for all event :
// la V3 de Yousign permet la création de 5 Webhook differents
/*
$data = {"sandbox":true,"auto_retry":true,"enabled":true,"subscribed_events":["*"],"endpoint":"https://mondomaine.com/routequirecoiteventyousign","description":"all event "}
*/

## 4 - create webhook:
$data=json_encode($params);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => sprintf('%s/webhooks', $this->apiBaseUrlWslash),
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => [
sprintf('Authorization: Bearer %s', $this->apikey),
'Content-Type: application/json'
],
]);

$initActivateSignatureRequestResponse = curl_exec($curl);

$this->ActivateSignatureResponse = json_decode($initActivateSignatureRequestResponse,true);
curl_close($curl);

return $this->ActivateSignatureResponse;


}

}

0 comments on commit 371fa1f

Please sign in to comment.