Skip to content

Commit 41a208d

Browse files
authored
Added an ability to get launcher text from manifests (#86)
* added loading of the data from the manifest and mapping for code examples pages * added mapping for texts on the homepages and code example pages * Added getting the manifest in the Quick_ACG project * removed leftover comments * Added support of the common texts and notes * Added form inputs and redirects * fixes after testing * fixes after code review * moved str_replace to service * fixed the link to example 28 to example 30
1 parent 6ab73f3 commit 41a208d

File tree

169 files changed

+4603
-2473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+4603
-2473
lines changed

Quick_ACG/src/RouterService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace QuickACG;
44

55
use Example\Services\CodeGrantService;
6+
use Example\Services\ManifestService;
67
use Example\Services\IRouterService;
78

89
class RouterService implements IRouterService
@@ -15,10 +16,6 @@ class RouterService implements IRouterService
1516
'eg001' => 'esignature/quickEmbeddedSigning.html'
1617
];
1718

18-
private const TITLES = [
19-
'eg001' => 'Use embedded signing'
20-
];
21-
2219
private const SESSION_VALUES = [
2320
'ds_access_token',
2421
'ds_refresh_token',
@@ -70,6 +67,7 @@ public function router(): void
7067
break;
7168
default:
7269
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
70+
$_SESSION['API_TEXT'] = ManifestService::loadManifestData(ManifestService::getLinkToManifestFile('eSignature'));
7371
$controller = '\Example\\' . $this->getController($page);
7472
new $controller($page);
7573
break;
@@ -177,6 +175,6 @@ public function getTemplate($eg): string
177175
*/
178176
public function getTitle($eg): string
179177
{
180-
return self::TITLES[$eg];
178+
return ManifestService::getPageText($eg)["ExampleName"];
181179
}
182180
}

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
"DocuSign\\OAuth2\\Client\\Provider\\": "src/"
55
}
66
},
7-
7+
"scripts": {
8+
"post-install-cmd": [
9+
"@code-sniffer"
10+
],
11+
"post-update-cmd": [
12+
"@code-sniffer"
13+
]
14+
},
815
"require": {
916
"docusign/admin-client": "1.1.0",
1017
"docusign/click-client": "1.1.0",
@@ -16,6 +23,7 @@
1623
"ext-json": "*",
1724
"guzzlehttp/guzzle": "7.4.5",
1825
"firebase/php-jwt": "5.5.1",
19-
"mashape/unirest-php": "3.0.4"
26+
"mashape/unirest-php": "3.0.4",
27+
"squizlabs/php_codesniffer": "*"
2028
}
2129
}

ds_config_example.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
'gateway_name' => "stripe",
3030
'gateway_display_name' => "Stripe",
3131
'github_example_url' => 'https://github.com/docusign/code-examples-php/tree/master/src/Controllers/Examples',
32-
'documentation' => false
32+
'documentation' => false,
33+
// Manifest files
34+
"ESignatureManifest" => "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/eSignatureManifest.json",
35+
"ClickManifest" => "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/ClickManifest.json",
36+
"RoomsManifest" => "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/RoomsManifest.json",
37+
"MonitorManifest" => "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/MonitorManifest.json",
38+
"AdminManifest" => "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/AdminManifest.json"
3339
];
3440

