zmp-sdk 2.52.1-beta.2 → 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 +39 -8
- package/apis/package.json.js +1 -1
- package/browser.min.js +2 -2
- package/index.d.ts +35 -10
- 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 o from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import n,{object as e,string as
|
|
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
|
@@ -1334,9 +1334,10 @@ type AddVoucherData = {
|
|
|
1334
1334
|
*/
|
|
1335
1335
|
display?: VoucherDisplayType;
|
|
1336
1336
|
/**
|
|
1337
|
-
*
|
|
1337
|
+
* Token để merchant gửi tin nhắn không tốn phí. Lấy từ callback
|
|
1338
|
+
* `onDataReceived` của `showFunctionButtonWidget`.
|
|
1338
1339
|
*/
|
|
1339
|
-
|
|
1340
|
+
interactToken?: string;
|
|
1340
1341
|
/**
|
|
1341
1342
|
* Tên khách hàng sở hữu; không truyền thì không hiển thị trên vé.
|
|
1342
1343
|
*/
|
|
@@ -1358,6 +1359,13 @@ type AddVoucherData = {
|
|
|
1358
1359
|
*/
|
|
1359
1360
|
actions?: VoucherAction[];
|
|
1360
1361
|
};
|
|
1362
|
+
type AddVoucherReturns = {
|
|
1363
|
+
/**
|
|
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ề.
|
|
1366
|
+
*/
|
|
1367
|
+
oa_message_token: string;
|
|
1368
|
+
};
|
|
1361
1369
|
type TempFile = {
|
|
1362
1370
|
/**
|
|
1363
1371
|
* Đường dẫn các temp file đã chọn.
|
|
@@ -4939,14 +4947,14 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
|
|
|
4939
4947
|
* API này gửi dữ liệu voucher từ Mini App về server trung gian. Server trung gian
|
|
4940
4948
|
* chịu trách nhiệm đăng nhập Ví QR, mã hoá dữ liệu bằng `secureKey`, sau đó trả về
|
|
4941
4949
|
* deeplink thêm thẻ vào Ví QR. SDK sẽ tự mở deeplink này bằng `openWebview` để đưa
|
|
4942
|
-
* 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`.
|
|
4943
4952
|
*
|
|
4944
4953
|
* @zaloOnly Chỉ hoạt động khi chạy bên trong ứng dụng Zalo mobile.
|
|
4945
4954
|
*
|
|
4946
4955
|
* @param {string} name Tên voucher / ưu đãi.
|
|
4947
4956
|
* @param {string} condition Điều kiện áp dụng (chính), hiển thị trên chi tiết vé.
|
|
4948
4957
|
* @param {number} expiredAt Hạn sử dụng, epoch milliseconds.
|
|
4949
|
-
* @param {number} remindBefore Khoảng thời gian trước hạn để gửi nhắc, tính bằng milliseconds.
|
|
4950
4958
|
* @param {string} merchantOaId OA ID của merchant trên Zalo.
|
|
4951
4959
|
* @param {string} merchantName Tên OA / thương hiệu phát hành voucher.
|
|
4952
4960
|
* @param {string} merchantLogoUrl Logo OA, dùng làm logo hiển thị trên voucher.
|
|
@@ -4955,10 +4963,14 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
|
|
|
4955
4963
|
* @param {string} [code] Mã voucher; không truyền thì tự sinh QR OA của merchant.
|
|
4956
4964
|
* @param {"qr_code" | "bar_code"} [display="qr_code"] Loại mã hiển thị.
|
|
4957
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.
|
|
4958
4969
|
* @param {VoucherAction[]} [actions] Danh sách CTA hiển thị trên thẻ (tối đa 2).
|
|
4959
4970
|
*
|
|
4960
|
-
* @returns {Promise<
|
|
4961
|
-
* đượ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.
|
|
4962
4974
|
*
|
|
4963
4975
|
* @example Thêm voucher vào Ví QR:
|
|
4964
4976
|
* ```ts
|
|
@@ -4966,14 +4978,33 @@ declare function addRating(args?: AsyncVoidCallback): Promise<void>;
|
|
|
4966
4978
|
* name: "Giảm 50% giá trị đơn hàng",
|
|
4967
4979
|
* condition: "Áp dụng cho hóa đơn trên 200.000đ",
|
|
4968
4980
|
* expiredAt: 1743440399000,
|
|
4969
|
-
* remindBefore: 3600000,
|
|
4970
4981
|
* merchantOaId: "2646373759294038927",
|
|
4971
4982
|
* merchantName: "The Face Shop",
|
|
4972
4983
|
* merchantLogoUrl: "https://static.example.com/logo.png",
|
|
4973
4984
|
* });
|
|
4974
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
|
+
* },
|
|
5004
|
+
* });
|
|
5005
|
+
* ```
|
|
4975
5006
|
*/
|
|
4976
|
-
declare function addVoucher(args: AsyncCallback<
|
|
5007
|
+
declare function addVoucher(args: AsyncCallback<AddVoucherReturns> & AddVoucherData): Promise<AddVoucherReturns>;
|
|
4977
5008
|
|
|
4978
5009
|
declare const interactOAArgs$1: ZodObject<{
|
|
4979
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};
|