Skip to content

Commit d57c5c4

Browse files
authored
Implemented new code examples for Admin SDK (#78)
* fixed the namings for the input properties * Added new admin code examples * changed a case for properties * added a check if account has been deleted
1 parent a36b2f1 commit d57c5c4

22 files changed

+883
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77

88
"require": {
9-
"docusign/admin-client": "1.0.0",
9+
"docusign/admin-client": "1.1.0",
1010
"docusign/click-client": "1.1.0",
1111
"docusign/esign-client": "6.8.0",
1212
"docusign/rooms-client": "2.0.0",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/site.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$(document).ready(function () {
2+
$("#Products").on("change", function () {
3+
$list = $("#PermissionProfilesFiltered");
4+
5+
let json_raw = $("#PermissionProfilesData").attr("data-value"),
6+
json = json_raw ? JSON.parse(json_raw) : false;
7+
8+
if (json) {
9+
$list.empty();
10+
$.each(json, function (key, product) {
11+
if(key === $("#Products option:selected").html()){
12+
$.each(product, function (i, permissionProfile) {
13+
$list.append(
14+
'<option value="'
15+
+ permissionProfile["permission_profile_id"]
16+
+ '"> '
17+
+ permissionProfile["permission_profile_name"]
18+
+ ' </option>'
19+
);
20+
});
21+
}
22+
});
23+
}
24+
});
25+
});

src/Controllers/AdminApiBaseController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function getController(
8282
'args' => $args,
8383
'permission_profiles' => $permission_profiles,
8484
'export_id' => isset($_SESSION['export_id']),
85-
'import_id' => isset($_SESSION['import_id'])
85+
'import_id' => isset($_SESSION['import_id']),
8686
]);
8787
}
8888
else {
@@ -121,5 +121,15 @@ protected function getDefaultTemplateArgs(): array
121121
];
122122
}
123123

124+
/**
125+
* Check input values using regular expressions
126+
* @param $value
127+
* @return string
128+
*/
129+
protected function checkInputValues($value): string
130+
{
131+
return preg_replace('/([^\w \-\@\.\,])+/', '', $value);
132+
}
133+
124134
abstract function getTemplateArgs(): array;
125135
}

src/Controllers/Examples/Admin/EG002CreateActiveCLMESignUser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function createController(): void
8585
);
8686

8787
if ($addUsersResponse) {
88+
$_SESSION['email_address'] = strval($addUsersResponse->getEmail());
89+
8890
$addUsersResponse = json_decode((string)$addUsersResponse, true);
8991
$this->clientService->showDoneTemplate(
9092
"Create a new active user for CLM and eSignature",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Example\Controllers\Examples\Admin;
4+
5+
use DocuSign\Admin\Client\ApiException;
6+
use Example\Controllers\AdminApiBaseController;
7+
use Example\Services\Examples\Admin\RetrieveDocuSignProfileByEmailAddress;
8+
9+
class EG006RetrieveDocuSignProfileByEmailAddress extends AdminApiBaseController
10+
{
11+
const EG = 'aeg006'; # reference (and url) for this example
12+
13+
const FILE = __FILE__;
14+
15+
/**
16+
* Create a new controller instance
17+
*
18+
* @return void
19+
*/
20+
public function __construct()
21+
{
22+
parent::__construct();
23+
24+
parent::controller();
25+
}
26+
27+
/**
28+
* 1. Check the token
29+
* 2. Call the worker method
30+
*
31+
* @return void
32+
*/
33+
public function createController(): void
34+
{
35+
$this->checkDsToken();
36+
37+
try {
38+
$organizationId = $this->clientService->getOrgAdminId();
39+
40+
$usersResponse = RetrieveDocuSignProfileByEmailAddress::getDocuSignProfileByEmailAddress(
41+
$organizationId,
42+
$this->args["email"],
43+
$this->clientService);
44+
45+
$this->clientService->showDoneTemplate(
46+
"Retrieve the user's DocuSign profile using an email address",
47+
"Retrieve the user's DocuSign profile using an email address",
48+
"Results from MultiProductUserManagement:getUserDSProfilesByEmail method:",
49+
json_encode(json_encode($usersResponse))
50+
);
51+
} catch (ApiException $e) {
52+
$this->clientService->showErrorTemplate($e);
53+
}
54+
}
55+
56+
/**
57+
* Get specific template arguments
58+
*
59+
* @return array
60+
*/
61+
public function getTemplateArgs(): array
62+
{
63+
return [
64+
'email' => $this->checkInputValues($_POST['email']),
65+
'account_id' => $_SESSION['ds_account_id'],
66+
'ds_access_token' => $_SESSION['ds_access_token']
67+
];
68+
}
69+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Example\Controllers\Examples\Admin;
4+
5+
use DocuSign\Admin\Client\ApiException;
6+
use Example\Controllers\AdminApiBaseController;
7+
use Example\Services\Examples\Admin\RetrieveDocuSignProfileByUserId;
8+
9+
class EG007RetrieveDocuSignProfileByUserID extends AdminApiBaseController
10+
{
11+
const EG = 'aeg007'; # reference (and url) for this example
12+
13+
const FILE = __FILE__;
14+
15+
/**
16+
* Create a new controller instance
17+
*
18+
* @return void
19+
*/
20+
public function __construct()
21+
{
22+
parent::__construct();
23+
24+
parent::controller();
25+
}
26+
27+
/**
28+
* 1. Check the token
29+
* 2. Call the worker method
30+
*
31+
* @return void
32+
*/
33+
public function createController(): void
34+
{
35+
$this->checkDsToken();
36+
37+
try {
38+
$organizationId = $this->clientService->getOrgAdminId();
39+
$usersResponse = RetrieveDocuSignProfileByUserId::getDocuSignProfileByUserId(
40+
$organizationId, $this->args["user_id"], $this->clientService);
41+
42+
$this->clientService->showDoneTemplate(
43+
"Retrieve the user's DocuSign profile using a User ID",
44+
"Retrieve the user's DocuSign profile using a User ID",
45+
"Results from MultiProductUserManagement:getUserDSProfile method:",
46+
json_encode(json_encode($usersResponse))
47+
);
48+
} catch (ApiException $e) {
49+
$this->clientService->showErrorTemplate($e);
50+
}
51+
}
52+
53+
/**
54+
* Get specific template arguments
55+
*
56+
* @return array
57+
*/
58+
public function getTemplateArgs(): array
59+
{
60+
return [
61+
'user_id' => $this->checkInputValues($_POST['user_id']),
62+
'account_id' => $_SESSION['ds_account_id'],
63+
'ds_access_token' => $_SESSION['ds_access_token']
64+
];
65+
}
66+
}

0 commit comments

Comments
 (0)