Skip to content

Commit b2db525

Browse files
2 parents ceb20bd + d26f2d7 commit b2db525

21 files changed

+1040
-706
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
>
77
### GitHub repo: [code-examples-php](./README.md)
88

9+
If you downloaded this project using the [Quickstart](https://developers.docusign.com/docs/esign-rest-api/quickstart/) tool, it may be configured in one of three ways:
10+
11+
* **[JWT Grant remote signing example](#jwt-grant-remote-signing-example)**–demonstrates how to implement JSON Web Token authentication. It includes a single remote signing workflow.
12+
* **[Authorization Code Grant embedded signing example](#authorization-code-grant-embedded-signing-example)**–demonstrates how to implement Authorization Code Grant authentication. It includes a single embedded signing workflow.
13+
* **[Multiple code examples, Authorization Code Grant and JWT Grant](#installation-steps)**–includes the full range of examples and authentication types.
14+
15+
***Installation and running instructions vary depending on the configuration. Follow the link that matches your project type to get started.***
16+
917
This GitHub repo includes code examples for the [Web Forms API](https://developers.docusign.com/docs/web-forms-api/), [Maestro API](https://developers.docusign.com/docs/maestro-api/), [Docusign Admin API](https://developers.docusign.com/docs/admin-api/), [Click API](https://developers.docusign.com/docs/click-api/), [eSignature REST API](https://developers.docusign.com/docs/esign-rest-api/), [Monitor API](https://developers.docusign.com/docs/monitor-api/), and [Rooms API](https://developers.docusign.com/docs/rooms-api/).
1018

1119

@@ -200,6 +208,23 @@ Apache will run.
200208
## JWT grant remote signing and Authorization Code Grant embedded signing projects
201209
See [Docusign Quickstart overview](https://developers.docusign.com/docs/esign-rest-api/quickstart/overview/) on the Docusign Developer Center for more information on how to run the JWT grant remote signing and the Authorization Code Grant embedded signing project.
202210

211+
### Authorization Code Grant embedded signing example:
212+
Run in Git Bash:
213+
```
214+
$ cd <Quickstart folder>/Quick_ACG
215+
$ composer install
216+
$ php -S localhost:8080
217+
```
218+
219+
Open a browser to http://localhost:3000
220+
221+
### JWT grant remote signing example:
222+
Run in Git Bash:
223+
```
224+
$ cd <Quickstart folder>/JWT Console App
225+
$ composer install
226+
$ php JWTConsoleApp.php
227+
```
203228

204229
## Payments code example
205230

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"docusign/rooms-client": "^2.1.1",
2424
"docusign/monitor-client": "^1.2.1",
2525
"docusign/webforms-client": "^1.0.1-rc1",
26-
"docusign/maestro-client": "v2.0.0-rc1",
2726
"twig/twig": "^3.14.0",
2827
"league/oauth2-client": "^2.7.0",
2928
"ext-json": "*",

public/assets/search.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ let DS_SEARCH = (function () {
66
ROOMS: 'rooms',
77
ADMIN: 'admin',
88
CONNECT: 'connect',
9+
WEBFORMS: 'webforms',
10+
NOTARY: 'notary',
911
MAESTRO: 'maestro',
10-
WEBFORMS: 'webforms'
12+
CONNECTEDFIELDS: 'connectedfields',
1113
};
1214

1315
let processJSONData = function () {
@@ -127,10 +129,14 @@ let DS_SEARCH = (function () {
127129
return "eg";
128130
case API_TYPES.CONNECT:
129131
return "con";
130-
case API_TYPES.MAESTRO:
131-
return "mae";
132132
case API_TYPES.WEBFORMS:
133133
return "web";
134+
case API_TYPES.NOTARY:
135+
return "n";
136+
case API_TYPES.CONNECTEDFIELDS:
137+
return "cf";
138+
case API_TYPES.MAESTRO:
139+
return "mae";
134140
}
135141
}
136142

src/Controllers/Auth/DocuSign.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,18 @@ public function getDefaultScopes(): array
122122
. " asset_group_account_clone_write asset_group_account_clone_read "
123123
. "organization_sub_account_write organization_sub_account_read"
124124
];
125-
} elseif ($_SESSION['api_type'] == ApiTypes::MAESTRO) {
126-
return [
127-
"signature aow_manage"
128-
];
129125
} elseif ($_SESSION['api_type'] == ApiTypes::WEBFORMS) {
130126
return [
131127
"signature webforms_read webforms_instance_read webforms_instance_write"
132128
];
129+
} elseif ($_SESSION['api_type'] == ApiTypes::NOTARY) {
130+
return [
131+
"signature"
132+
];
133+
} elseif ($_SESSION['api_type'] == ApiTypes::CONNECTEDFIELDS) {
134+
return [
135+
"signature adm_store_unified_repo_read"
136+
];
133137
} else {
134138
return [
135139
"signature"

src/Controllers/MaestroApiBaseController.php renamed to src/Controllers/ConnectedFieldsApiBaseController.php

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
namespace DocuSign\Controllers;
44

5+
use DocuSign\Services\SignatureClientService;
6+
use DocuSign\Services\RouterService;
7+
use DocuSign\Services\IRouterService;
58
use DocuSign\Services\ApiTypes;
69
use DocuSign\Services\ManifestService;
7-
use DocuSign\Services\MaestroApiClientService;
8-
use DocuSign\Services\RouterService;
910

10-
abstract class MaestroApiBaseController extends BaseController
11+
abstract class ConnectedFieldsApiBaseController extends BaseController
1112
{
1213
private const MINIMUM_BUFFER_MIN = 3;
13-
protected MaestroApiClientService $clientService;
14-
protected RouterService $routerService;
14+
protected SignatureClientService $clientService;
15+
protected IRouterService $routerService;
1516
protected array $args;
1617

1718
public function __construct()
1819
{
1920
$this->args = $this->getTemplateArgs();
20-
$this->clientService = new MaestroApiClientService($this->args);
21+
$this->clientService = new SignatureClientService($this->args);
2122
$this->routerService = new RouterService();
2223
if (defined("static::EG")) {
2324
$this->checkDsToken();
@@ -29,87 +30,100 @@ abstract protected function getTemplateArgs(): array;
2930
/**
3031
* Base controller
3132
*
32-
* @param $args array|null
33+
* @param null $eg
3334
* @return void
3435
*/
35-
public function controller(array $args = null): void
36+
public function controller($args = null): void
3637
{
38+
if (empty($eg)) {
39+
$eg = static::EG;
40+
$this->codeExampleText = $this->getPageText(static::EG);
41+
}
42+
3743
$this->codeExampleText = $this->getPageText(static::EG);
3844

3945
if ($this->isMethodGet()) {
40-
$this->getController($this->routerService, basename(static::FILE), $args);
46+
$this->getController(
47+
$args,
48+
basename(static::FILE)
49+
);
4150
}
51+
4252
if ($this->isMethodPost()) {
43-
$this->routerService->checkCsrf();
4453
$this->createController();
4554
}
4655
}
4756

4857
/**
4958
* Show the example's form page
5059
*
51-
* @param $routerService RouterService
60+
* @param $eg
5261
* @param $basename string|null
53-
* @param $args array|null
62+
* @param $brand_languages array|null
63+
* @param $brands array|null
64+
* @param $permission_profiles array|null
65+
* @param $groups array|null
5466
* @return void
5567
*/
56-
private function getController(
57-
RouterService $routerService,
58-
?string $basename,
59-
?array $args
68+
protected function getController(
69+
$args,
70+
?string $basename
6071
): void {
6172
if ($this->isHomePage(static::EG)) {
62-
$GLOBALS['twig']->display(
63-
static::EG . '.html',
64-
[
65-
'title' => $this->homePageTitle(static::EG),
66-
'show_doc' => false,
67-
'common_texts' => $this->getCommonText()
68-
]
69-
);
73+
$GLOBALS['twig']->display(static::EG . '.html', [
74+
'title' => $this->homePageTitle(static::EG),
75+
'show_doc' => false,
76+
'common_texts' => $this->getCommonText()
77+
]);
7078
} else {
7179
$currentAPI = ManifestService::getAPIByLink(static::EG);
72-
if ($routerService->dsTokenOk() && $currentAPI === $_SESSION['api_type']) {
73-
$GLOBALS['twig']->display($routerService->getTemplate(static::EG), [
74-
'title' => $routerService->getTitle(static::EG),
80+
if ($this->routerService->dsTokenOk() && $currentAPI === $_SESSION['api_type']) {
81+
$displayOptions = [
82+
'title' => $this->routerService->getTitle(static::EG),
7583
'source_file' => $basename,
76-
'source_url' => $GLOBALS['DS_CONFIG']['github_example_url'] . "/Maestro/" . $basename,
84+
'args' => $args,
85+
'source_url' => $GLOBALS['DS_CONFIG']['github_example_url'] . "/ConnectedFields/". $basename,
7786
'documentation' => $GLOBALS['DS_CONFIG']['documentation'] . static::EG,
7887
'show_doc' => $GLOBALS['DS_CONFIG']['documentation'],
79-
'args' => $args,
80-
'template_id' => $_COOKIE["template_id"],
81-
'workflow_id' => $_SESSION["workflow_id"],
82-
'instance_id' => $_SESSION['instance_id'],
8388
'signer_name' => $GLOBALS['DS_CONFIG']['signer_name'],
8489
'signer_email' => $GLOBALS['DS_CONFIG']['signer_email'],
8590
'code_example_text' => $this->codeExampleText,
8691
'common_texts' => $this->getCommonText()
87-
]);
92+
];
93+
94+
$GLOBALS['twig']->display($this->routerService->getTemplate(static::EG), $displayOptions);
8895
} else {
89-
# Save the current operation so it will be resumed after authentication
90-
$_SESSION['prefered_api_type'] = ApiTypes::MAESTRO;
91-
$_SESSION['eg'] = $GLOBALS['app_url'] . 'index.php?page=' . static::EG;
96+
$_SESSION['prefered_api_type'] = ApiTypes::CONNECTEDFIELDS;
97+
$this->saveCurrentUrlToSession(static::EG);
9298
header('Location: ' . $GLOBALS['app_url'] . 'index.php?page=' . static::LOGIN_REDIRECT);
9399
exit;
94100
}
95101
}
96102
}
97-
103+
98104
/**
99105
* Declaration for the base controller creator. Each creator should be described in specific Controller
100106
*/
101107
abstract protected function createController(): void;
102108

103109
/**
104-
* @return array
110+
* Check email input value using regular expression
111+
* @param $email
112+
* @return string
113+
*/
114+
protected function checkEmailInputValue($email): string
115+
{
116+
return preg_replace('/([^\w +\-\@\.\,])+/', '', $email);
117+
}
118+
119+
/**
120+
* Check input values using regular expressions
121+
* @param $value
122+
* @return string
105123
*/
106-
protected function getDefaultTemplateArgs(): array
124+
protected function checkInputValues($value): string
107125
{
108-
return [
109-
'account_id' => $_SESSION['ds_account_id'],
110-
'base_path' => $_SESSION['ds_base_path'], // here
111-
'ds_access_token' => $_SESSION['ds_access_token']
112-
];
126+
return preg_replace('/([^\w \-\@\.\,])+/', '', $value);
113127
}
114128

115129
/**
@@ -118,20 +132,10 @@ protected function getDefaultTemplateArgs(): array
118132
protected function checkDsToken(): void
119133
{
120134
$currentAPI = ManifestService::getAPIByLink(static::EG);
121-
135+
122136
if (!$this->routerService->dsTokenOk(self::MINIMUM_BUFFER_MIN) || $currentAPI !== $_SESSION['api_type']) {
123-
$_SESSION['prefered_api_type'] = ApiTypes::MAESTRO;
137+
$_SESSION['prefered_api_type'] = ApiTypes::CONNECTEDFIELDS;
124138
$this->clientService->needToReAuth(static::EG);
125139
}
126140
}
127-
128-
/**
129-
* Check input values using regular expressions
130-
* @param $value
131-
* @return string
132-
*/
133-
protected function checkInputValues($value): string
134-
{
135-
return preg_replace('/([^\w \-\@\.\,])+/', '', $value);
136-
}
137141
}

0 commit comments

Comments
 (0)