@nguyennhuy/zalo-api
Version:
Unofficial Zalo API for JavaScript
33 lines (29 loc) • 1.12 kB
JavaScript
;
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
var utils = require('../../utils.cjs');
const getLastMsgFactory = utils.apiFactory()((api, ctx, utils) => {
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/preloadconvers/get-last-msgs`);
/**
* get last message
*
* @param threadIdLocalMsgId object user_id_0:conversation_id
*
* @throws ZaloApiError
*
*/
return async function addGroupDeputy(threadIdLocalMsgId) {
const params = {
threadIdLocalMsgId: JSON.stringify(threadIdLocalMsgId),
imei: ctx.imei,
};
const encryptedParams = utils.encodeAES(JSON.stringify(params));
if (!encryptedParams)
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
const urlWithParams = `${serviceURL}¶ms=${encodeURIComponent(encryptedParams)}`;
const response = await utils.request(urlWithParams, {
method: "GET",
});
return utils.resolve(response);
};
});
exports.getLastMsgFactory = getLastMsgFactory;