@adobe/acc-js-sdk 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +8 -2170
  2. package/docs/404.html +11 -0
  3. package/docs/Gemfile +35 -0
  4. package/docs/Gemfile.lock +270 -0
  5. package/docs/_config.yml +55 -0
  6. package/docs/_data/navigation.yml +119 -0
  7. package/docs/_includes/navigation.html +33 -0
  8. package/docs/_layouts/default.html +21 -0
  9. package/docs/_layouts/home.html +4 -0
  10. package/docs/_layouts/page.html +5 -0
  11. package/docs/_layouts/post.html +7 -0
  12. package/docs/_posts/2022-10-14-welcome.html +149 -0
  13. package/docs/application.html +366 -0
  14. package/docs/architecture.html +24 -0
  15. package/docs/assets/css/styles.css +362 -0
  16. package/docs/assets/images/adobe-campaign-256.png +0 -0
  17. package/docs/assets/images/architecture.png +0 -0
  18. package/docs/assets/images/ref.svg +6 -0
  19. package/docs/badgerFish.html +14 -0
  20. package/docs/bestPractices.html +189 -0
  21. package/docs/blog.html +18 -0
  22. package/docs/buildAndRun.html +96 -0
  23. package/docs/caches.html +68 -0
  24. package/docs/changeLog.html +256 -0
  25. package/docs/checkList.html +168 -0
  26. package/docs/concepts.html +130 -0
  27. package/docs/connecting.html +210 -0
  28. package/docs/connectionParameters.html +109 -0
  29. package/docs/contribute.html +54 -0
  30. package/docs/dataTypes.html +124 -0
  31. package/docs/differences.html +4 -0
  32. package/docs/documentation.html +21 -0
  33. package/docs/domHelper.html +88 -0
  34. package/docs/dynamicInvoke.html +36 -0
  35. package/docs/entityAccessor.html +22 -0
  36. package/docs/errors.html +47 -0
  37. package/docs/escaping.html +76 -0
  38. package/docs/favicon.png +0 -0
  39. package/docs/healthCheck.html +66 -0
  40. package/docs/httpHeaders.html +78 -0
  41. package/docs/index.html +64 -0
  42. package/docs/installation.html +34 -0
  43. package/docs/license.html +208 -0
  44. package/docs/messageCenter.html +80 -0
  45. package/docs/methodLevelRepresentation.html +12 -0
  46. package/docs/midSourcing.html +19 -0
  47. package/docs/observability.html +169 -0
  48. package/docs/passwords.html +27 -0
  49. package/docs/profiles.html +103 -0
  50. package/docs/pushDown.html +13 -0
  51. package/docs/quickstart.html +69 -0
  52. package/docs/release.html +52 -0
  53. package/docs/samples.html +82 -0
  54. package/docs/simpleJson.html +88 -0
  55. package/docs/soapAPIs.html +234 -0
  56. package/docs/timeouts.html +23 -0
  57. package/docs/transport.html +45 -0
  58. package/docs/troubleshooting.html +17 -0
  59. package/docs/writeDoc.html +208 -0
  60. package/docs/xml2json.html +96 -0
  61. package/docs/xtkCaster.html +67 -0
  62. package/docs/xtkInterface.html +20 -0
  63. package/docs/xtkOption.html +54 -0
  64. package/docs/xtkPackage.html +16 -0
  65. package/docs/xtkPersist.html +213 -0
  66. package/docs/xtkQueryDef.html +245 -0
  67. package/docs/xtkSchema.html +39 -0
  68. package/docs/xtkSession.html +29 -0
  69. package/docs/xtkWorkflow.html +28 -0
  70. package/docs/xtkWrite.html +51 -0
  71. package/package-lock.json +1 -1
  72. package/package.json +1 -1
  73. package/src/campaign.js +1 -1
  74. package/src/soap.js +6 -6
  75. package/test/soap.test.js +13 -0
  76. package/CHANGELOG.md +0 -252
