@bytexbyte/ike-app-api 1.0.37 → 1.0.39
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/lib/Product/index.d.ts +27 -0
- package/lib/Product/index.js +108 -0
- package/lib/Product/type.d.ts +12 -0
- package/lib/Product/type.js +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import BxBApi from '@bytexbyte/bxb-api';
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
3
|
+
import { Product } from './type';
|
|
4
|
+
declare class IKEAppProductApi extends BxBApi {
|
|
5
|
+
constructor({ host, onSuccess, onError }: {
|
|
6
|
+
host: string;
|
|
7
|
+
onSuccess?: () => void;
|
|
8
|
+
onError?: (error: any) => void;
|
|
9
|
+
});
|
|
10
|
+
getProductByMacAddress(form: {
|
|
11
|
+
macAddress: string;
|
|
12
|
+
longitude: number;
|
|
13
|
+
latitude: number;
|
|
14
|
+
}): Promise<Product | {
|
|
15
|
+
error: 'Token is not exist.' | 'Digital customization is not exist.';
|
|
16
|
+
}>;
|
|
17
|
+
getIsSmokeFreeByMacAddress(form: {
|
|
18
|
+
macAddress: string;
|
|
19
|
+
longitude: Decimal | null;
|
|
20
|
+
latitude: Decimal | null;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
isSmokeFree: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
error: 'Token is not exist.' | 'Digital customization is not exist.';
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export default IKEAppProductApi;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 IKEAppProductApi = /** @class */ (function (_super) {
|
|
58
|
+
__extends(IKEAppProductApi, _super);
|
|
59
|
+
function IKEAppProductApi(_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,
|
|
64
|
+
secret: '',
|
|
65
|
+
moduleName: 'product',
|
|
66
|
+
onSuccess: onSuccess,
|
|
67
|
+
onError: onError,
|
|
68
|
+
}) || this;
|
|
69
|
+
}
|
|
70
|
+
IKEAppProductApi.prototype.getProductByMacAddress = function (form) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var response;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, this.bxbFetch({
|
|
76
|
+
method: 'GET',
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
},
|
|
80
|
+
}, "".concat(form.macAddress, "?longitude=").concat(form.longitude, "&latitude=").concat(form.latitude))];
|
|
81
|
+
case 1:
|
|
82
|
+
response = _a.sent();
|
|
83
|
+
return [2 /*return*/, response.json()];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
IKEAppProductApi.prototype.getIsSmokeFreeByMacAddress = function (form) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var response;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0: return [4 /*yield*/, this.bxbFetch({
|
|
94
|
+
method: 'GET',
|
|
95
|
+
headers: {
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
},
|
|
98
|
+
}, "".concat(form.macAddress, "/isSmokeFree?longitude=").concat(form.longitude, "&latitude=").concat(form.latitude))];
|
|
99
|
+
case 1:
|
|
100
|
+
response = _a.sent();
|
|
101
|
+
return [2 /*return*/, response.json()];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return IKEAppProductApi;
|
|
107
|
+
}(bxb_api_1.default));
|
|
108
|
+
exports.default = IKEAppProductApi;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type Product = {
|
|
2
|
+
batchName: string;
|
|
3
|
+
tokenId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
companyName: string;
|
|
7
|
+
image: string;
|
|
8
|
+
minVerifyTimer: number;
|
|
9
|
+
maxVerifyTimer: number;
|
|
10
|
+
isSmokeFree: boolean;
|
|
11
|
+
isScanningAllow: boolean;
|
|
12
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import IKEAppFileApi from './File';
|
|
|
8
8
|
import IKEApInAppNotificationApi from './InAppNotification';
|
|
9
9
|
import IKEAppIncodeApi from './Incode';
|
|
10
10
|
import IKEAppMfaApi from './Mfa';
|
|
11
|
+
import IKEAppProductApi from './Product';
|
|
11
12
|
import IKEAppRedeemApi from './Redeem';
|
|
12
13
|
import IKEAppRegisterDeviceCodeApi from './RegisterDeviceCode';
|
|
13
14
|
import IKEAppRsaApi from './Rsa';
|
|
@@ -33,6 +34,7 @@ declare class IKEAppApi {
|
|
|
33
34
|
incode: IKEAppIncodeApi;
|
|
34
35
|
rsa: IKEAppRsaApi;
|
|
35
36
|
bleConnectionErrorLog: IKEAppBleConnectionErrorLogApi;
|
|
37
|
+
product: IKEAppProductApi;
|
|
36
38
|
constructor({ host, env, secretKey, secret, onSuccess, onError, }: {
|
|
37
39
|
host: string;
|
|
38
40
|
env: string;
|
package/lib/index.js
CHANGED
|
@@ -57,6 +57,7 @@ var File_1 = require("./File");
|
|
|
57
57
|
var InAppNotification_1 = require("./InAppNotification");
|
|
58
58
|
var Incode_1 = require("./Incode");
|
|
59
59
|
var Mfa_1 = require("./Mfa");
|
|
60
|
+
var Product_1 = require("./Product");
|
|
60
61
|
var Redeem_1 = require("./Redeem");
|
|
61
62
|
var RegisterDeviceCode_1 = require("./RegisterDeviceCode");
|
|
62
63
|
var Rsa_1 = require("./Rsa");
|
|
@@ -94,6 +95,7 @@ var IKEAppApi = /** @class */ (function () {
|
|
|
94
95
|
this.digitalCustomization = new DigitalCustomization_1.default({ host: host, onSuccess: onSuccess, onError: onError });
|
|
95
96
|
this.contract = new Contract_1.default({ host: host, onSuccess: onSuccess, onError: onError });
|
|
96
97
|
this.rsa = new Rsa_1.default({ host: host, onSuccess: onSuccess, onError: onError });
|
|
98
|
+
this.product = new Product_1.default({ host: host, onSuccess: onSuccess, onError: onError });
|
|
97
99
|
this.inAppNotification = new InAppNotification_1.default({ host: host, secretKey: secretKey, secret: secret, onSuccess: onSuccess, onError: onError });
|
|
98
100
|
this.incode = new Incode_1.default({ host: host, secretKey: secretKey, secret: secret, onSuccess: onSuccess, onError: onError });
|
|
99
101
|
this.bleConnectionErrorLog = new BleConnectionErrorLog_1.default({ host: host, onSuccess: onSuccess, onError: onError });
|
package/package.json
CHANGED