UNPKG

@nguyennhuy/zalo-api

Version:

Unofficial Zalo API for JavaScript

31 lines (30 loc) 1.08 kB
import { ZaloApiError } from "../../Errors/ZaloApiError.js"; import { apiFactory } from "../../utils.js"; export const getGroupBoardListFactory = apiFactory()((api, ctx, utils) => { const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/list`); /** * get group board list * * @throws ZaloApiError * */ return async function getGroupBoardList(groupId) { const params = { group_id: groupId, board_type: 0, // 0: all, 2: tin gim, 3: bình chọn page: 1, count: 20, last_id: 0, last_type: 0, imei: ctx.imei, }; const encryptedParams = utils.encodeAES(JSON.stringify(params)); if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); const urlWithParams = `${serviceURL}&params=${encodeURIComponent(encryptedParams)}`; const response = await utils.request(urlWithParams, { method: "GET", }); return utils.resolve(response); }; });