UNPKG

@nguyennhuy/zalo-api

Version:

Unofficial Zalo API for JavaScript

33 lines (29 loc) 1.01 kB
'use strict'; var ZaloApiError = require('../../Errors/ZaloApiError.cjs'); var utils = require('../../utils.cjs'); const getPhoneBookFactory = utils.apiFactory()((api, ctx, utils) => { const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/phonebook/v2`); /** * Get all friends * * @param count Page size (default: 20000) * @param page Page number (default: 1) * * @throws ZaloApiError */ return async function () { const params = { phonebook_version: 0, }; const encryptedParams = utils.encodeAES(JSON.stringify(params)); if (!encryptedParams) throw new ZaloApiError.ZaloApiError("Failed to encrypt message"); const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams, }), { method: "GET", }); return utils.resolve(response); }; }); exports.getPhoneBookFactory = getPhoneBookFactory;