51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
require('../models/AutoReply.cjs');
|
|
require('../models/Board.cjs');
|
|
var Enum = require('../models/Enum.cjs');
|
|
require('../models/FriendEvent.cjs');
|
|
require('../models/Group.cjs');
|
|
require('../models/GroupEvent.cjs');
|
|
require('../models/Reaction.cjs');
|
|
require('../models/Reminder.cjs');
|
|
require('../models/ZBusiness.cjs');
|
|
var utils = require('../utils.cjs');
|
|
|
|
const sendBankCardFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/card`);
|
|
/**
|
|
* Send bank card
|
|
*
|
|
* @param payload The payload containing the bank card information
|
|
* @param threadId The ID of the thread to send the bank card to
|
|
* @param type The type of thread to send the bank card to
|
|
*
|
|
* @throws {ZaloApiError}
|
|
*/
|
|
return async function sendBankCard(payload, threadId, type = Enum.ThreadType.User) {
|
|
var _a;
|
|
const params = {
|
|
binBank: payload.binBank,
|
|
numAccBank: payload.numAccBank,
|
|
nameAccBank: ((_a = payload.nameAccBank) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "---",
|
|
cliMsgId: Date.now().toString(),
|
|
tsMsg: Date.now(),
|
|
destUid: threadId,
|
|
destType: type === Enum.ThreadType.Group ? 1 : 0,
|
|
};
|
|
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
if (!encryptedParams)
|
|
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
const response = await utils.request(serviceURL, {
|
|
method: "POST",
|
|
body: new URLSearchParams({
|
|
params: encryptedParams,
|
|
}),
|
|
});
|
|
return utils.resolve(response);
|
|
};
|
|
});
|
|
|
|
exports.sendBankCardFactory = sendBankCardFactory;
|