@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,264 @@
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 IKEAppTagsApi = /** @class */ (function (_super) {
58
+ __extends(IKEAppTagsApi, _super);
59
+ function IKEAppTagsApi(_a) {
60
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ return _super.call(this, {
62
+ host: host,
63
+ secretKey: config_1.localSecretKey, secret: '',
64
+ moduleName: 'tags',
65
+ onSuccess: onSuccess,
66
+ onError: onError
67
+ }) || this;
68
+ }
69
+ IKEAppTagsApi.prototype.get = function (tokenId) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var response;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.bxbFetch({
75
+ method: 'GET',
76
+ headers: {
77
+ 'Content-Type': 'application/json'
78
+ }
79
+ }, tokenId)];
80
+ case 1:
81
+ response = _a.sent();
82
+ return [2 /*return*/, response.json()];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ IKEAppTagsApi.prototype.getMany = function (query, userId) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var searchParams, response;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ searchParams = new URLSearchParams();
94
+ searchParams.append('batchId', query.batchId);
95
+ if (query.batchSerialNumberGte)
96
+ searchParams.append('batchSerialNumberGte', query.batchSerialNumberGte);
97
+ if (query.batchSerialNumberLte)
98
+ searchParams.append('batchSerialNumberLte', query.batchSerialNumberLte);
99
+ return [4 /*yield*/, this.bxbFetch({
100
+ method: 'GET',
101
+ headers: userId ? {
102
+ 'Content-Type': 'application/json',
103
+ 'IKE-App-User-Id': userId
104
+ } : {
105
+ 'Content-Type': 'application/json'
106
+ }
107
+ }, "?".concat(searchParams.toString()))];
108
+ case 1:
109
+ response = _a.sent();
110
+ return [2 /*return*/, response.json()];
111
+ }
112
+ });
113
+ });
114
+ };
115
+ IKEAppTagsApi.prototype.getBlockchainStatus = function (tokenId) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var response;
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0: return [4 /*yield*/, this.bxbFetch({
121
+ method: 'GET',
122
+ headers: {
123
+ 'Content-Type': 'application/json'
124
+ }
125
+ }, "".concat(tokenId, "/blockchainStatus"))];
126
+ case 1:
127
+ response = _a.sent();
128
+ return [2 /*return*/, response.json()];
129
+ }
130
+ });
131
+ });
132
+ };
133
+ IKEAppTagsApi.prototype.update = function (tokenId, form) {
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ var response;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0: return [4 /*yield*/, this.bxbFetch({
139
+ method: 'POST',
140
+ headers: form.ownerId ? {
141
+ 'Content-Type': 'application/json',
142
+ 'IKE-App-User-Id': form.ownerId
143
+ } : {
144
+ 'Content-Type': 'application/json'
145
+ },
146
+ body: JSON.stringify(form)
147
+ }, tokenId)];
148
+ case 1:
149
+ response = _a.sent();
150
+ return [2 /*return*/, response.json()];
151
+ }
152
+ });
153
+ });
154
+ };
155
+ IKEAppTagsApi.prototype.updateMany = function (form, userId) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var response;
158
+ return __generator(this, function (_a) {
159
+ switch (_a.label) {
160
+ case 0: return [4 /*yield*/, this.bxbFetch({
161
+ method: 'PUT',
162
+ headers: userId ? {
163
+ 'Content-Type': 'application/json',
164
+ 'IKE-App-User-Id': userId
165
+ } : {
166
+ 'Content-Type': 'application/json'
167
+ },
168
+ body: JSON.stringify(form)
169
+ })];
170
+ case 1:
171
+ response = _a.sent();
172
+ return [2 /*return*/, response.json()];
173
+ }
174
+ });
175
+ });
176
+ };
177
+ IKEAppTagsApi.prototype.transferOwner = function (tokenId, form) {
178
+ return __awaiter(this, void 0, void 0, function () {
179
+ var response;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0: return [4 /*yield*/, this.bxbFetch({
183
+ method: 'POST',
184
+ headers: form.ownerId ? {
185
+ 'Content-Type': 'application/json',
186
+ 'IKE-App-User-Id': form.ownerId
187
+ } : {
188
+ 'Content-Type': 'application/json'
189
+ },
190
+ body: JSON.stringify(form)
191
+ }, "".concat(tokenId, "/transfer"))];
192
+ case 1:
193
+ response = _a.sent();
194
+ return [2 /*return*/, response.json()];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ IKEAppTagsApi.prototype.undoTransferOwner = function (tokenId, form) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var response;
202
+ return __generator(this, function (_a) {
203
+ switch (_a.label) {
204
+ case 0: return [4 /*yield*/, this.bxbFetch({
205
+ method: 'DELETE',
206
+ headers: form.ownerId ? {
207
+ 'Content-Type': 'application/json',
208
+ 'IKE-App-User-Id': form.ownerId
209
+ } : {
210
+ 'Content-Type': 'application/json'
211
+ },
212
+ body: JSON.stringify(form)
213
+ }, "".concat(tokenId, "/transfer"))];
214
+ case 1:
215
+ response = _a.sent();
216
+ return [2 /*return*/, response.json()];
217
+ }
218
+ });
219
+ });
220
+ };
221
+ IKEAppTagsApi.prototype.updateInfoVisible = function (tokenId, form) {
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: 'PUT',
228
+ headers: form.ownerId ? {
229
+ 'Content-Type': 'application/json',
230
+ 'IKE-App-User-Id': form.ownerId
231
+ } : {
232
+ 'Content-Type': 'application/json'
233
+ },
234
+ body: JSON.stringify(form)
235
+ }, "".concat(tokenId, "/infoVisible"))];
236
+ case 1:
237
+ response = _a.sent();
238
+ return [2 /*return*/, response.json()];
239
+ }
240
+ });
241
+ });
242
+ };
243
+ IKEAppTagsApi.prototype.updateDisplayName = function (tokenId, displayName) {
244
+ return __awaiter(this, void 0, void 0, function () {
245
+ var response;
246
+ return __generator(this, function (_a) {
247
+ switch (_a.label) {
248
+ case 0: return [4 /*yield*/, this.bxbFetch({
249
+ method: 'PUT',
250
+ headers: {
251
+ 'Content-Type': 'application/json'
252
+ },
253
+ body: JSON.stringify({ displayName: displayName })
254
+ }, "".concat(tokenId, "/updateDisplayName"))];
255
+ case 1:
256
+ response = _a.sent();
257
+ return [2 /*return*/, response.json()];
258
+ }
259
+ });
260
+ });
261
+ };
262
+ return IKEAppTagsApi;
263
+ }(bxb_api_1.default));
264
+ exports.default = IKEAppTagsApi;
@@ -0,0 +1,140 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ import { User, Wallet } from '../types';
3
+ declare type GetResult = {
4
+ user: {
5
+ email: string | null;
6
+ phone: string | null;
7
+ firstName: string | null;
8
+ lastName: string | null;
9
+ };
10
+ error?: undefined;
11
+ } | {
12
+ user?: undefined;
13
+ error: 'Authentication type error.' | 'Incorrect userID.' | 'User not found.' | 'You are not authorized to call this API.';
14
+ };
15
+ declare type UpdateBody = Pick<User, 'image' | 'firstName' | 'lastName'>;
16
+ declare type UpdateResult = Pick<User, 'id' | 'email' | 'phone' | 'image' | 'firstName' | 'lastName'> | {
17
+ error?: 'Authentication type error.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'You are not authorized to call this API.';
18
+ };
19
+ declare type DeleteResult = User | {
20
+ error?: 'Authentication type error.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'User not found.' | 'You are not authorized to call this API.';
21
+ };
22
+ declare type GetWalletResult = {
23
+ address: Pick<Wallet, 'address'>['address'];
24
+ error?: undefined;
25
+ } | {
26
+ address?: undefined;
27
+ error: 'Incorrect userID.' | 'You are not logged in.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Invalid id.';
28
+ };
29
+ declare type GetUserIdByEmailResult = {
30
+ user: {
31
+ id: string;
32
+ };
33
+ error?: undefined;
34
+ } | {
35
+ user?: undefined;
36
+ error: 'Invalid email.' | 'You are not logged in.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'Missing userId.';
37
+ };
38
+ declare type PostWalletBody = {
39
+ address: string;
40
+ };
41
+ declare type PostWalletResult = {
42
+ userId: string;
43
+ address: string;
44
+ };
45
+ declare type LogoutResult = {
46
+ success?: boolean;
47
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'Missing userId.';
48
+ };
49
+ declare type RemoveScanHistoryResult = {
50
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing scanHistoryId.';
51
+ };
52
+ declare type RemoveAllScanHistoryResult = {
53
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'You cannot make changes to this user.' | 'Missing userId.';
54
+ };
55
+ declare type SaveProductResult = {
56
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'Incorrect batchId.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing batchId.';
57
+ };
58
+ declare type RemoveProductResult = {
59
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'Incorrect digitalCustomizationId.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing digitalCustomizationId.';
60
+ };
61
+ declare type CreateNotificationResult = {
62
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'Incorrect digitalCustomizationId.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing digitalCustomizationId.' | 'Missing digitalCustomization.';
63
+ };
64
+ declare type RemoveNotificationResult = {
65
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'Incorrect digitalCustomizationId.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing digitalCustomizationId.';
66
+ };
67
+ declare type UpdateNotificationResult = {
68
+ error?: 'You are not logged in.' | 'Incorrect userID.' | 'Incorrect digitalCustomizationId.' | 'You cannot make changes to this user.' | 'Missing userId.' | 'Missing digitalCustomizationId.';
69
+ };
70
+ declare enum RuleType {
71
+ scan = "scan",
72
+ referral = "referral",
73
+ redeemNFT = "redeemNFT",
74
+ redeemGoldenTicket = "redeemGoldenTicket"
75
+ }
76
+ declare class IKEAppUserApi extends BxBApi {
77
+ constructor({ host, secretKey, secret, onSuccess, onError }: {
78
+ host: string;
79
+ secretKey?: string;
80
+ secret?: string;
81
+ onSuccess?: () => void;
82
+ onError?: (error: any) => void;
83
+ });
84
+ get(userId: string): Promise<GetResult>;
85
+ update(userId: string, form: UpdateBody): Promise<UpdateResult>;
86
+ delete(userId: string): Promise<DeleteResult>;
87
+ getWallet(userId: string): Promise<GetWalletResult>;
88
+ connectWallet(userId: string, form: PostWalletBody): Promise<PostWalletResult>;
89
+ removeScanHistory(userId: string, id: number): Promise<RemoveScanHistoryResult>;
90
+ removeAllScanHistory(userId: string): Promise<RemoveAllScanHistoryResult>;
91
+ saveProduct(userId: string, batchId: string): Promise<SaveProductResult>;
92
+ removeProduct(userId: string, batchId: string): Promise<RemoveProductResult>;
93
+ logout(userId: string, form: {
94
+ deviceToken: string;
95
+ }): Promise<LogoutResult>;
96
+ createNotification(userId: string, digitalCustomizationId: number): Promise<CreateNotificationResult>;
97
+ removeNotification(userId: string, digitalCustomizationId: number): Promise<RemoveNotificationResult>;
98
+ updateEnableNotification(userId: string, digitalCustomizationId: number, body: {
99
+ enabled: boolean;
100
+ }): Promise<UpdateNotificationResult>;
101
+ checkBiometricsStatus(userId: string, form: {
102
+ publicKey: string | null;
103
+ }): Promise<{
104
+ status: 'NotSet' | 'Match' | 'NotMatch';
105
+ error?: undefined;
106
+ } | {
107
+ status?: undefined;
108
+ error: 'Incorrect userID.' | 'id not found.' | 'Field(s) cannot be empty.';
109
+ }>;
110
+ updateIsIKEToolTutorialReaded(userId: string): Promise<any>;
111
+ ikeToolConnect(userId: string, form: {
112
+ webUserId: string;
113
+ }): Promise<{
114
+ error?: 'Incorrect userID.' | 'You are not authorized to call this API.' | 'Authentication type error.' | 'User not found.' | 'Connection failed.' | 'webUserId is already in use.' | undefined;
115
+ }>;
116
+ ikeToolDisConnect(userId: string, form: {
117
+ webUserId: string;
118
+ }): Promise<{
119
+ error?: 'Incorrect userID.' | 'You are not authorized to call this API.' | 'Authentication type error.' | 'User not found.' | 'Disconnection error.' | 'Disconnection failed.' | undefined;
120
+ }>;
121
+ createPoints(userId: string, form: {
122
+ digitalCustomizationId: number;
123
+ type: RuleType;
124
+ tagTokenId: string;
125
+ }): Promise<{
126
+ error?: 'You are not authorized to call this API.' | 'Incorrect userID.' | 'Authentication type error.' | 'You cannot make changes to this user.' | 'This is not your tag.' | undefined;
127
+ }>;
128
+ redeemDiscount(userId: string, form: {
129
+ rewardRuleId: string;
130
+ companyId: number;
131
+ }): Promise<{
132
+ code: string;
133
+ error?: undefined;
134
+ } | {
135
+ code?: undefined;
136
+ error: 'Incorrect userID.' | 'Authentication type error.' | 'You cannot make changes to this user.' | 'You are not logged in.' | 'Missing userId.' | 'Missing companyId.' | 'Missing rewardRuleId.' | 'No available discount codes found.' | undefined;
137
+ }>;
138
+ getUserIdByEmail(userId: string, email: string): Promise<GetUserIdByEmailResult>;
139
+ }
140
+ export default IKEAppUserApi;