3541
$JWT_CONFIG = [

phpcs.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="igmaDev">
3+
<file>src/Controllers</file>
4+
<file>src/Services</file>
5+
<file>src/EG001EmbeddedSigning.php</file>
6+
<file>public/index.php</file>
7+
<exclude-pattern>*/docs/*</exclude-pattern>
8+
<exclude-pattern>*/templates/*</exclude-pattern>
9+
<exclude-pattern>*/public/assets/*</exclude-pattern>
10+
<exclude-pattern>*/public/demo_documents/*</exclude-pattern>
11+
<arg name="extensions" value="php" />
12+
<rule ref="PEAR">
13+
<exclude name="PEAR.Commenting.FunctionCallSignature.CloseBracketLine" />
14+
<exclude name="PEAR.Files.IncludingFile.UseInclude" />
15+
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
16+
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
17+
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
18+
<exclude name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
19+
<exclude name="PEAR.WhiteSpace.ObjectOperatorIndent.Incorrect" />
20+
</rule>
21+
<rule ref="PSR2">
22+
<exclude name="PSR2.Methods.FunctionCallSignature.CloseBracketLine" />
23+
<exclude name="PSR2.Methods.FunctionCallSignature.ContentAfterOpenBracket" />
24+
<exclude name="PSR2.Methods.FunctionCallSignature.Indent" />
25+
</rule>
26+
<rule ref="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter" />
27+
<rule ref="Generic.Files.LineLength">
28+
<properties>
29+
<property name="lineLimit" value="90"/>
30+
<property name="absoluteLineLimit" value="130"/>
31+
</properties>
32+
</rule>
33+
<rule ref="Generic.Commenting.DocComment.MissingShort">
34+
<severity>0</severity>
35+
</rule>
36+
<rule ref="Generic.Commenting.DocComment.TagValueIndent">
37+
<severity>0</severity>
38+
</rule>
39+
<rule ref="Generic.Commenting.DocComment.ContentAfterOpen">
40+
<severity>0</severity>
41+
</rule>
42+
<rule ref="Generic.Commenting.DocComment.ContentBeforeClose">
43+
<severity>0</severity>
44+
</rule>
45+
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
46+
</ruleset>

public/assets/css.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,8 @@ pre.json-display {
144144
.your-class div{
145145
float:left;
146146
margin-left: 10px;
147+
}
148+
149+
.chooseApiTypeStyle {
150+
padding-left: 0;
147151
}

src/Controllers/AdminApiBaseController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function controller(
3232
{
3333
$method = $_SERVER['REQUEST_METHOD'];
3434

35+
$this->codeExampleText = $this->getPageText(static::EG);
36+
3537
if (!$this->routerService) {
3638
$this->routerService = new RouterService();
3739
}
@@ -67,7 +69,8 @@ private function getController(
6769
if ($this->isHomePage(static::EG)) {
6870
$GLOBALS['twig']->display(static::EG . '.html', [
6971
'title' => $this->homePageTitle(static::EG),
70-
'show_doc' => false
72+
'show_doc' => false,
73+
'common_texts' => $this->getCommonText()
7174
]);
7275
}
7376
else
@@ -83,6 +86,8 @@ private function getController(
8386
'permission_profiles' => $permission_profiles,
8487
'export_id' => isset($_SESSION['export_id']),
8588
'import_id' => isset($_SESSION['import_id']),
89+
'code_example_text' => $this->codeExampleText,
90+
'common_texts' => $this->getCommonText()
8691
]);
8792
}
8893
else {

src/Controllers/BaseController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
namespace Example\Controllers;
44

5+
use Example\Services\ManifestService;
6+
57
abstract class BaseController
68
{
79

810
protected const DEMO_DOCS_PATH = __DIR__ . '/../../public/demo_documents/';
11+
12+
protected array $codeExampleText;
913

1014
/**
1115
* Save the current operation so it will be resumed after authentication
@@ -39,6 +43,16 @@ protected function isHomePage(string $eg): bool
3943
return in_array($eg, ["home_esig", "home_rooms", "home_click", "home_monitor", "home_admin"]);
4044
}
4145

46+
protected function getPageText(string $eg): array
47+
{
48+
return ManifestService::getPageText($eg);
49+
}
50+
51+
protected function getCommonText(): array
52+
{
53+
return ManifestService::getCommonTexts();
54+
}
55+
4256
protected function homePageTitle($eg=''): string
4357
{
4458
$title = '';

src/Controllers/ClickApiBaseController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ abstract function getTemplateArgs(): array;
2929
*/
3030
public function controller(array $args = null): void
3131
{
32+
$this->codeExampleText = $this->getPageText(static::EG);
33+
3234
$method = $_SERVER['REQUEST_METHOD'];
3335
if ($method == 'GET') {
3436
$this->getController($this->routerService, basename(static::FILE), $args);
@@ -57,19 +59,21 @@ private function getController(
5759
static::EG . '.html',
5860
[
5961
'title' => $this->homePageTitle(static::EG),
60-
'show_doc' => false
62+
'show_doc' => false,
63+
'common_texts' => $this->getCommonText()
6164
]
6265
);
6366
} else {
64-
if ($routerService->ds_token_ok()) {
65-
67+
if ($routerService->ds_token_ok()) {
6668
$GLOBALS['twig']->display($routerService->getTemplate(static::EG), [
6769
'title' => $routerService->getTitle(static::EG),
6870
'source_file' => $basename,
6971
'source_url' => $GLOBALS['DS_CONFIG']['github_example_url'] . "/Click/" . $basename,
7072
'documentation' => $GLOBALS['DS_CONFIG']['documentation'] . static::EG,
7173
'show_doc' => $GLOBALS['DS_CONFIG']['documentation'],
7274
'args' => $args,
75+
'code_example_text' => $this->codeExampleText,
76+
'common_texts' => $this->getCommonText()
7377
]);
7478
}
7579
else {

src/Controllers/Examples/Admin/EG002CreateActiveCLMESignUser.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public function __construct()
4747
$dsgReq = $this->clientService->adminGroupsApi();
4848
$dsgRes = $dsgReq->getDSGroups($this->orgId, $this->args["account_id"]);
4949
$dsGroups = $dsgRes["ds_groups"];
50+
if ($dsgRes["ds_groups"] == null) {
51+
throw new ApiException(
52+
$this->codeExampleText["CustomErrorTexts"][0]["ErrorMessage"]
53+
);
54+
}
5055
// Step 4 end
5156

5257
$preFill = [
@@ -88,10 +93,8 @@ public function createController(): void
8893
$_SESSION['email_address'] = strval($addUsersResponse->getEmail());
8994

9095
$addUsersResponse = json_decode((string)$addUsersResponse, true);
91-
$this->clientService->showDoneTemplate(
92-
"Create a new active user for CLM and eSignature",
93-
"Create a new active user for CLM and eSignature",
94-
"Results from MultiProductUserManagement:addOrUpdateUser method:",
96+
$this->clientService->showDoneTemplateFromManifest(
97+
$this->codeExampleText,
9598
json_encode(json_encode($addUsersResponse))
9699
);
97100
}

src/Controllers/Examples/Admin/EG003BulkExportUserData.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DocuSign\Admin\Client\ApiException;
66
use Example\Controllers\AdminApiBaseController;
77
use Example\Services\Examples\Admin\BulkExportUserDataService;
8+
use Example\Services\ManifestService;
89

910
class EG003BulkExportUserData extends AdminApiBaseController
1011
{
@@ -41,14 +42,14 @@ public function createController(): void
4142
$organizationId
4243
);
4344
$filePath = realpath(
44-
$_SERVER["DOCUMENT_ROOT"]
45-
) . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "demo_documents" . DIRECTORY_SEPARATOR . "ExportedUserData.csv";
45+
$_SERVER["DOCUMENT_ROOT"]
46+
) . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "demo_documents" . DIRECTORY_SEPARATOR . "ExportedUserData.csv";
4647
if ($bulkExports) {
47-
$this->clientService->showDoneTemplate(
48-
"Bulk export user data",
49-
"Bulk export user data",
50-
"User data exported to $filePath<br>from UserExport:getUserListExport method:",
51-
json_encode(json_encode($bulkExports))
48+
$this->clientService->showDoneTemplateFromManifest(
49+
$this->codeExampleText,
50+
json_encode(json_encode($bulkExports)),
51+
null,
52+
ManifestService::replacePlaceholders("{0}", $filePath, $this->codeExampleText["ResultsPageText"])
5253
);
5354
}
5455
} catch (ApiException $e) {

0 commit comments

Comments
 (0)