@drttix/drt-sdk 0.6.5 → 0.7.0
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.
- package/azure-pipelines.yml +15 -6
- package/demo/default.html +2 -1
- package/demo/test.html +529 -102
- package/demo/with-base.html +10 -8
- package/dist/bundle/drt-sdk.js +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/cjs/src/generated/portal/core/request.js +3 -1
- package/dist/cjs/src/generated/portal/services/AccountService.d.ts +12 -2
- package/dist/cjs/src/generated/portal/services/AccountService.js +26 -2
- package/dist/cjs/src/generated/portal/services/AuthService.d.ts +2 -1
- package/dist/cjs/src/generated/portal/services/AuthService.js +5 -1
- package/dist/cjs/src/generated/portal/services/FeaturesBlockedSeatsService.d.ts +10 -7
- package/dist/cjs/src/generated/portal/services/FeaturesBlockedSeatsService.js +19 -7
- package/dist/cjs/src/generated/portal/services/OrderLookupService.d.ts +4 -3
- package/dist/cjs/src/generated/portal/services/OrderLookupService.js +7 -3
- package/dist/cjs/src/generated/scanner/core/request.d.ts +7 -10
- package/dist/cjs/src/generated/scanner/core/request.js +56 -37
- package/dist/cjs/src/generated/shopper/core/request.js +3 -1
- package/dist/cjs/src/scripts/build-all.js +9 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/esm/src/generated/portal/core/request.js +3 -1
- package/dist/esm/src/generated/portal/services/AccountService.d.ts +12 -2
- package/dist/esm/src/generated/portal/services/AccountService.js +26 -2
- package/dist/esm/src/generated/portal/services/AuthService.d.ts +2 -1
- package/dist/esm/src/generated/portal/services/AuthService.js +5 -1
- package/dist/esm/src/generated/portal/services/FeaturesBlockedSeatsService.d.ts +10 -7
- package/dist/esm/src/generated/portal/services/FeaturesBlockedSeatsService.js +19 -7
- package/dist/esm/src/generated/portal/services/OrderLookupService.d.ts +4 -3
- package/dist/esm/src/generated/portal/services/OrderLookupService.js +7 -3
- package/dist/esm/src/generated/scanner/core/request.d.ts +7 -10
- package/dist/esm/src/generated/scanner/core/request.js +58 -39
- package/dist/esm/src/generated/shopper/core/request.js +3 -1
- package/dist/esm/src/scripts/build-all.js +9 -1
- package/index.ts +5 -0
- package/package.json +3 -1
- package/src/custom/custom-request.txt +7 -2
- package/src/generated/portal/core/OpenAPI.ts +1 -1
- package/src/generated/portal/core/request.ts +7 -2
- package/src/generated/portal/services/AccountService.ts +30 -1
- package/src/generated/portal/services/AuthService.ts +7 -1
- package/src/generated/portal/services/FeaturesBlockedSeatsService.ts +23 -6
- package/src/generated/portal/services/OrderLookupService.ts +7 -2
- package/src/generated/scanner/core/request.ts +331 -266
- package/src/generated/shopper/core/request.ts +7 -2
- package/src/scripts/build-all.ts +14 -1
package/demo/test.html
CHANGED
|
@@ -3,42 +3,103 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<title>DRT SDK Test Page</title>
|
|
6
|
+
<link rel="icon" href="data:," />
|
|
6
7
|
<style>
|
|
8
|
+
* {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
7
11
|
body {
|
|
8
12
|
font-family: system-ui, sans-serif;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
display: flex;
|
|
16
|
+
height: 100vh;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
.main-container {
|
|
20
|
+
display: flex;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100vh;
|
|
23
|
+
background: #fff;
|
|
24
|
+
}
|
|
25
|
+
.left-panel {
|
|
26
|
+
flex: 1;
|
|
27
|
+
overflow-y: auto;
|
|
28
|
+
padding: 1rem 2rem;
|
|
29
|
+
}
|
|
30
|
+
.right-panel {
|
|
31
|
+
flex: 1;
|
|
32
|
+
background: #1e1e1e;
|
|
33
|
+
color: #d4d4d4;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
border-left: 1px solid #333;
|
|
37
|
+
position: sticky;
|
|
38
|
+
top: 0;
|
|
39
|
+
height: 100vh;
|
|
40
|
+
}
|
|
41
|
+
.right-panel h2 {
|
|
42
|
+
color: #fff;
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 1rem;
|
|
45
|
+
background: #2d2d2d;
|
|
46
|
+
border-bottom: 1px solid #444;
|
|
47
|
+
font-size: 1rem;
|
|
12
48
|
}
|
|
13
49
|
h1 {
|
|
14
50
|
color: #333;
|
|
51
|
+
margin-top: 0;
|
|
15
52
|
}
|
|
16
53
|
h2 {
|
|
17
54
|
color: #555;
|
|
18
55
|
margin-top: 2rem;
|
|
56
|
+
border-bottom: 1px solid #ddd;
|
|
57
|
+
padding-bottom: 0.5rem;
|
|
58
|
+
}
|
|
59
|
+
h3 {
|
|
60
|
+
color: #666;
|
|
61
|
+
margin-top: 1.5rem;
|
|
19
62
|
}
|
|
20
63
|
button {
|
|
21
64
|
padding: 0.5rem 1rem;
|
|
22
|
-
font-size:
|
|
65
|
+
font-size: 0.9rem;
|
|
23
66
|
cursor: pointer;
|
|
24
67
|
margin: 0.25rem;
|
|
68
|
+
border: 1px solid #ccc;
|
|
69
|
+
border-radius: 4px;
|
|
70
|
+
background: #fff;
|
|
25
71
|
}
|
|
26
|
-
|
|
27
|
-
background: #
|
|
28
|
-
|
|
72
|
+
button:hover {
|
|
73
|
+
background: #f0f0f0;
|
|
74
|
+
}
|
|
75
|
+
button:disabled {
|
|
76
|
+
opacity: 0.5;
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
}
|
|
79
|
+
#output-container {
|
|
80
|
+
flex: 1;
|
|
29
81
|
overflow: auto;
|
|
30
|
-
|
|
31
|
-
|
|
82
|
+
padding: 1rem;
|
|
83
|
+
}
|
|
84
|
+
pre {
|
|
85
|
+
background: transparent;
|
|
86
|
+
margin: 0;
|
|
87
|
+
white-space: pre-wrap;
|
|
88
|
+
word-wrap: break-word;
|
|
89
|
+
font-size: 0.85rem;
|
|
90
|
+
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
|
|
32
91
|
}
|
|
33
92
|
.success {
|
|
34
|
-
color:
|
|
93
|
+
color: #4ec9b0;
|
|
35
94
|
}
|
|
36
95
|
.error {
|
|
37
|
-
color:
|
|
96
|
+
color: #f48771;
|
|
38
97
|
}
|
|
39
98
|
#status {
|
|
40
|
-
|
|
99
|
+
padding: 0.5rem 1rem;
|
|
41
100
|
font-weight: bold;
|
|
101
|
+
background: #252526;
|
|
102
|
+
border-bottom: 1px solid #444;
|
|
42
103
|
}
|
|
43
104
|
.config-form {
|
|
44
105
|
background: #f9f9f9;
|
|
@@ -49,60 +110,261 @@
|
|
|
49
110
|
.config-form label {
|
|
50
111
|
display: block;
|
|
51
112
|
margin: 0.5rem 0 0.25rem;
|
|
113
|
+
font-weight: 500;
|
|
52
114
|
}
|
|
53
115
|
.config-form input {
|
|
54
116
|
width: 100%;
|
|
55
117
|
padding: 0.5rem;
|
|
56
118
|
font-size: 1rem;
|
|
57
119
|
box-sizing: border-box;
|
|
120
|
+
border: 1px solid #ccc;
|
|
121
|
+
border-radius: 4px;
|
|
122
|
+
}
|
|
123
|
+
.btn-group {
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-wrap: wrap;
|
|
126
|
+
gap: 0.5rem;
|
|
127
|
+
margin: 0.5rem 0;
|
|
128
|
+
}
|
|
129
|
+
.input-row {
|
|
130
|
+
display: flex;
|
|
131
|
+
gap: 0.5rem;
|
|
132
|
+
align-items: center;
|
|
133
|
+
margin: 0.5rem 0;
|
|
134
|
+
}
|
|
135
|
+
.input-row input {
|
|
136
|
+
flex: 1;
|
|
137
|
+
padding: 0.4rem;
|
|
138
|
+
font-size: 0.9rem;
|
|
139
|
+
}
|
|
140
|
+
.input-row label {
|
|
141
|
+
min-width: 80px;
|
|
142
|
+
font-size: 0.85rem;
|
|
143
|
+
}
|
|
144
|
+
.tab-container {
|
|
145
|
+
border-bottom: 2px solid #ddd;
|
|
146
|
+
margin-bottom: 1rem;
|
|
147
|
+
}
|
|
148
|
+
.tab {
|
|
149
|
+
padding: 0.5rem 1rem;
|
|
150
|
+
border: none;
|
|
151
|
+
background: none;
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
font-size: 1rem;
|
|
154
|
+
}
|
|
155
|
+
.tab.active {
|
|
156
|
+
border-bottom: 2px solid #007bff;
|
|
157
|
+
color: #007bff;
|
|
158
|
+
margin-bottom: -2px;
|
|
159
|
+
}
|
|
160
|
+
.tab-content {
|
|
161
|
+
display: none;
|
|
162
|
+
}
|
|
163
|
+
.tab-content.active {
|
|
164
|
+
display: block;
|
|
165
|
+
}
|
|
166
|
+
code {
|
|
167
|
+
background: #e9e9e9;
|
|
168
|
+
padding: 0.2rem 0.4rem;
|
|
169
|
+
border-radius: 3px;
|
|
170
|
+
font-size: 0.85rem;
|
|
58
171
|
}
|
|
59
172
|
</style>
|
|
60
173
|
</head>
|
|
61
174
|
<body>
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<div class="config-form">
|
|
66
|
-
<label for="shopperGuid">Shopper GUID:</label>
|
|
67
|
-
<input
|
|
68
|
-
type="text"
|
|
69
|
-
id="shopperGuid"
|
|
70
|
-
placeholder="e.g., F1199DCD-BB45-4BD0-8DED600A3A234C75"
|
|
71
|
-
/>
|
|
72
|
-
|
|
73
|
-
<label for="accountId">Account ID:</label>
|
|
74
|
-
<input type="text" id="accountId" placeholder="e.g., 508" />
|
|
75
|
-
|
|
76
|
-
<label for="apiKey">API Key:</label>
|
|
77
|
-
<input type="text" id="apiKey" placeholder="e.g., your-api-key" />
|
|
78
|
-
|
|
79
|
-
<button id="btn-init" style="margin-top: 1rem">
|
|
80
|
-
Initialize SDK
|
|
81
|
-
</button>
|
|
82
|
-
</div>
|
|
175
|
+
<div class="main-container">
|
|
176
|
+
<div class="left-panel">
|
|
177
|
+
<h1>DRT SDK Test Page</h1>
|
|
83
178
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
179
|
+
<h2>1. Initialize SDK</h2>
|
|
180
|
+
<div class="config-form">
|
|
181
|
+
<label for="shopperGuid">Shopper GUID:</label>
|
|
182
|
+
<input
|
|
183
|
+
type="text"
|
|
184
|
+
id="shopperGuid"
|
|
185
|
+
placeholder="e.g., F1199DCD-BB45-4BD0-8DED600A3A234C75"
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
<label for="accountId">Account ID:</label>
|
|
189
|
+
<input type="text" id="accountId" placeholder="e.g., 508" />
|
|
190
|
+
|
|
191
|
+
<label for="apiKey">API Key:</label>
|
|
192
|
+
<input
|
|
193
|
+
type="text"
|
|
194
|
+
id="apiKey"
|
|
195
|
+
placeholder="e.g., your-api-key"
|
|
196
|
+
/>
|
|
197
|
+
|
|
198
|
+
<div style="margin-top: 1rem">
|
|
199
|
+
<button id="btn-init">Initialize SDK</button>
|
|
200
|
+
<button id="btn-check-sdk">Check SDK Status</button>
|
|
201
|
+
<button id="btn-reset">Reset SDK</button>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<h2>2. Test API Calls</h2>
|
|
206
|
+
|
|
207
|
+
<div class="tab-container">
|
|
208
|
+
<button class="tab active" data-tab="shopper">
|
|
209
|
+
Shopper API
|
|
210
|
+
</button>
|
|
211
|
+
<button class="tab" data-tab="scanner">Scanner API</button>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
<!-- SHOPPER API -->
|
|
215
|
+
<div id="tab-shopper" class="tab-content active">
|
|
216
|
+
<h3>Account</h3>
|
|
217
|
+
<p>
|
|
218
|
+
Basic account/site configuration.
|
|
219
|
+
<code>DRT.shopper.account</code>
|
|
220
|
+
</p>
|
|
221
|
+
<div class="btn-group">
|
|
222
|
+
<button id="btn-theme">Get Theme</button>
|
|
223
|
+
<button id="btn-disposition">Get Disposition</button>
|
|
224
|
+
<button id="btn-root">Get Root Config</button>
|
|
225
|
+
<button id="btn-landing">Get Landing Page</button>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<h3>Events</h3>
|
|
229
|
+
<p>
|
|
230
|
+
Event listings and details.
|
|
231
|
+
<code>DRT.shopper.event</code>
|
|
232
|
+
</p>
|
|
233
|
+
<div class="btn-group">
|
|
234
|
+
<button id="btn-events">Get All Events</button>
|
|
235
|
+
</div>
|
|
236
|
+
<div class="input-row">
|
|
237
|
+
<label>Event ID:</label>
|
|
238
|
+
<input
|
|
239
|
+
type="number"
|
|
240
|
+
id="eventId"
|
|
241
|
+
placeholder="e.g., 123"
|
|
242
|
+
/>
|
|
243
|
+
<button id="btn-event-details">
|
|
244
|
+
Get Event Details
|
|
245
|
+
</button>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<h3>Cart</h3>
|
|
249
|
+
<p>
|
|
250
|
+
Shopping cart operations. <code>DRT.shopper.cart</code>
|
|
251
|
+
</p>
|
|
252
|
+
<div class="btn-group">
|
|
253
|
+
<button id="btn-cart">Get Cart</button>
|
|
254
|
+
<button id="btn-delete-cart">Delete Cart</button>
|
|
255
|
+
</div>
|
|
94
256
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
257
|
+
<h3>Orders</h3>
|
|
258
|
+
<p>
|
|
259
|
+
Order receipts and management.
|
|
260
|
+
<code>DRT.shopper.order</code>
|
|
261
|
+
</p>
|
|
262
|
+
<div class="input-row">
|
|
263
|
+
<label>Order GUID:</label>
|
|
264
|
+
<input
|
|
265
|
+
type="text"
|
|
266
|
+
id="orderGuid"
|
|
267
|
+
placeholder="e.g., ABC123-..."
|
|
268
|
+
/>
|
|
269
|
+
<button id="btn-receipt">Get Receipt</button>
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<h3>Codes/Discounts</h3>
|
|
273
|
+
<p>
|
|
274
|
+
Promo codes and discounts. <code>DRT.shopper.code</code>
|
|
275
|
+
</p>
|
|
276
|
+
<div class="input-row">
|
|
277
|
+
<label>Code:</label>
|
|
278
|
+
<input
|
|
279
|
+
type="text"
|
|
280
|
+
id="promoCode"
|
|
281
|
+
placeholder="e.g., SAVE10"
|
|
282
|
+
/>
|
|
283
|
+
<button id="btn-validate-code">Validate Code</button>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<h3>Gift Cards</h3>
|
|
287
|
+
<p>
|
|
288
|
+
Gift card operations. <code>DRT.shopper.giftCard</code>
|
|
289
|
+
</p>
|
|
290
|
+
<div class="input-row">
|
|
291
|
+
<label>Card #:</label>
|
|
292
|
+
<input
|
|
293
|
+
type="text"
|
|
294
|
+
id="giftCardNumber"
|
|
295
|
+
placeholder="Gift card number"
|
|
296
|
+
/>
|
|
297
|
+
<button id="btn-gift-balance">Check Balance</button>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<!-- SCANNER API -->
|
|
302
|
+
<div id="tab-scanner" class="tab-content">
|
|
303
|
+
<h3>Scanning</h3>
|
|
304
|
+
<p>
|
|
305
|
+
Scanner app strings and utilities.
|
|
306
|
+
<code>DRT.scanner.scanning</code>
|
|
307
|
+
</p>
|
|
308
|
+
<div class="btn-group">
|
|
309
|
+
<button id="btn-strings">
|
|
310
|
+
Get App Strings (no auth)
|
|
311
|
+
</button>
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
<h3>Database</h3>
|
|
315
|
+
<p>
|
|
316
|
+
Scanner database operations.
|
|
317
|
+
<code>DRT.scanner.database</code>
|
|
318
|
+
</p>
|
|
319
|
+
<div class="input-row">
|
|
320
|
+
<label>Event ID:</label>
|
|
321
|
+
<input
|
|
322
|
+
type="number"
|
|
323
|
+
id="scannerEventId"
|
|
324
|
+
placeholder="e.g., 123"
|
|
325
|
+
/>
|
|
326
|
+
<button id="btn-scanner-db">Get Database</button>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
<h3>Orders</h3>
|
|
330
|
+
<p>
|
|
331
|
+
Order lookup for scanning.
|
|
332
|
+
<code>DRT.scanner.orders</code>
|
|
333
|
+
</p>
|
|
334
|
+
<div class="input-row">
|
|
335
|
+
<label>Order ID:</label>
|
|
336
|
+
<input
|
|
337
|
+
type="text"
|
|
338
|
+
id="scannerOrderId"
|
|
339
|
+
placeholder="Order ID"
|
|
340
|
+
/>
|
|
341
|
+
<button id="btn-scanner-order">Get Order</button>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<div class="right-panel">
|
|
347
|
+
<h2>Output</h2>
|
|
348
|
+
<div id="status">
|
|
349
|
+
SDK loaded! Initialize with your credentials.
|
|
350
|
+
</div>
|
|
351
|
+
<div id="output-container">
|
|
352
|
+
<pre id="output">
|
|
353
|
+
Initialize the SDK, then click a button to test...</pre
|
|
354
|
+
>
|
|
355
|
+
</div>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
99
358
|
|
|
100
359
|
<script type="module">
|
|
101
|
-
import { DRT } from '
|
|
360
|
+
import { DRT } from '/public/sdk/latest/drt-sdk.js';
|
|
102
361
|
|
|
103
362
|
const out = document.getElementById('output');
|
|
104
363
|
const status = document.getElementById('status');
|
|
105
364
|
|
|
365
|
+
// Expose DRT globally for console testing
|
|
366
|
+
window.DRT = DRT;
|
|
367
|
+
|
|
106
368
|
function setStatus(msg, isError = false) {
|
|
107
369
|
status.textContent = msg;
|
|
108
370
|
status.className = isError ? 'error' : 'success';
|
|
@@ -112,11 +374,51 @@ Initialize the SDK above, then click a button to test...</pre
|
|
|
112
374
|
out.textContent =
|
|
113
375
|
typeof data === 'string'
|
|
114
376
|
? data
|
|
115
|
-
: JSON.stringify(data, null,
|
|
377
|
+
: JSON.stringify(data, null, 4);
|
|
116
378
|
}
|
|
117
379
|
|
|
118
|
-
|
|
119
|
-
|
|
380
|
+
function requireInit() {
|
|
381
|
+
if (!DRT.isReady()) {
|
|
382
|
+
setStatus(
|
|
383
|
+
'SDK not initialized! Please initialize first.',
|
|
384
|
+
true,
|
|
385
|
+
);
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
async function callApi(fn, description) {
|
|
392
|
+
setStatus(`Fetching ${description}...`, false);
|
|
393
|
+
try {
|
|
394
|
+
const result = await fn();
|
|
395
|
+
setStatus('Success!', false);
|
|
396
|
+
setOutput(result);
|
|
397
|
+
} catch (err) {
|
|
398
|
+
setStatus(`Error: ${err.message}`, true);
|
|
399
|
+
setOutput({
|
|
400
|
+
error: err.message,
|
|
401
|
+
details: err.body || err.toString(),
|
|
402
|
+
});
|
|
403
|
+
console.error(err);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Tab switching
|
|
408
|
+
document.querySelectorAll('.tab').forEach((tab) => {
|
|
409
|
+
tab.addEventListener('click', () => {
|
|
410
|
+
document
|
|
411
|
+
.querySelectorAll('.tab')
|
|
412
|
+
.forEach((t) => t.classList.remove('active'));
|
|
413
|
+
document
|
|
414
|
+
.querySelectorAll('.tab-content')
|
|
415
|
+
.forEach((c) => c.classList.remove('active'));
|
|
416
|
+
tab.classList.add('active');
|
|
417
|
+
document
|
|
418
|
+
.getElementById(`tab-${tab.dataset.tab}`)
|
|
419
|
+
.classList.add('active');
|
|
420
|
+
});
|
|
421
|
+
});
|
|
120
422
|
|
|
121
423
|
// Initialize SDK
|
|
122
424
|
document
|
|
@@ -138,19 +440,11 @@ Initialize the SDK above, then click a button to test...</pre
|
|
|
138
440
|
}
|
|
139
441
|
|
|
140
442
|
try {
|
|
141
|
-
DRT.init({
|
|
142
|
-
shopperGuid,
|
|
143
|
-
accountId,
|
|
144
|
-
apiKey,
|
|
145
|
-
});
|
|
443
|
+
DRT.init({ shopperGuid, accountId, apiKey });
|
|
146
444
|
setStatus('SDK Initialized!', false);
|
|
147
445
|
setOutput({
|
|
148
446
|
message: 'SDK initialized successfully!',
|
|
149
|
-
config: {
|
|
150
|
-
shopperGuid,
|
|
151
|
-
accountId,
|
|
152
|
-
apiKey: '***', // Don't show full key
|
|
153
|
-
},
|
|
447
|
+
config: { shopperGuid, accountId, apiKey: '***' },
|
|
154
448
|
});
|
|
155
449
|
} catch (err) {
|
|
156
450
|
setStatus('Init failed: ' + err.message, true);
|
|
@@ -181,59 +475,192 @@ Initialize the SDK above, then click a button to test...</pre
|
|
|
181
475
|
});
|
|
182
476
|
});
|
|
183
477
|
|
|
184
|
-
//
|
|
478
|
+
// Reset SDK
|
|
185
479
|
document
|
|
186
|
-
.getElementById('btn-
|
|
187
|
-
.addEventListener('click',
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
setOutput(strings);
|
|
194
|
-
} catch (err) {
|
|
195
|
-
setStatus('Error: ' + err.message, true);
|
|
196
|
-
setOutput({
|
|
197
|
-
error: err.message,
|
|
198
|
-
details: err.toString(),
|
|
199
|
-
});
|
|
200
|
-
console.error(err);
|
|
201
|
-
}
|
|
480
|
+
.getElementById('btn-reset')
|
|
481
|
+
.addEventListener('click', () => {
|
|
482
|
+
DRT.reset();
|
|
483
|
+
setStatus('SDK Reset!', false);
|
|
484
|
+
setOutput({
|
|
485
|
+
message: 'SDK has been reset. Initialize again to use.',
|
|
486
|
+
});
|
|
202
487
|
});
|
|
203
488
|
|
|
204
|
-
//
|
|
489
|
+
// ==================== SHOPPER API ====================
|
|
490
|
+
|
|
491
|
+
// Account
|
|
205
492
|
document
|
|
206
493
|
.getElementById('btn-theme')
|
|
207
|
-
.addEventListener('click',
|
|
208
|
-
if (!
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
494
|
+
.addEventListener('click', () => {
|
|
495
|
+
if (!requireInit()) return;
|
|
496
|
+
callApi(() => DRT.shopper.account.getTheme(), 'theme');
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
document
|
|
500
|
+
.getElementById('btn-disposition')
|
|
501
|
+
.addEventListener('click', () => {
|
|
502
|
+
if (!requireInit()) return;
|
|
503
|
+
callApi(
|
|
504
|
+
() => DRT.shopper.account.getDisposition(),
|
|
505
|
+
'disposition',
|
|
506
|
+
);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
document
|
|
510
|
+
.getElementById('btn-root')
|
|
511
|
+
.addEventListener('click', () => {
|
|
512
|
+
if (!requireInit()) return;
|
|
513
|
+
callApi(() => DRT.shopper.account.getRoot(), 'root config');
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
document
|
|
517
|
+
.getElementById('btn-landing')
|
|
518
|
+
.addEventListener('click', () => {
|
|
519
|
+
if (!requireInit()) return;
|
|
520
|
+
callApi(
|
|
521
|
+
() => DRT.shopper.account.getLanding(),
|
|
522
|
+
'landing page',
|
|
523
|
+
);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// Events
|
|
527
|
+
document
|
|
528
|
+
.getElementById('btn-events')
|
|
529
|
+
.addEventListener('click', () => {
|
|
530
|
+
if (!requireInit()) return;
|
|
531
|
+
callApi(() => DRT.shopper.event.getEvents(), 'events');
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
document
|
|
535
|
+
.getElementById('btn-event-details')
|
|
536
|
+
.addEventListener('click', () => {
|
|
537
|
+
if (!requireInit()) return;
|
|
538
|
+
const id = parseInt(
|
|
539
|
+
document.getElementById('eventId').value,
|
|
540
|
+
);
|
|
541
|
+
if (!id) {
|
|
542
|
+
setStatus('Please enter an Event ID', true);
|
|
213
543
|
return;
|
|
214
544
|
}
|
|
545
|
+
callApi(
|
|
546
|
+
() => DRT.shopper.event.getEventById(id),
|
|
547
|
+
`event ${id}`,
|
|
548
|
+
);
|
|
549
|
+
});
|
|
215
550
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
551
|
+
// Cart
|
|
552
|
+
document
|
|
553
|
+
.getElementById('btn-cart')
|
|
554
|
+
.addEventListener('click', () => {
|
|
555
|
+
if (!requireInit()) return;
|
|
556
|
+
callApi(() => DRT.shopper.cart.getCart(), 'cart');
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
document
|
|
560
|
+
.getElementById('btn-delete-cart')
|
|
561
|
+
.addEventListener('click', () => {
|
|
562
|
+
if (!requireInit()) return;
|
|
563
|
+
callApi(() => DRT.shopper.cart.deleteCart(), 'delete cart');
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// Orders
|
|
567
|
+
document
|
|
568
|
+
.getElementById('btn-receipt')
|
|
569
|
+
.addEventListener('click', () => {
|
|
570
|
+
if (!requireInit()) return;
|
|
571
|
+
const guid = document
|
|
572
|
+
.getElementById('orderGuid')
|
|
573
|
+
.value.trim();
|
|
574
|
+
if (!guid) {
|
|
575
|
+
setStatus('Please enter an Order GUID', true);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
callApi(
|
|
579
|
+
() => DRT.shopper.order.getReceipt(guid),
|
|
580
|
+
'receipt',
|
|
581
|
+
);
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
// Codes
|
|
585
|
+
document
|
|
586
|
+
.getElementById('btn-validate-code')
|
|
587
|
+
.addEventListener('click', () => {
|
|
588
|
+
if (!requireInit()) return;
|
|
589
|
+
const code = document
|
|
590
|
+
.getElementById('promoCode')
|
|
591
|
+
.value.trim();
|
|
592
|
+
if (!code) {
|
|
593
|
+
setStatus('Please enter a code', true);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
callApi(
|
|
597
|
+
() => DRT.shopper.code.validateCode(code),
|
|
598
|
+
`code validation`,
|
|
599
|
+
);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// Gift Cards
|
|
603
|
+
document
|
|
604
|
+
.getElementById('btn-gift-balance')
|
|
605
|
+
.addEventListener('click', () => {
|
|
606
|
+
if (!requireInit()) return;
|
|
607
|
+
const num = document
|
|
608
|
+
.getElementById('giftCardNumber')
|
|
609
|
+
.value.trim();
|
|
610
|
+
if (!num) {
|
|
611
|
+
setStatus('Please enter a gift card number', true);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
callApi(
|
|
615
|
+
() => DRT.shopper.giftCard.getBalance(num),
|
|
616
|
+
'gift card balance',
|
|
617
|
+
);
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
// ==================== SCANNER API ====================
|
|
621
|
+
|
|
622
|
+
document
|
|
623
|
+
.getElementById('btn-strings')
|
|
624
|
+
.addEventListener('click', () => {
|
|
625
|
+
callApi(
|
|
626
|
+
() => DRT.scanner.scanning.appControllerGetStrings(),
|
|
627
|
+
'scanner strings',
|
|
628
|
+
);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
document
|
|
632
|
+
.getElementById('btn-scanner-db')
|
|
633
|
+
.addEventListener('click', () => {
|
|
634
|
+
const eventId = parseInt(
|
|
635
|
+
document.getElementById('scannerEventId').value,
|
|
636
|
+
);
|
|
637
|
+
if (!eventId) {
|
|
638
|
+
setStatus('Please enter an Event ID', true);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
callApi(
|
|
642
|
+
() => DRT.scanner.database.getDatabase(eventId),
|
|
643
|
+
`scanner database`,
|
|
644
|
+
);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
document
|
|
648
|
+
.getElementById('btn-scanner-order')
|
|
649
|
+
.addEventListener('click', () => {
|
|
650
|
+
const orderId = document
|
|
651
|
+
.getElementById('scannerOrderId')
|
|
652
|
+
.value.trim();
|
|
653
|
+
if (!orderId) {
|
|
654
|
+
setStatus('Please enter an Order ID', true);
|
|
655
|
+
return;
|
|
229
656
|
}
|
|
657
|
+
callApi(
|
|
658
|
+
() => DRT.scanner.orders.getOrder(orderId),
|
|
659
|
+
`scanner order`,
|
|
660
|
+
);
|
|
230
661
|
});
|
|
231
662
|
|
|
232
663
|
// Auto-check on load
|
|
233
|
-
setStatus(
|
|
234
|
-
'SDK loaded! Initialize with your credentials above.',
|
|
235
|
-
false,
|
|
236
|
-
);
|
|
237
664
|
console.log('DRT SDK available at window.DRT for console testing');
|
|
238
665
|
</script>
|
|
239
666
|
</body>
|