Skip to content

Commit acc4dcf

Browse files
AaronWDSdependabot[bot]InbarGazit
authored
Devdocs 8770: createHasAgreed code example (#92)
* Bump twig/twig from 3.3.8 to 3.4.3 in /Quick_ACG Bumps [twig/twig](https://github.com/twigphp/Twig) from 3.3.8 to 3.4.3. - [Release notes](https://github.com/twigphp/Twig/releases) - [Changelog](https://github.com/twigphp/Twig/blob/3.x/CHANGELOG) - [Commits](twigphp/Twig@v3.3.8...v3.4.3) --- updated-dependencies: - dependency-name: twig/twig dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump twig/twig from 3.3.8 to 3.4.3 Bumps [twig/twig](https://github.com/twigphp/Twig) from 3.3.8 to 3.4.3. - [Release notes](https://github.com/twigphp/Twig/releases) - [Changelog](https://github.com/twigphp/Twig/blob/3.x/CHANGELOG) - [Commits](twigphp/Twig@v3.3.8...v3.4.3) --- updated-dependencies: - dependency-name: twig/twig dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * README.md updates * initial commit * adding in routes * bug in click2 * checking in fixes for embed clickwrap * bugfix and check-in * small cleanup changes * show inactive clickwraps and redirect if used and removed extra error string on template render method * checks before loading example and reroutes based on clickwraps present and/or active * manifest error fix * error text fixes * error fixes * check in * fixed error handling * small bugfixes * fix small bug on ifelse in index * figured out the mismatch on error handling * match pdf doc from other launchers Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Inbar Gazit <inbar.gazit@docusign.com>
1 parent 9c9a140 commit acc4dcf

File tree

12 files changed

+433
-35
lines changed

12 files changed

+433
-35
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require": {
1616
"docusign/admin-client": "1.1.0",
17-
"docusign/click-client": "1.1.0",
17+
"docusign/click-client": "1.2.2",
1818
"docusign/esign-client": "6.8.0",
1919
"docusign/rooms-client": "2.0.0",
2020
"docusign/monitor-client": "1.1.0",

composer.lock

Lines changed: 90 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
27.1 KB
Binary file not shown.

src/Controllers/Examples/Click/EG001CreateClickwrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function createController(): void
3939
);
4040

4141
if ($clickwrapSummaryResponse) {
42-
$clickwrap_name = $clickwrapSummaryResponse['clickwrapName'];
42+
$clickwrap_name = $clickwrapSummaryResponse['clickwrap_name'];
4343
$clickwrapSummaryResponse = json_decode((string)$clickwrapSummaryResponse, true);
4444
$this->clientService->showDoneTemplateFromManifest(
4545
$this->codeExampleText,
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace Example\Controllers\Examples\Click;
4+
5+
use DocuSign\Click\Client\ApiException;
6+
use Example\Controllers\ClickApiBaseController;
7+
use Example\Services\Examples\Click\EmbedClickwrapService;
8+
9+
class EG006EmbedClickwrap extends ClickApiBaseController
10+
{
11+
const EG = 'ceg006'; # reference (and URL) for this example
12+
const FILE = __FILE__;
13+
14+
/**
15+
* 1. Get available clickwraps
16+
* 2. Create a new controller instance.
17+
*
18+
* @return void
19+
*/
20+
public function __construct()
21+
{
22+
parent::__construct();
23+
# Get available clickwraps
24+
$clickwraps = EmbedClickwrapService::getClickwraps(
25+
$this->routerService,
26+
$this->clientService,
27+
$this->args,
28+
$this::EG
29+
);
30+
31+
parent::controller(['clickwraps' => $clickwraps[0], 'inactives'=>$clickwraps[1]]);
32+
}
33+
34+
35+
36+
/**
37+
* 1. Check the token
38+
* 2. Call the worker method
39+
* 3. Display clickwrap responses data
40+
*
41+
* @return void
42+
*/
43+
function createController(): void
44+
{
45+
$this->checkDsToken();
46+
$clickwrapResponse = EmbedClickwrapService::createAgreeementUrl($this->args, $this->clientService);
47+
$htmlString = "<p id='agreementStatus'>NOT AGREED</p><div id='ds-terms-of-service'></div><script src='https://stage.docusign.net/clickapi/sdk/latest/docusign-click.js'></script><script>docuSignClick.Clickwrap.render({agreementUrl: '" . $clickwrapResponse . "',onAgreed: function () {document.getElementById('agreementStatus').innerHTML = 'AGREED';}}, '#ds-terms-of-service');</script>";
48+
if ($clickwrapResponse) {
49+
50+
if($clickwrapResponse === 'Already Agreed'){
51+
$e = new ApiException("The email address was already used to agree to this elastic template. Provide a different email address if you want to view the agreement and agree to it.",990);
52+
$this->clientService->showErrorTemplate($e);
53+
exit;
54+
}
55+
56+
57+
58+
$this->clientService->showDoneTemplateFromManifest(
59+
$this->codeExampleText,
60+
null,
61+
$this->codeExampleText["ResultsPageText"]."<p>Agreement URL received back from API call: <code>".$clickwrapResponse."</code></p>".$htmlString
62+
);
63+
64+
}
65+
}
66+
67+
public function getTemplateArgs(): array
68+
{
69+
return [
70+
'account_id' => $_SESSION['ds_account_id'],
71+
'ds_access_token' => $_SESSION['ds_access_token'],
72+
'clickwrap_id' => $this->checkInputValues($_POST['clickwrap_id']),
73+
'full_name' => $this->checkInputValues($_POST['fullName']),
74+
'email_address' => $this->checkInputValues(($_POST['emailAddress'])),
75+
'company' => $this->checkInputValues($_POST['company']),
76+
'job_title' => $this->checkInputValues($_POST['jobTitle']),
77+
'date' => $this->checkInputValues($_POST['date'])
78+
];
79+
}
80+
}

src/Controllers/Examples/SelectAPI.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,19 @@ public function controller()
3232
}
3333
}
3434

35+
3536
private function getController()
3637
{
38+
/*
39+
we don't know if the api_type has been set,
40+
if it has never been set, this will trigger an
41+
error in the manifest, therefore, we'll set it
42+
to ESignature for the Manifest service to work.
43+
*/
44+
if(!isset($_SESSION['api_type'])){
45+
$_SESSION['api_type'] = "ESignature";
46+
}
47+
3748
$GLOBALS['twig']->display(
3849
'select_api.html',
3950
[

0 commit comments

Comments
 (0)