@@ -0,0 +1,47 @@
1
+ ---
2
+ layout: page
3
+ title: Handling Errors
4
+ ---
5
+
6
+
7
+ <p>If an API call fails (SOAP fault or HTTP error), <b>CampaignException</b> object is thrown. This object contains the following attributes</p>
8
+
9
+ <li><b>message</b> a message describing the error</li>
10
+ <li><b>statusCode</b> a HTTP status code. In case of a SOAP fault, the status code will be 500
11
+ <li><b>errorCode</b> the Campaign error code if one is available (ex: XSV-350013)
12
+ <li><b>methodCall</b> the SOAP call which caused the error. It will contain the following attributes
13
+ <ul>
14
+ <li><b>type</b> the type of the API call ("SOAP" or "HTTP")
15
+ <li><b>urn</b> the SOAP call URN, i.e. the schema id. Will be empty for HTTP methods
16
+ <li><b>url</b> the HTTP URL
17
+ <li><b>methodName</b> the name of the SOAP method. For HTTP methods, the query path
18
+ <li><b>request</b> the raw SOAP request, as text. For HTTP requests, this is an option object containing details about the request
19
+ <li><b>response</b> the raw SOAP/HTTP response, as text
20
+ </ul>
21
+ <li><b>faultCode</b> for SOAP faults, the Campaign error code
22
+ <li><b>faultString</b> the error message
23
+ <li><b>detail</b> optional additional details about the error
24
+
25
+ <p>
26
+ In general all errors are mapped to a CampaignException and we try to keep the semantic of errors: for instance a call with an incorrect parameter will return an HTTP stauts of 400 even if it's not actually a, HTTP call. SDK specific errors will have an errorCode with the "SDK-######" format, using "SDK" as a prefix.
27
+ </p>
28
+
29
+ <pre class="code">
30
+ try {
31
+ await client.logon();
32
+ result = await NLWS.xtkSession.getServerTime();
33
+ } catch (ex) {
34
+ /*
35
+ CampaignException object
36
+ <span class="emphasis">ex.statusCode</span>: the HTTP status code, such as 500, 404…
37
+ <span class="emphasis">ex.errorCode</span> the Campaign error code (ex: XSV-350013)
38
+ <span class="emphasis">ex.faultCode</span> the Campaign iRc or some other error code (ex: -53)
39
+ <span class="emphasis">ex.faultString</span> the Error message
40
+ */
41
+ console.log(ex.message);
42
+ }
43
+ </pre>
44
+
45
+ <p>
46
+ It's also noteworthy that all the data returned in a CampaignException is trimmed, i.e. session and security token values are hidden, so that the exception object can be safely logged.
47
+ </p>
@@ -0,0 +1,76 @@
1
+ ---
2
+ layout: page
3
+ title: Escaping
4
+ ---
5
+
6
+
7
+ <p>It's common to use variables in query conditions. For instance, in the above example, you'll want to query an account by name instead of using the hardcoded <b>ffda</b> name. The <b>expr</b> attribute takes an XTK expression as a parameter, and <b>ffda</b> is a string litteral in an xtk expression.</p>
8
+
9
+ <p>To prevent xtk ingestions vulnerabilities, you should not concatenate strings and write code such as expr: "@name = '" + name + "'": if the value of the name
10
+ parameter contains single quotes, your code will not work, but could also cause vulnerabilities.
11
+ </p>
12
+
13
+
14
+ <h1>sdk.escapeXtk</h1>
15
+
16
+ <p>The <b>sdk.escapeXtk</b> can be used to properly escape string litterals in xtk expressions. The function will also surround the escaped value with single quotes.</p>
17
+
18
+ <p>You can use string concatenation like this. Note the lack of single quotes around the value.</p>
19
+ <pre class="code">
20
+ { expr: "@name=" + sdk.escapeXtk(name) }
21
+ </pre>
22
+
23
+ <p>or a template litteral</p>
24
+ <pre class="code">
25
+ `{ expr: "@name=${sdk.escapeXtk(name)}" }`
26
+ </pre>
27
+
28
+ <p>The <b>escapeXtk</b> function can also be used to create tagged string litterals. This leads to a much shorter syntax. Note that with this syntax, only the parameter values of the template litteral are escaped</p>
29
+ <pre class="code">
30
+ sdk.escapeXtk`{ expr: "@name=${name}" }`
31
+ </pre>
32
+
33
+ <p>This can also be used to escape other data types such as timestamps</p>
34
+
35
+ <pre class="code">
36
+ sdk.escapeXtk`{ expr: "@lastModified > = ${yesterday}" }`
37
+ </pre>
38
+
39
+ <p>will return</p>
40
+ <pre class="code">
41
+ { expr: "@lastModified > = #2021-07-07T10:03:33.332Z# }`
42
+ </pre>
43
+
44
+
45
+ <h1>sdk.escapeForLike</h1>
46
+
47
+ <p>This function escapes values so that they can be used in SQL or XTK like conditions. For example a search term "term" can be escaped as follows to implement a search conditions</p>
48
+
49
+ <pre class="code">
50
+ expr: `Lower([${xpath}]) LIKE '%${sdk.escapeForLike(term)}%'`,
51
+ </pre>
52
+
53
+
54
+ <h1>sdk.expandXPath & sdk.unexpandXPath</h1>
55
+
56
+ <p>In Campaign, xpaths are used to access attributes of entities. When XPaths are used in XTK expressions, there can be ambiguities, for instance, in the expression "country/@name", is "country/@name" a xpath or are we dividing the variable country by the value of the attribute @name?</p>
57
+
58
+ <p>Amibiguity can be resolved by "expanding" the xpath from "country/@name" to "[country/@name]". The square brackets indicate an xpath.</p>
59
+
60
+ <pre class="code">
61
+ const expandedXPath = sdk.expandXPath(xpath);
62
+ const unexpandedXPath = sdk.unexpandXPath(expandedXPath);
63
+ </pre>
64
+
65
+
66
+
67
+ <h1>xtkConstText</h1>
68
+
69
+ <p>This function allows to convert literal values to xtk text constants, providing correct serialization. For instance, text constants will be quoted with single quotes, timestamps with the "#" character, etc.</p>
70
+
71
+ <pre class="code">
72
+ expect(sdk.xtkConstText("Hello", "string")).toBe("'Hello'");
73
+ expect(sdk.xtkConstText(-42.3, "double")).toBe("-42.3");
74
+ expect(sdk.xtkConstText("2022-02-15T09:49:04.000Z", "datetime"))
75
+ .toBe("#2022-02-15T09:49:04.000Z#");
76
+ </pre>
Binary file
@@ -0,0 +1,66 @@
1
+ ---
2
+ layout: page
3
+ title: Health Check
4
+ ---
5
+
6
+ <p>Campaign proposes several APIs for health check. Just like all APIs in the SDK, it's been wrapped into a function and will return a XML or JSON object depending on the current representation</p>
7
+
8
+ <h1>/r/test</h1>
9
+ <p>This API is anonymous and run directly on the Apache front server. Note that this API will failed if called on a tomcat endpoint (port 8080)</p>
10
+ <pre class="code">
11
+ const test = await client.test();
12
+ </pre>
13
+
14
+ <p>will return</p>
15
+ <pre class="code">
16
+ {
17
+ "status":"OK",
18
+ "date":"2021-08-27 03:06:02.941-07",
19
+ "build":"9236",
20
+ "sha1":"cc45440",
21
+ "instance":"xxx_mkt_prod1",
22
+ "sourceIP":"193.104.215.11",
23
+ "host":"xxx.campaign.adobe.com",
24
+ "localHost":"xxx-mkt-prod1-1"
25
+ }
26
+ </pre>
27
+
28
+ <p class="info">Note: as this API is anonymous, one does not need to actually log on to Campaign to call it. Here's a full example. See the authentication section for more details about anonymous logon.
29
+ </p>
30
+ <pre class="code">
31
+ const connectionParameters = sdk.ConnectionParameters.ofAnonymousUser("https://...");
32
+ const client = await sdk.init(connectionParameters);
33
+ const test = await client.test();
34
+ </pre>
35
+
36
+
37
+ <h1>ping</h1>
38
+ <p>The ping API is authenticated and will return a simple status code indicating the the Campaign server is running. It will also return the current database timestamp. The API itself will return plain text, but for convenience this has been wrapped into JSON / XML in the SDK</p>
39
+ <pre class="code">
40
+ const ping = await client.ping();
41
+ </pre>
42
+
43
+ <p>will return</p>
44
+ <pre class="code">
45
+ {
46
+ "status":"Ok",
47
+ "timestamp":"2021-08-27 12:51:56.088Z"
48
+ }
49
+ </pre>
50
+
51
+
52
+ <h1>mcPing</h1>
53
+ <p>Message Center instances have a dedicated ping API which also returns the Message Center queue size and the maximum expected size (threshold). The API itself will return plain text, but for convenience this has been wrapped into JSON / XML in the SDK</p>
54
+ <pre class="code">
55
+ const ping = await client.mcPing();
56
+ </pre>
57
+
58
+ <p>will return</p>
59
+ <pre class="code">
60
+ {
61
+ "status":"Ok",
62
+ "timestamp":"2021-08-27 12:51:56.088Z",
63
+ "eventQueueSize":"7",
64
+ "eventQueueMaxSize":"400"
65
+ }
66
+ </pre>
@@ -0,0 +1,78 @@
1
+ ---
2
+ layout: page
3
+ title: HTTP Headers
4
+ ---
5
+
6
+ <h1>Out-of-the-box headers</h1>
7
+ <p>In version 1.1.3 and above, the SDK will pass additional HTTP headers automatically</p>
8
+
9
+
10
+ <table>
11
+ <thead>
12
+ <tr>
13
+ <th>Header</th>
14
+ <th>Comment / Description</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <tr>
19
+ <td>SOAPAction</td>
20
+ <td>name of the schema and SOAP method (ex: xtk:query#ExecuteQuery)</td>
21
+ </tr>
22
+ <tr>
23
+ <td>ACC-SDK-Version</td>
24
+ <td>Version of the SDK making the scores</td>
25
+ </tr>
26
+ <tr>
27
+ <td>ACC-SDK-Auth</td>
28
+ <td>Authentification type and ACC user</td>
29
+ </tr>
30
+ <tr>
31
+ <td>ACC-SDK-Client-App</td>
32
+ <td>Name of the application calling the client SDK</td>
33
+ </tr>
34
+ <tr>
35
+ <td>ACC-SDK-Call-RetryCount</td>
36
+ <td>In case an API call is retried, indicates the number of retries</td>
37
+ </tr>
38
+ <tr>
39
+ <td>ACC-SDK-Call-Internal</td>
40
+ <td>Indicates that an API call is performed byt the SDK for its own purpose</td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+
45
+ <p>The <b>ACC-SDK</b> headers can be removed using the connection parameter <b>noSDKHeaders</b>.</p>
46
+
47
+
48
+
49
+
50
+ <h1>Custom HTTP headers</h1>
51
+ <p>In version 1.1.3 and above, it is possible to pass additional HTTP headers or override HTTP headers set by the SDK. This can be done globally (i.e. for all API calls), or locally, i.e. just for a particular call, or both.</p>
52
+
53
+ <p>Http headers are passed through an object whose keys represent the header name and values the corresponding header value. Nothing particular is done in term of case sensitivity, headers will be passed as passed.</p>
54
+
55
+ <p>To set global HTTP headers for all API calls of a client, pass an http headers array in the connection parameters</p>
56
+
57
+ <pre class="code">
58
+ const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
59
+ "https://myInstance.campaign.adobe.com",
60
+ "admin", "admin",
61
+ { extraHttpHeaders: {
62
+ "X-ACC-JS-SDK-LBSAFE": "1",
63
+ "X-ACC-WEBUI-VERSION: "1.2"
64
+ } });
65
+ </pre>
66
+
67
+
68
+ <p>Subsequent API calls will have the corresponding headers set.</p>
69
+
70
+ <p>To set more HTTP headers for a particular API call, use the "headers" method of the NLWS object.</p>
71
+
72
+ <pre class="code">
73
+ const query = client.NLWS
74
+ .headers({'X-Test': 'hello'})
75
+ .xtkQueryDef.create(queryDef);
76
+ await query.executeQuery();
77
+ </pre>
78
+
@@ -0,0 +1,64 @@
1
+ ---
2
+ layout: home
3
+ title: ACC JS SDK Home
4
+ ---
5
+
6
+ <p>The <b>ACC JavaScript SDK</b> is a JavaScript SDK which allows you to call Campaign APIs in a simple, expressive and JavaScript idiomatic way. It hides away the Campaign complexities associated with having to make SOAP calls, XML to JSON conversion, type formatting, etc.</p>
7
+
8
+ <p>The API is fully asynchronous using promises and works as well on the server side than on the client side in the browser.</p>
9
+
10
+ <button class="cta" onclick="location.href='./connecting.html'">View the docs</button>
11
+
12
+ <!--
13
+ <div class="card-row">
14
+ <div class="card">
15
+ <h1>Simple</h1>
16
+ </div>
17
+ <div class="card">
18
+ <h1>Light</h1>
19
+ </div>
20
+ </div>
21
+ -->
22
+
23
+ <div class="marquee">Get up and running in seconds</div>
24
+
25
+ <p>Install</p>
26
+
27
+ <pre class="code">
28
+ npm install --save @adobe/acc-js-sdk
29
+ </pre>
30
+
31
+ <p></p>
32
+ <p>Use</p>
33
+ <pre class="code">
34
+ const sdk = require('@adobe/acc-js-sdk');
35
+
36
+ (async () => {
37
+ // Logon to a Campaign instance with user and password
38
+ const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
39
+ "https://myInstance.campaign.adobe.com",
40
+ "admin", "admin");
41
+ const client = await sdk.init(connectionParameters);
42
+ await client.logon();
43
+
44
+ // Get recipients
45
+ const queryDef = {
46
+ schema: "nms:recipient",
47
+ operation: "select",
48
+ lineCount: 10,
49
+ select: {
50
+ node: [
51
+ { expr: "@id" },
52
+ { expr: "@firstName" },
53
+ { expr: "@lastName" },
54
+ { expr: "@email" }
55
+ ]
56
+ }
57
+ };
58
+ const query = client.NLWS.xtkQueryDef.create(queryDef);
59
+ const recipients = await query.executeQuery();
60
+ console.log(`Recipients: ${JSON.stringify(recipients)}`);
61
+ })().catch((error) => {
62
+ console.log(error);
63
+ });
64
+ </pre>
@@ -0,0 +1,34 @@
1
+ ---
2
+ layout: page
3
+ title: Installation
4
+ ---
5
+
6
+ <p>Install
7
+ </p>
8
+ <pre class="code">
9
+ npm install --save @adobe/acc-js-sdk
10
+ </pre>
11
+
12
+ <p>The SDK entrypoint is the <b>sdk</b> object from which everything else can be created.
13
+ </p>
14
+
15
+ <pre class="code">
16
+ const sdk = require('@adobe/acc-js-sdk');
17
+ </pre>
18
+
19
+ <p>You can get version information about the SDK
20
+ </p>
21
+
22
+ <pre class="code">
23
+ console.log(sdk.getSDKVersion());
24
+ </pre>
25
+
26
+ <p>which will return the SDK name and version (the actual name and version number will depend on the version you have installed)
27
+ </p>
28
+ <pre class="code">
29
+ {
30
+ version: "1.0.0",
31
+ name: "@adobe/acc-js-sdk",
32
+ description: "ACC Javascript SDK",
33
+ }
34
+ </pre>
@@ -0,0 +1,208 @@
1
+ ---
2
+ layout: page
3
+ title: License
4
+ ---
5
+
6
+ <pre class="license">
7
+ Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+ APPENDIX: How to apply the Apache License to your work.
185
+
186
+ To apply the Apache License to your work, attach the following
187
+ boilerplate notice, with the fields enclosed by brackets "[]"
188
+ replaced with your own identifying information. (Don't include
189
+ the brackets!) The text should be enclosed in the appropriate
190
+ comment syntax for the file format. We also recommend that a
191
+ file or class name and description of purpose be included on the
192
+ same "printed page" as the copyright notice for easier
193
+ identification within third-party archives.
194
+
195
+ Copyright 2020 Adobe
196
+
197
+ Licensed under the Apache License, Version 2.0 (the "License");
198
+ you may not use this file except in compliance with the License.
199
+ You may obtain a copy of the License at
200
+
201
+ http://www.apache.org/licenses/LICENSE-2.0
202
+
203
+ Unless required by applicable law or agreed to in writing, software
204
+ distributed under the License is distributed on an "AS IS" BASIS,
205
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
206
+ See the License for the specific language governing permissions and
207
+ limitations under the License.
208
+ </pre>
@@ -0,0 +1,80 @@
1
+ ---
2
+ layout: page
3
+ title: Message Center
4
+ ---
5
+
6
+
7
+ <p>The Message Center API (<b>nms:rtEvent#PushEvent</b>) can be used to send transactional messages. It should be called on the Message Center execution instances, not on the marketing instances.</p>
8
+
9
+ <h1>Authentication</h1>
10
+ <p>Two authentication mechanism are possible for Message Center. It is possible to use a user/password authentication and call the Logon method to get a session and security token, as all other APIs. When using this authentication mechanism, the caller is responsible to handle token expiration and must explicitely handle the case when the Message Center API call fails because of an expired token.</p>
11
+
12
+ <p>Another common authentication strategy is to define a trusted Security Zone for message center clients and setup this security zone to use the "user/password" as a session token.</p>
13
+
14
+ <p>Here's an example of authentication with this method</p>
15
+ <pre class="code">
16
+ const connectionParameters = sdk.ConnectionParameters.ofSessionToken(url, "mc/mc");
17
+ const client = await sdk.init(connectionParameters);
18
+ </pre>
19
+
20
+
21
+
22
+
23
+
24
+
25
+ <h1>Pushing events</h1>
26
+
27
+ <p>Events can be pushed using the <b>nms:rtEvent#PushEvent</b> API call. For instance</p>
28
+ <pre class="code">
29
+ var result = await NLWS.nmsRtEvent.pushEvent({
30
+ wishedChannel: 0,
31
+ type: "welcome",
32
+ email: "aggmorin@gmail.com",
33
+ ctx: {
34
+ $title: "Alex"
35
+ }
36
+ });
37
+ console.log(`>> Result: ${result}`);
38
+ </pre>
39
+
40
+ <p>There are a couple of noteworthy things to say about this API when using SimpleJson serialization.</p>
41
+ <ul>
42
+ <li>The payload passed to the pushEvent API call is actuall a nms:rtEvent entity. Hence the wishedChannel, etc. are actually XML attributes. The default SimpleJson conversion works fine here, no need to prefix the attributes with the "@" sign.</li>
43
+ <li>However, the <b>ctx</b> section is not structured. We do not have a schema to validate or guide the conversion. It is common to use XML elements instead of attributes in the ctx context. In the message center template, you'll find things like <b>&lt;%= rtEvent.ctx.title %></b>. The fact that "title" is used (in stead of "@title") implied that the ctx node will contain a title element, not a title attribute. For the SimpleJson conversion to work, it's therefore important to indicate "$title" as the JSON attribute name. This will guide the SimpleJson converted to use an XML element instead of an XML attribute</li>
44
+ </ul>
45
+
46
+ <h1>Getting event status</h1>
47
+
48
+ <p class="warning">There's no scalable API to get the status of a message center event. One can use the QueryDef API to query the nms:rtEvent table for testing purpose though.</p>
49
+
50
+ <p>To do so, the first step is to decode the event id returned by PushEvent. It is a 64 bit number, whose high byte is the message center cell (instance) id which handled the event. It's a number between 0 and 255. The lower bytes represent the primary key of the event. Note that this is subject to change in future versions of Campaign and should not be considered stable.</p>
51
+
52
+ <p>Clear high byte</p>
53
+ <pre class="code">
54
+ eventId = Number(BigInt(eventId) & BigInt("0xFFFFFFFFFFFFFF"));
55
+ </pre>
56
+
57
+ <p>Get event status</p>
58
+ <pre class="code">
59
+ var queryDef = {
60
+ schema: "nms:rtEvent",
61
+ operation: "get",
62
+ select: {
63
+ node: [
64
+ { expr: "@id" },
65
+ { expr: "@status" },
66
+ { expr: "@created" },
67
+ { expr: "@processing" },
68
+ { expr: "@processed" }
69
+ ]
70
+ },
71
+ where: {
72
+ condition: [
73
+ { expr:`@id=${eventId}` }
74
+ ]
75
+ }
76
+ }
77
+ query = NLWS.xtkQueryDef.create(queryDef);
78
+ var event = await query.executeQuery();
79
+ console.log(`>> Event: ${JSON.stringify(event)}`);
80
+ </pre>
@@ -0,0 +1,12 @@
1
+ ---
2
+ layout: page
3
+ title: Method-level representation
4
+ ---
5
+
6
+ <p>The client object is created with a default representation which is used for all API calls in the context of this client. Since version 1.1.2, it is also possible to set the representation at the method level, i.e. use a particular representation for a particular API call.</p>
7
+
8
+ <ul>
9
+ <li> <b>client.NLWS</b>: use the default representation set at the client level</li>
10
+ <li> <b>client.NLWS.xml</b>: use the XML reresentation</li>
11
+ <li> <b>client.NLWS.json</b>: use the SimpleJson representation</li>
12
+ </ul>