@nguyennhuy/zalo-api
Version:
Unofficial Zalo API for JavaScript
28 lines (27 loc) • 1.05 kB
JavaScript
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
import { apiFactory } from "../../utils.js";
export const getLastMsgFactory = 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("Failed to encrypt params");
const urlWithParams = `${serviceURL}¶ms=${encodeURIComponent(encryptedParams)}`;
const response = await utils.request(urlWithParams, {
method: "GET",
});
return utils.resolve(response);
};
});