zmp-sdk 2.52.1-beta.1 → 2.52.1-beta.3
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/apis/apis/addVoucher.js +1 -1
- package/apis/common/apis/general/addVoucher.js +1 -1
- package/apis/index.d.ts +75 -58
- package/apis/package.json.js +1 -1
- package/browser.min.js +2 -2
- package/index.d.ts +72 -61
- package/index.es.js +2 -2
- package/index.js +2 -2
- package/index.umd.js +2 -2
- package/package.json +1 -1
package/apis/apis/addVoucher.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import n,{object as e,string as t,number as r}from'./../external/zod/lib/index.mjs.js';import i from"../appEnv/index.js";import a from"../common/notFound.js";import{functionHandler as m}from"../utils/decorator.js";import s from"../common/apis/general/addVoucher.js";import{__generator as c}from'./../external/tslib/tslib.es6.js';var p=e({type:n.enum(["url","phone"]),value:t().min(1),cta:t().min(1)}),u=[e({name:t().min(1).max(200),condition:t().min(1).max(500),conditionDetail:t().min(1).max(2e3).optional(),validAt:r().int().nonnegative().optional(),expiredAt:r().int().positive(),code:t().min(1).max(140).optional(),display:n.enum(["qr_code","bar_code"]).default("qr_code").optional(),interactToken:t().min(1).optional(),ownerName:t().min(1).max(100).optional(),merchantOaId:t().min(1).max(50),merchantName:t().min(1).max(100),merchantLogoUrl:t().url().max(500),actions:n.array(p).max(2).optional()})];function l(o){return d.apply(this,arguments)}function d(){return d=o((function(n){return c(this,(function(e){return[2,m("addVoucher",u,[n],(t=o((function(o,n){var e;return c(this,(function(t){switch(t.label){case 0:return e=n||o,i.isMp?[4,s(e)]:[3,2];case 1:return[2,t.sent()];case 2:return i.isMpWeb?[2,Promise.resolve({oa_message_token:""})]:[2,Promise.reject(a("addVoucher",{}))]}}))})),function(o,n){return t.apply(this,arguments)}))];var t}))})),d.apply(this,arguments)}export{l as addVoucher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import
|
|
1
|
+
import e from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from"../../token.js";import{RESPONSE_CODE as t,MESSAGES as r,QRCARD_APIS as o}from"../../../constants.js";import{AppError as a}from"../../../utils/errorHandler.js";import i from"./openWebview.js";import{__generator as s}from'./../../../external/tslib/tslib.es6.js';var c,d=(c=e((function(e){var c,d,l,m,u,p,E,_,f;return s(this,(function(s){switch(s.label){case 0:return[4,n.jumpAndGetToken()];case 1:if(s.sent(),!(m=null===(c=n.miniProgramConfig)||void 0===c?void 0:c.jwt))throw new a(t.UNAUTHORIZED,r.LOGIN_REQUIRED);return(u=new URLSearchParams).append("data",JSON.stringify(function(e){return{name:e.name,condition:e.condition,conditionDetail:e.conditionDetail,validAt:e.validAt,expiredAt:e.expiredAt,code:e.code,display:e.display||"qr_code",ownerName:e.ownerName,merchantOaId:e.merchantOaId,merchantName:e.merchantName,merchantLogoUrl:e.merchantLogoUrl,actions:e.actions}}(e))),e.interactToken&&u.append("interactToken",e.interactToken),[4,fetch(o.ADD_VOUCHER,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(m)},body:u})];case 2:p=s.sent(),s.label=3;case 3:return s.trys.push([3,5,,6]),[4,p.json()];case 4:return E=s.sent(),[3,6];case 5:throw s.sent(),new a(t.VOUCHER_CREATE_FAILED,r.VOUCHER_CREATE_FAILED);case 6:if(0!==(null==E?void 0:E.err))throw new a("number"==typeof(null==E?void 0:E.err)?E.err:t.VOUCHER_CREATE_FAILED,function(e){var n="string"==typeof(null==e?void 0:e.msg)?e.msg.trim():"";return n||(-1===(null==e?void 0:e.err)?"Unknown exception":r.VOUCHER_CREATE_FAILED)}(E));if(_=null===(d=E.data)||void 0===d?void 0:d.deeplink,f=(null===(l=E.data)||void 0===l?void 0:l.oaMessageToken)||"",!_)throw new a(t.VOUCHER_CREATE_FAILED,r.VOUCHER_CREATE_FAILED);return[4,i(_)];case 7:return s.sent(),[2,{oa_message_token:f}]}}))})),function(e){return c.apply(this,arguments)});export{d as default};
|
package/apis/index.d.ts
CHANGED
|
@@ -1305,74 +1305,66 @@ type VoucherAction = {
|
|
|
1305
1305
|
cta: string;
|
|
1306
1306
|
};
|
|
1307
1307
|
type AddVoucherData = {
|
|
1308
|
-
/**
|
|
1309
|
-
* Tiêu đề hiển thị trên card.
|
|
1310
|
-
*/
|
|
1311
|
-
title: string;
|
|
1312
|
-
/**
|
|
1313
|
-
* Nội dung encode vào QR hoặc barcode.
|
|
1314
|
-
*/
|
|
1315
|
-
code: string;
|
|
1316
|
-
/**
|
|
1317
|
-
* Loại mã hiển thị. Mặc định là `qr_code`.
|
|
1318
|
-
*/
|
|
1319
|
-
display?: VoucherDisplayType;
|
|
1320
1308
|
/**
|
|
1321
1309
|
* Tên voucher / ưu đãi.
|
|
1322
1310
|
*/
|
|
1323
1311
|
name: string;
|
|
1324
1312
|
/**
|
|
1325
|
-
*
|
|
1313
|
+
* Điều kiện áp dụng (chính), hiển thị trên chi tiết vé.
|
|
1326
1314
|
*/
|
|
1327
|
-
|
|
1315
|
+
condition: string;
|
|
1328
1316
|
/**
|
|
1329
|
-
*
|
|
1317
|
+
* Điều kiện áp dụng chi tiết (phụ).
|
|
1330
1318
|
*/
|
|
1331
|
-
|
|
1319
|
+
conditionDetail?: string;
|
|
1332
1320
|
/**
|
|
1333
|
-
*
|
|
1321
|
+
* Thời gian bắt đầu hiệu lực, epoch milliseconds.
|
|
1334
1322
|
*/
|
|
1335
|
-
|
|
1323
|
+
validAt?: number;
|
|
1336
1324
|
/**
|
|
1337
|
-
*
|
|
1325
|
+
* Hạn sử dụng, epoch milliseconds.
|
|
1338
1326
|
*/
|
|
1339
|
-
|
|
1327
|
+
expiredAt: number;
|
|
1340
1328
|
/**
|
|
1341
|
-
* OA
|
|
1329
|
+
* Mã voucher; không truyền thì tự sinh QR OA của merchant.
|
|
1342
1330
|
*/
|
|
1343
|
-
|
|
1331
|
+
code?: string;
|
|
1344
1332
|
/**
|
|
1345
|
-
*
|
|
1333
|
+
* Loại mã hiển thị. Mặc định là `qr_code`.
|
|
1346
1334
|
*/
|
|
1347
|
-
|
|
1335
|
+
display?: VoucherDisplayType;
|
|
1348
1336
|
/**
|
|
1349
|
-
*
|
|
1337
|
+
* Token để merchant gửi tin nhắn không tốn phí. Lấy từ callback
|
|
1338
|
+
* `onDataReceived` của `showFunctionButtonWidget`.
|
|
1350
1339
|
*/
|
|
1351
|
-
|
|
1340
|
+
interactToken?: string;
|
|
1352
1341
|
/**
|
|
1353
|
-
*
|
|
1342
|
+
* Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
|
|
1354
1343
|
*/
|
|
1355
|
-
|
|
1344
|
+
ownerName?: string;
|
|
1356
1345
|
/**
|
|
1357
|
-
*
|
|
1346
|
+
* OA ID của merchant trên Zalo.
|
|
1358
1347
|
*/
|
|
1359
|
-
|
|
1348
|
+
merchantOaId: string;
|
|
1360
1349
|
/**
|
|
1361
|
-
*
|
|
1350
|
+
* Tên OA / thương hiệu phát hành voucher.
|
|
1362
1351
|
*/
|
|
1363
|
-
|
|
1352
|
+
merchantName: string;
|
|
1364
1353
|
/**
|
|
1365
|
-
*
|
|
1354
|
+
* Logo OA, dùng làm logo hiển thị trên voucher.
|
|
1366
1355
|
*/
|
|
1367
|
-
|
|
1356
|
+
merchantLogoUrl: string;
|
|
1368
1357
|
/**
|
|
1369
|
-
*
|
|
1358
|
+
* Danh sách CTA hiển thị trên thẻ (tối đa 2).
|
|
1370
1359
|
*/
|
|
1371
|
-
|
|
1360
|
+
actions?: VoucherAction[];
|
|
1361
|
+
};
|
|
1362
|
+
type AddVoucherReturns = {
|
|
1372
1363
|
/**
|
|
1373
|
-
*
|
|
1364
|
+
* Token để merchant gửi tin nhắn OA cho người dùng; chuỗi rỗng nếu server
|
|
1365
|
+
* không trả về.
|
|
1374
1366
|
*/
|
|
1375
|
-
|
|
1367
|
+
oa_message_token: string;
|
|
1376
1368
|
};
|
|
1377
1369
|
type TempFile = {
|
|
1378
1370
|
/**
|
|
@@ -4955,39 +4947,64 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
|
|
|
4955
4947
|
* API này gửi dữ liệu voucher từ Mini App về server trung gian. Server trung gian
|
|
4956
4948
|
* chịu trách nhiệm đăng nhập Ví QR, mã hoá dữ liệu bằng `secureKey`, sau đó trả về
|
|
4957
4949
|
* deeplink thêm thẻ vào Ví QR. SDK sẽ tự mở deeplink này bằng `openWebview` để đưa
|
|
4958
|
-
* người dùng tới màn hình thêm thẻ; deeplink không được trả về cho bên gọi
|
|
4950
|
+
* người dùng tới màn hình thêm thẻ; deeplink không được trả về cho bên gọi, chỉ
|
|
4951
|
+
* trả về `oa_message_token`.
|
|
4959
4952
|
*
|
|
4960
4953
|
* @zaloOnly Chỉ hoạt động khi chạy bên trong ứng dụng Zalo mobile.
|
|
4961
4954
|
*
|
|
4962
4955
|
* @param {string} name Tên voucher / ưu đãi.
|
|
4963
|
-
* @param {string}
|
|
4964
|
-
* @param {
|
|
4965
|
-
* @param {string} merchantName Tên thương hiệu / cửa hàng phát hành voucher.
|
|
4956
|
+
* @param {string} condition Điều kiện áp dụng (chính), hiển thị trên chi tiết vé.
|
|
4957
|
+
* @param {number} expiredAt Hạn sử dụng, epoch milliseconds.
|
|
4966
4958
|
* @param {string} merchantOaId OA ID của merchant trên Zalo.
|
|
4967
|
-
* @param {string}
|
|
4968
|
-
* @param {string}
|
|
4969
|
-
* @param {
|
|
4970
|
-
* @param {number} [
|
|
4971
|
-
* @param {
|
|
4959
|
+
* @param {string} merchantName Tên OA / thương hiệu phát hành voucher.
|
|
4960
|
+
* @param {string} merchantLogoUrl Logo OA, dùng làm logo hiển thị trên voucher.
|
|
4961
|
+
* @param {string} [conditionDetail] Điều kiện áp dụng chi tiết (phụ).
|
|
4962
|
+
* @param {number} [validAt] Thời gian bắt đầu hiệu lực, epoch milliseconds.
|
|
4963
|
+
* @param {string} [code] Mã voucher; không truyền thì tự sinh QR OA của merchant.
|
|
4964
|
+
* @param {"qr_code" | "bar_code"} [display="qr_code"] Loại mã hiển thị.
|
|
4965
|
+
* @param {string} [ownerName] Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
|
|
4966
|
+
* @param {string} [interactToken] Token để merchant gửi tin nhắn không tốn phí.
|
|
4967
|
+
* Lấy từ callback `onDataReceived` của {@link showFunctionButtonWidget} khi
|
|
4968
|
+
* người dùng nhấn vào Function Button Widget.
|
|
4969
|
+
* @param {VoucherAction[]} [actions] Danh sách CTA hiển thị trên thẻ (tối đa 2).
|
|
4972
4970
|
*
|
|
4973
|
-
* @returns {Promise<
|
|
4974
|
-
* được m
|
|
4971
|
+
* @returns {Promise<AddVoucherReturns>} Promise resolve khi tạo thẻ thành công và
|
|
4972
|
+
* deeplink đã được mở, trả về `oa_message_token` (chuỗi rỗng nếu server không
|
|
4973
|
+
* trả về); reject kèm mã lỗi từ server nếu thất bại.
|
|
4975
4974
|
*
|
|
4976
4975
|
* @example Thêm voucher vào Ví QR:
|
|
4977
4976
|
* ```ts
|
|
4978
4977
|
* await addVoucher({
|
|
4979
|
-
* name: "Giảm
|
|
4980
|
-
*
|
|
4981
|
-
*
|
|
4982
|
-
* merchantOaId: "
|
|
4983
|
-
*
|
|
4984
|
-
*
|
|
4985
|
-
*
|
|
4986
|
-
*
|
|
4978
|
+
* name: "Giảm 50% giá trị đơn hàng",
|
|
4979
|
+
* condition: "Áp dụng cho hóa đơn trên 200.000đ",
|
|
4980
|
+
* expiredAt: 1743440399000,
|
|
4981
|
+
* merchantOaId: "2646373759294038927",
|
|
4982
|
+
* merchantName: "The Face Shop",
|
|
4983
|
+
* merchantLogoUrl: "https://static.example.com/logo.png",
|
|
4984
|
+
* });
|
|
4985
|
+
* ```
|
|
4986
|
+
*
|
|
4987
|
+
* @example Gửi kèm `interactToken` lấy từ Function Button Widget:
|
|
4988
|
+
* ```ts
|
|
4989
|
+
* showFunctionButtonWidget({
|
|
4990
|
+
* id: "orderButton",
|
|
4991
|
+
* type: "ORDER",
|
|
4992
|
+
* text: "Tạo đơn hàng",
|
|
4993
|
+
* onDataReceived: async (interactToken) => {
|
|
4994
|
+
* await addVoucher({
|
|
4995
|
+
* name: "Giảm 50% giá trị đơn hàng",
|
|
4996
|
+
* condition: "Áp dụng cho hóa đơn trên 200.000đ",
|
|
4997
|
+
* expiredAt: 1743440399000,
|
|
4998
|
+
* merchantOaId: "2646373759294038927",
|
|
4999
|
+
* merchantName: "The Face Shop",
|
|
5000
|
+
* merchantLogoUrl: "https://static.example.com/logo.png",
|
|
5001
|
+
* interactToken,
|
|
5002
|
+
* });
|
|
5003
|
+
* },
|
|
4987
5004
|
* });
|
|
4988
5005
|
* ```
|
|
4989
5006
|
*/
|
|
4990
|
-
declare function addVoucher(args: AsyncCallback<
|
|
5007
|
+
declare function addVoucher(args: AsyncCallback<AddVoucherReturns> & AddVoucherData): Promise<AddVoucherReturns>;
|
|
4991
5008
|
|
|
4992
5009
|
declare const interactOAArgs$1: ZodObject<{
|
|
4993
5010
|
oaId: ZodString;
|
package/apis/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="2.52.1-beta.
|
|
1
|
+
var a="2.52.1-beta.3";export{a as version};
|