@bytexbyte/ike-app-api 1.0.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.
Files changed (42) hide show
  1. package/README.md +17 -0
  2. package/lib/App.d.ts +23 -0
  3. package/lib/App.js +126 -0
  4. package/lib/Auth/index.d.ts +156 -0
  5. package/lib/Auth/index.js +392 -0
  6. package/lib/Auth/type.d.ts +73 -0
  7. package/lib/Auth/type.js +2 -0
  8. package/lib/Batch/index.d.ts +26 -0
  9. package/lib/Batch/index.js +136 -0
  10. package/lib/Contract/index.d.ts +26 -0
  11. package/lib/Contract/index.js +109 -0
  12. package/lib/DigitalCustomization/index.d.ts +34 -0
  13. package/lib/DigitalCustomization/index.js +128 -0
  14. package/lib/DigitalCustomization/shopifyType.d.ts +72 -0
  15. package/lib/DigitalCustomization/shopifyType.js +2 -0
  16. package/lib/File/UploadFileType.d.ts +5 -0
  17. package/lib/File/UploadFileType.js +16 -0
  18. package/lib/File/index.d.ts +34 -0
  19. package/lib/File/index.js +131 -0
  20. package/lib/InAppNotification/index.d.ts +23 -0
  21. package/lib/InAppNotification/index.js +89 -0
  22. package/lib/InAppNotification/type.d.ts +1 -0
  23. package/lib/InAppNotification/type.js +2 -0
  24. package/lib/Mfa/index.d.ts +47 -0
  25. package/lib/Mfa/index.js +139 -0
  26. package/lib/Redeem/index.d.ts +23 -0
  27. package/lib/Redeem/index.js +90 -0
  28. package/lib/RegisterDeviceCode/index.d.ts +18 -0
  29. package/lib/RegisterDeviceCode/index.js +88 -0
  30. package/lib/Scan/index.d.ts +39 -0
  31. package/lib/Scan/index.js +121 -0
  32. package/lib/Tags/index.d.ts +75 -0
  33. package/lib/Tags/index.js +264 -0
  34. package/lib/User/index.d.ts +140 -0
  35. package/lib/User/index.js +478 -0
  36. package/lib/config.d.ts +3 -0
  37. package/lib/config.js +8 -0
  38. package/lib/index.d.ts +42 -0
  39. package/lib/index.js +98 -0
  40. package/lib/types.d.ts +587 -0
  41. package/lib/types.js +64 -0
  42. package/package.json +79 -0
@@ -0,0 +1,478 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ /* eslint-disable no-undef */
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var RuleType;
58
+ (function (RuleType) {
59
+ RuleType["scan"] = "scan";
60
+ RuleType["referral"] = "referral";
61
+ RuleType["redeemNFT"] = "redeemNFT";
62
+ RuleType["redeemGoldenTicket"] = "redeemGoldenTicket";
63
+ })(RuleType || (RuleType = {}));
64
+ var IKEAppUserApi = /** @class */ (function (_super) {
65
+ __extends(IKEAppUserApi, _super);
66
+ function IKEAppUserApi(_a) {
67
+ var host = _a.host, secretKey = _a.secretKey, secret = _a.secret, onSuccess = _a.onSuccess, onError = _a.onError;
68
+ return _super.call(this, {
69
+ host: host,
70
+ secretKey: secretKey !== null && secretKey !== void 0 ? secretKey : config_1.localSecretKey,
71
+ secret: secret !== null && secret !== void 0 ? secret : '',
72
+ moduleName: 'user',
73
+ onSuccess: onSuccess,
74
+ onError: onError
75
+ }) || this;
76
+ }
77
+ IKEAppUserApi.prototype.get = function (userId) {
78
+ return __awaiter(this, void 0, void 0, function () {
79
+ var response;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0: return [4 /*yield*/, this.bxbFetch({
83
+ method: 'GET',
84
+ headers: userId ? {
85
+ 'Content-Type': 'application/json',
86
+ 'IKE-App-User-Id': userId
87
+ } : {
88
+ 'Content-Type': 'application/json'
89
+ }
90
+ }, userId)];
91
+ case 1:
92
+ response = _a.sent();
93
+ return [2 /*return*/, response.json()];
94
+ }
95
+ });
96
+ });
97
+ };
98
+ IKEAppUserApi.prototype.update = function (userId, form) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var response;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0: return [4 /*yield*/, this.bxbFetch({
104
+ method: 'PUT',
105
+ headers: userId ? {
106
+ 'Content-Type': 'application/json',
107
+ 'IKE-App-User-Id': userId
108
+ } : {
109
+ 'Content-Type': 'application/json'
110
+ },
111
+ body: JSON.stringify(form)
112
+ }, userId)];
113
+ case 1:
114
+ response = _a.sent();
115
+ return [2 /*return*/, response.json()];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ IKEAppUserApi.prototype.delete = function (userId) {
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var response;
123
+ return __generator(this, function (_a) {
124
+ switch (_a.label) {
125
+ case 0: return [4 /*yield*/, this.bxbFetch({
126
+ method: 'DELETE',
127
+ headers: userId ? {
128
+ 'Content-Type': 'application/json',
129
+ 'IKE-App-User-Id': userId
130
+ } : {
131
+ 'Content-Type': 'application/json'
132
+ }
133
+ }, userId)];
134
+ case 1:
135
+ response = _a.sent();
136
+ return [2 /*return*/, response.json()];
137
+ }
138
+ });
139
+ });
140
+ };
141
+ IKEAppUserApi.prototype.getWallet = function (userId) {
142
+ return __awaiter(this, void 0, void 0, function () {
143
+ var response;
144
+ return __generator(this, function (_a) {
145
+ switch (_a.label) {
146
+ case 0: return [4 /*yield*/, this.bxbFetch({
147
+ method: 'GET',
148
+ headers: userId ? {
149
+ 'Content-Type': 'application/json',
150
+ 'IKE-App-User-Id': userId
151
+ } : {
152
+ 'Content-Type': 'application/json'
153
+ }
154
+ }, "".concat(userId, "/wallet"))];
155
+ case 1:
156
+ response = _a.sent();
157
+ return [2 /*return*/, response.json()];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ IKEAppUserApi.prototype.connectWallet = function (userId, form) {
163
+ return __awaiter(this, void 0, void 0, function () {
164
+ var response;
165
+ return __generator(this, function (_a) {
166
+ switch (_a.label) {
167
+ case 0: return [4 /*yield*/, this.bxbFetch({
168
+ method: 'POST',
169
+ headers: { 'Content-Type': 'application/json' },
170
+ body: JSON.stringify(form),
171
+ }, "".concat(userId, "/wallet"))];
172
+ case 1:
173
+ response = _a.sent();
174
+ return [2 /*return*/, response.json()];
175
+ }
176
+ });
177
+ });
178
+ };
179
+ IKEAppUserApi.prototype.removeScanHistory = function (userId, id) {
180
+ return __awaiter(this, void 0, void 0, function () {
181
+ var response;
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0: return [4 /*yield*/, this.bxbFetch({
185
+ method: 'DELETE',
186
+ headers: userId ? {
187
+ 'Content-Type': 'application/json',
188
+ 'IKE-App-User-Id': userId
189
+ } : {
190
+ 'Content-Type': 'application/json'
191
+ }
192
+ }, "".concat(userId, "/scan-history/").concat(id))];
193
+ case 1:
194
+ response = _a.sent();
195
+ return [2 /*return*/, response.json()];
196
+ }
197
+ });
198
+ });
199
+ };
200
+ IKEAppUserApi.prototype.removeAllScanHistory = function (userId) {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ var response;
203
+ return __generator(this, function (_a) {
204
+ switch (_a.label) {
205
+ case 0: return [4 /*yield*/, this.bxbFetch({
206
+ method: 'DELETE',
207
+ headers: userId ? {
208
+ 'Content-Type': 'application/json',
209
+ 'IKE-App-User-Id': userId
210
+ } : {
211
+ 'Content-Type': 'application/json'
212
+ }
213
+ }, "".concat(userId, "/scan-history"))];
214
+ case 1:
215
+ response = _a.sent();
216
+ return [2 /*return*/, response.json()];
217
+ }
218
+ });
219
+ });
220
+ };
221
+ IKEAppUserApi.prototype.saveProduct = function (userId, batchId) {
222
+ return __awaiter(this, void 0, void 0, function () {
223
+ var response;
224
+ return __generator(this, function (_a) {
225
+ switch (_a.label) {
226
+ case 0: return [4 /*yield*/, this.bxbFetch({
227
+ method: 'POST',
228
+ headers: userId ? {
229
+ 'Content-Type': 'application/json',
230
+ 'IKE-App-User-Id': userId
231
+ } : {
232
+ 'Content-Type': 'application/json'
233
+ }
234
+ }, "".concat(userId, "/save-product/").concat(batchId))];
235
+ case 1:
236
+ response = _a.sent();
237
+ return [2 /*return*/, response.json()];
238
+ }
239
+ });
240
+ });
241
+ };
242
+ IKEAppUserApi.prototype.removeProduct = function (userId, batchId) {
243
+ return __awaiter(this, void 0, void 0, function () {
244
+ var response;
245
+ return __generator(this, function (_a) {
246
+ switch (_a.label) {
247
+ case 0: return [4 /*yield*/, this.bxbFetch({
248
+ method: 'DELETE',
249
+ headers: userId ? {
250
+ 'Content-Type': 'application/json',
251
+ 'IKE-App-User-Id': userId
252
+ } : {
253
+ 'Content-Type': 'application/json'
254
+ }
255
+ }, "".concat(userId, "/save-product/").concat(batchId))];
256
+ case 1:
257
+ response = _a.sent();
258
+ return [2 /*return*/, response.json()];
259
+ }
260
+ });
261
+ });
262
+ };
263
+ IKEAppUserApi.prototype.logout = function (userId, form) {
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var response;
266
+ return __generator(this, function (_a) {
267
+ switch (_a.label) {
268
+ case 0: return [4 /*yield*/, this.bxbFetch({
269
+ method: 'POST',
270
+ headers: { 'Content-Type': 'application/json' },
271
+ body: JSON.stringify(form)
272
+ }, "".concat(userId, "/logout"))];
273
+ case 1:
274
+ response = _a.sent();
275
+ return [2 /*return*/, response.json()];
276
+ }
277
+ });
278
+ });
279
+ };
280
+ IKEAppUserApi.prototype.createNotification = function (userId, digitalCustomizationId) {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ var response;
283
+ return __generator(this, function (_a) {
284
+ switch (_a.label) {
285
+ case 0: return [4 /*yield*/, this.bxbFetch({
286
+ method: 'POST',
287
+ headers: { 'Content-Type': 'application/json' }
288
+ }, "".concat(userId, "/").concat(digitalCustomizationId, "/notifications"))];
289
+ case 1:
290
+ response = _a.sent();
291
+ return [2 /*return*/, response.json()];
292
+ }
293
+ });
294
+ });
295
+ };
296
+ IKEAppUserApi.prototype.removeNotification = function (userId, digitalCustomizationId) {
297
+ return __awaiter(this, void 0, void 0, function () {
298
+ var response;
299
+ return __generator(this, function (_a) {
300
+ switch (_a.label) {
301
+ case 0: return [4 /*yield*/, this.bxbFetch({
302
+ method: 'DELETE',
303
+ headers: { 'Content-Type': 'application/json' }
304
+ }, "".concat(userId, "/").concat(digitalCustomizationId, "/notifications"))];
305
+ case 1:
306
+ response = _a.sent();
307
+ return [2 /*return*/, response.json()];
308
+ }
309
+ });
310
+ });
311
+ };
312
+ IKEAppUserApi.prototype.updateEnableNotification = function (userId, digitalCustomizationId, body) {
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ var response;
315
+ return __generator(this, function (_a) {
316
+ switch (_a.label) {
317
+ case 0: return [4 /*yield*/, this.bxbFetch({
318
+ method: 'PUT',
319
+ headers: { 'Content-Type': 'application/json' },
320
+ body: JSON.stringify(body)
321
+ }, "".concat(userId, "/").concat(digitalCustomizationId, "/notifications"))];
322
+ case 1:
323
+ response = _a.sent();
324
+ return [2 /*return*/, response.json()];
325
+ }
326
+ });
327
+ });
328
+ };
329
+ IKEAppUserApi.prototype.checkBiometricsStatus = function (userId, form) {
330
+ return __awaiter(this, void 0, void 0, function () {
331
+ var response;
332
+ return __generator(this, function (_a) {
333
+ switch (_a.label) {
334
+ case 0: return [4 /*yield*/, this.bxbFetch({
335
+ method: 'POST',
336
+ headers: { 'Content-Type': 'application/json' },
337
+ body: JSON.stringify(form)
338
+ }, "/".concat(userId, "/biometrics/status-check"))];
339
+ case 1:
340
+ response = _a.sent();
341
+ return [2 /*return*/, response.json()];
342
+ }
343
+ });
344
+ });
345
+ };
346
+ IKEAppUserApi.prototype.updateIsIKEToolTutorialReaded = function (userId) {
347
+ return __awaiter(this, void 0, void 0, function () {
348
+ var response;
349
+ return __generator(this, function (_a) {
350
+ switch (_a.label) {
351
+ case 0: return [4 /*yield*/, this.bxbFetch({
352
+ method: 'PUT',
353
+ headers: userId ? {
354
+ 'Content-Type': 'application/json',
355
+ 'IKE-App-User-Id': userId
356
+ } : {
357
+ 'Content-Type': 'application/json'
358
+ }
359
+ }, "".concat(userId, "/isIKEToolTutorialReaded"))];
360
+ case 1:
361
+ response = _a.sent();
362
+ return [2 /*return*/, response.json()];
363
+ }
364
+ });
365
+ });
366
+ };
367
+ IKEAppUserApi.prototype.ikeToolConnect = function (userId, form) {
368
+ return __awaiter(this, void 0, void 0, function () {
369
+ var response;
370
+ return __generator(this, function (_a) {
371
+ switch (_a.label) {
372
+ case 0: return [4 /*yield*/, this.bxbFetch({
373
+ method: 'PUT',
374
+ headers: userId ? {
375
+ 'Content-Type': 'application/json',
376
+ 'IKE-App-User-Id': userId
377
+ } : {
378
+ 'Content-Type': 'application/json'
379
+ },
380
+ body: JSON.stringify(form)
381
+ }, "".concat(userId, "/ikeTool/connect"))];
382
+ case 1:
383
+ response = _a.sent();
384
+ return [2 /*return*/, response.json()];
385
+ }
386
+ });
387
+ });
388
+ };
389
+ IKEAppUserApi.prototype.ikeToolDisConnect = function (userId, form) {
390
+ return __awaiter(this, void 0, void 0, function () {
391
+ var response;
392
+ return __generator(this, function (_a) {
393
+ switch (_a.label) {
394
+ case 0: return [4 /*yield*/, this.bxbFetch({
395
+ method: 'PUT',
396
+ headers: userId ? {
397
+ 'Content-Type': 'application/json',
398
+ 'IKE-App-User-Id': userId
399
+ } : {
400
+ 'Content-Type': 'application/json'
401
+ },
402
+ body: JSON.stringify(form)
403
+ }, "".concat(userId, "/ikeTool/disconnect"))];
404
+ case 1:
405
+ response = _a.sent();
406
+ return [2 /*return*/, response.json()];
407
+ }
408
+ });
409
+ });
410
+ };
411
+ IKEAppUserApi.prototype.createPoints = function (userId, form) {
412
+ return __awaiter(this, void 0, void 0, function () {
413
+ var response;
414
+ return __generator(this, function (_a) {
415
+ switch (_a.label) {
416
+ case 0: return [4 /*yield*/, this.bxbFetch({
417
+ method: 'POST',
418
+ headers: userId ? {
419
+ 'Content-Type': 'application/json',
420
+ 'IKE-App-User-Id': userId
421
+ } : {
422
+ 'Content-Type': 'application/json'
423
+ },
424
+ body: JSON.stringify(form)
425
+ }, "".concat(userId, "/reward/points"))];
426
+ case 1:
427
+ response = _a.sent();
428
+ return [2 /*return*/, response.json()];
429
+ }
430
+ });
431
+ });
432
+ };
433
+ IKEAppUserApi.prototype.redeemDiscount = function (userId, form) {
434
+ return __awaiter(this, void 0, void 0, function () {
435
+ var response;
436
+ return __generator(this, function (_a) {
437
+ switch (_a.label) {
438
+ case 0: return [4 /*yield*/, this.bxbFetch({
439
+ method: 'POST',
440
+ headers: userId ? {
441
+ 'Content-Type': 'application/json',
442
+ 'IKE-App-User-Id': userId
443
+ } : {
444
+ 'Content-Type': 'application/json'
445
+ },
446
+ body: JSON.stringify(form)
447
+ }, "".concat(userId, "/reward/discount"))];
448
+ case 1:
449
+ response = _a.sent();
450
+ return [2 /*return*/, response.json()];
451
+ }
452
+ });
453
+ });
454
+ };
455
+ IKEAppUserApi.prototype.getUserIdByEmail = function (userId, email) {
456
+ return __awaiter(this, void 0, void 0, function () {
457
+ var response;
458
+ return __generator(this, function (_a) {
459
+ switch (_a.label) {
460
+ case 0: return [4 /*yield*/, this.bxbFetch({
461
+ method: 'GET',
462
+ headers: userId ? {
463
+ 'Content-Type': 'application/json',
464
+ 'IKE-App-User-Id': userId
465
+ } : {
466
+ 'Content-Type': 'application/json'
467
+ },
468
+ }, "".concat(userId, "/getUserIdByEmail/").concat(email))];
469
+ case 1:
470
+ response = _a.sent();
471
+ return [2 /*return*/, response.json()];
472
+ }
473
+ });
474
+ });
475
+ };
476
+ return IKEAppUserApi;
477
+ }(bxb_api_1.default));
478
+ exports.default = IKEAppUserApi;
@@ -0,0 +1,3 @@
1
+ import IKEApi from '@bytexbyte/berify-api';
2
+ export declare const localSecretKey = "VCard-IKE-Secret";
3
+ export declare const ikeApi: IKEApi;
package/lib/config.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ikeApi = exports.localSecretKey = void 0;
4
+ var berify_api_1 = require("@bytexbyte/berify-api");
5
+ exports.localSecretKey = 'VCard-IKE-Secret';
6
+ exports.ikeApi = new berify_api_1.default({
7
+ host: '', secret: ''
8
+ });
package/lib/index.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import IKEAppVersionApi from './App';
2
+ import IKEAppAuthApi from './Auth';
3
+ import IKEAppBatchApi from './Batch';
4
+ import IKEAppContractApi from './Contract';
5
+ import IKEAppDigitalCustomizationApi from './DigitalCustomization';
6
+ import IKEAppFileApi from './File';
7
+ import IKEApInAppNotificationApi from './InAppNotification';
8
+ import IKEAppMfaApi from './Mfa';
9
+ import IKEAppRedeemApi from './Redeem';
10
+ import IKEAppRegisterDeviceCodeApi from './RegisterDeviceCode';
11
+ import IKEAppScanApi from './Scan';
12
+ import IKEAppTagsApi from './Tags';
13
+ import IKEAppUserApi from './User';
14
+ declare class IKEAppApi {
15
+ host: string;
16
+ env: string;
17
+ auth: IKEAppAuthApi;
18
+ mfa: IKEAppMfaApi;
19
+ redeem: IKEAppRedeemApi;
20
+ scan: IKEAppScanApi;
21
+ user: IKEAppUserApi;
22
+ app: IKEAppVersionApi;
23
+ registerDeviceCode: IKEAppRegisterDeviceCodeApi;
24
+ file: IKEAppFileApi;
25
+ batch: IKEAppBatchApi;
26
+ tags: IKEAppTagsApi;
27
+ digitalCustomization: IKEAppDigitalCustomizationApi;
28
+ contract: IKEAppContractApi;
29
+ inAppNotification: IKEApInAppNotificationApi;
30
+ constructor({ host, env, secretKey, secret, onSuccess, onError }: {
31
+ host: string;
32
+ env: string;
33
+ secretKey?: string;
34
+ secret?: string;
35
+ onSuccess?: () => void;
36
+ onError?: (error: any) => void;
37
+ });
38
+ getProps: <T>(pathname: string, init?: {
39
+ signal?: AbortSignal;
40
+ }) => Promise<T>;
41
+ }
42
+ export default IKEAppApi;
package/lib/index.js ADDED
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ var App_1 = require("./App");
51
+ var Auth_1 = require("./Auth");
52
+ var Batch_1 = require("./Batch");
53
+ var Contract_1 = require("./Contract");
54
+ var DigitalCustomization_1 = require("./DigitalCustomization");
55
+ var File_1 = require("./File");
56
+ var InAppNotification_1 = require("./InAppNotification");
57
+ var Mfa_1 = require("./Mfa");
58
+ var Redeem_1 = require("./Redeem");
59
+ var RegisterDeviceCode_1 = require("./RegisterDeviceCode");
60
+ var Scan_1 = require("./Scan");
61
+ var Tags_1 = require("./Tags");
62
+ var User_1 = require("./User");
63
+ var IKEAppApi = /** @class */ (function () {
64
+ function IKEAppApi(_a) {
65
+ var host = _a.host, env = _a.env, secretKey = _a.secretKey, secret = _a.secret, onSuccess = _a.onSuccess, onError = _a.onError;
66
+ var _this = this;
67
+ this.getProps = function (pathname, init) { return __awaiter(_this, void 0, void 0, function () {
68
+ var res;
69
+ return __generator(this, function (_a) {
70
+ switch (_a.label) {
71
+ case 0: return [4 /*yield*/, fetch("".concat(this.host, "/_next/data/").concat(this.env, "/app/").concat(pathname, ".json"), __assign({ method: 'GET', credentials: 'include' }, init))];
72
+ case 1:
73
+ res = _a.sent();
74
+ return [4 /*yield*/, res.json()];
75
+ case 2: return [2 /*return*/, (_a.sent()).pageProps];
76
+ }
77
+ });
78
+ }); };
79
+ this.host = host;
80
+ this.env = env;
81
+ this.auth = new Auth_1.default({ host: host, secretKey: secretKey, secret: secret, onSuccess: onSuccess, onError: onError });
82
+ this.mfa = new Mfa_1.default({ host: host, onSuccess: onSuccess, onError: onError });
83
+ this.redeem = new Redeem_1.default({ host: host, onSuccess: onSuccess, onError: onError });
84
+ this.scan = new Scan_1.default({ host: host, onSuccess: onSuccess, onError: onError });
85
+ this.user = new User_1.default({ host: host, secretKey: secretKey, secret: secret, onSuccess: onSuccess, onError: onError });
86
+ this.app = new App_1.default({ host: host, onSuccess: onSuccess, onError: onError });
87
+ this.registerDeviceCode = new RegisterDeviceCode_1.default({ host: host, onSuccess: onSuccess, onError: onError });
88
+ this.file = new File_1.default({ host: host, onSuccess: onSuccess, onError: onError });
89
+ this.batch = new Batch_1.default({ host: host, onSuccess: onSuccess, onError: onError });
90
+ this.tags = new Tags_1.default({ host: host, onSuccess: onSuccess, onError: onError });
91
+ this.digitalCustomization = new DigitalCustomization_1.default({ host: host, onSuccess: onSuccess, onError: onError });
92
+ this.contract = new Contract_1.default({ host: host, onSuccess: onSuccess, onError: onError });
93
+ this.inAppNotification = new InAppNotification_1.default({ host: host, secretKey: secretKey, secret: secret, onSuccess: onSuccess, onError: onError });
94
+ }
95
+ return IKEAppApi;
96
+ }());
97
+ ;
98
+ exports.default = IKEAppApi;