zalo-toolkit 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/apis/sendMessage.d.ts +5 -0
  2. package/dist/apis/sendMessage.js +31 -11
  3. package/dist/cjs/apis/acceptFriendRequest.cjs +33 -0
  4. package/dist/cjs/apis/addGroupBlockedMember.cjs +33 -0
  5. package/dist/cjs/apis/addGroupDeputy.cjs +36 -0
  6. package/dist/cjs/apis/addPollOptions.cjs +31 -0
  7. package/dist/cjs/apis/addQuickMessage.cjs +65 -0
  8. package/dist/cjs/apis/addReaction.cjs +297 -0
  9. package/dist/cjs/apis/addUnreadMark.cjs +65 -0
  10. package/dist/cjs/apis/addUserToGroup.cjs +39 -0
  11. package/dist/cjs/apis/blockUser.cjs +33 -0
  12. package/dist/cjs/apis/blockViewFeed.cjs +35 -0
  13. package/dist/cjs/apis/changeAccountAvatar.cjs +56 -0
  14. package/dist/cjs/apis/changeFriendAlias.cjs +32 -0
  15. package/dist/cjs/apis/changeGroupAvatar.cjs +47 -0
  16. package/dist/cjs/apis/changeGroupName.cjs +37 -0
  17. package/dist/cjs/apis/changeGroupOwner.cjs +36 -0
  18. package/dist/cjs/apis/createAutoReply.cjs +42 -0
  19. package/dist/cjs/apis/createCatalog.cjs +34 -0
  20. package/dist/cjs/apis/createGroup.cjs +48 -0
  21. package/dist/cjs/apis/createNote.cjs +52 -0
  22. package/dist/cjs/apis/createPoll.cjs +45 -0
  23. package/dist/cjs/apis/createProductCatalog.cjs +55 -0
  24. package/dist/cjs/apis/createReminder.cjs +76 -0
  25. package/dist/cjs/apis/custom.cjs +19 -0
  26. package/dist/cjs/apis/deleteAutoReply.cjs +34 -0
  27. package/dist/cjs/apis/deleteAvatar.cjs +32 -0
  28. package/dist/cjs/apis/deleteCatalog.cjs +33 -0
  29. package/dist/cjs/apis/deleteChat.cjs +63 -0
  30. package/dist/cjs/apis/deleteGroupInviteBox.cjs +32 -0
  31. package/dist/cjs/apis/deleteMessage.cjs +65 -0
  32. package/dist/cjs/apis/deleteProductCatalog.cjs +36 -0
  33. package/dist/cjs/apis/disableGroupLink.cjs +29 -0
  34. package/dist/cjs/apis/disperseGroup.cjs +33 -0
  35. package/dist/cjs/apis/editNote.cjs +51 -0
  36. package/dist/cjs/apis/editReminder.cjs +74 -0
  37. package/dist/cjs/apis/enableGroupLink.cjs +30 -0
  38. package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
  39. package/dist/cjs/apis/findUser.cjs +45 -0
  40. package/dist/cjs/apis/forwardAttachment.cjs +85 -0
  41. package/dist/cjs/apis/forwardMessage.cjs +122 -0
  42. package/dist/cjs/apis/getAliasList.cjs +33 -0
  43. package/dist/cjs/apis/getAllFriends.cjs +37 -0
  44. package/dist/cjs/apis/getAllGroups.cjs +15 -0
  45. package/dist/cjs/apis/getArchivedChatList.cjs +28 -0
  46. package/dist/cjs/apis/getAutoDeleteChat.cjs +26 -0
  47. package/dist/cjs/apis/getAutoReplyList.cjs +29 -0
  48. package/dist/cjs/apis/getAvatarList.cjs +33 -0
  49. package/dist/cjs/apis/getBizAccount.cjs +32 -0
  50. package/dist/cjs/apis/getCatalogList.cjs +37 -0
  51. package/dist/cjs/apis/getContext.cjs +9 -0
  52. package/dist/cjs/apis/getCookie.cjs +14 -0
  53. package/dist/cjs/apis/getFriendBoardList.cjs +31 -0
  54. package/dist/cjs/apis/getFriendOnlines.cjs +40 -0
  55. package/dist/cjs/apis/getFriendRecommendations.cjs +32 -0
  56. package/dist/cjs/apis/getFriendRequestStatus.cjs +30 -0
  57. package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
  58. package/dist/cjs/apis/getGroupInfo.cjs +37 -0
  59. package/dist/cjs/apis/getGroupInviteBoxInfo.cjs +43 -0
  60. package/dist/cjs/apis/getGroupInviteBoxList.cjs +36 -0
  61. package/dist/cjs/apis/getGroupLinkDetail.cjs +30 -0
  62. package/dist/cjs/apis/getGroupLinkInfo.cjs +33 -0
  63. package/dist/cjs/apis/getGroupMembersInfo.cjs +29 -0
  64. package/dist/cjs/apis/getHiddenConversations.cjs +28 -0
  65. package/dist/cjs/apis/getLabels.cjs +33 -0
  66. package/dist/cjs/apis/getLastMessage.cjs +25 -0
  67. package/dist/cjs/apis/getListBoard.cjs +58 -0
  68. package/dist/cjs/apis/getListReminder.cjs +60 -0
  69. package/dist/cjs/apis/getMute.cjs +27 -0
  70. package/dist/cjs/apis/getOwnId.cjs +9 -0
  71. package/dist/cjs/apis/getPendingGroupMembers.cjs +32 -0
  72. package/dist/cjs/apis/getPinConversations.cjs +27 -0
  73. package/dist/cjs/apis/getPollDetail.cjs +35 -0
  74. package/dist/cjs/apis/getProductCatalogList.cjs +38 -0
  75. package/dist/cjs/apis/getQR.cjs +34 -0
  76. package/dist/cjs/apis/getQuickMessageList.cjs +29 -0
  77. package/dist/cjs/apis/getRecommendFriends.cjs +25 -0
  78. package/dist/cjs/apis/getRelatedFriendGroup.cjs +35 -0
  79. package/dist/cjs/apis/getReminder.cjs +30 -0
  80. package/dist/cjs/apis/getReminderResponses.cjs +29 -0
  81. package/dist/cjs/apis/getSentFriendRequest.cjs +29 -0
  82. package/dist/cjs/apis/getSettings.cjs +25 -0
  83. package/dist/cjs/apis/getStickers.cjs +45 -0
  84. package/dist/cjs/apis/getStickersDetail.cjs +45 -0
  85. package/dist/cjs/apis/getUnreadMark.cjs +35 -0
  86. package/dist/cjs/apis/getUserInfo.cjs +47 -0
  87. package/dist/cjs/apis/inviteUserToGroups.cjs +35 -0
  88. package/dist/cjs/apis/joinGroupInviteBox.cjs +30 -0
  89. package/dist/cjs/apis/joinGroupLink.cjs +32 -0
  90. package/dist/cjs/apis/keepAlive.cjs +27 -0
  91. package/dist/cjs/apis/lastOnline.cjs +31 -0
  92. package/dist/cjs/apis/leaveGroup.cjs +38 -0
  93. package/dist/cjs/apis/lockPoll.cjs +33 -0
  94. package/dist/cjs/apis/parseLink.cjs +32 -0
  95. package/dist/cjs/apis/rejectFriendRequest.cjs +32 -0
  96. package/dist/cjs/apis/removeFriend.cjs +33 -0
  97. package/dist/cjs/apis/removeFriendAlias.cjs +29 -0
  98. package/dist/cjs/apis/removeGroupBlockedMember.cjs +33 -0
  99. package/dist/cjs/apis/removeGroupDeputy.cjs +35 -0
  100. package/dist/cjs/apis/removeQuickMessage.cjs +32 -0
  101. package/dist/cjs/apis/removeReminder.cjs +53 -0
  102. package/dist/cjs/apis/removeUnreadMark.cjs +63 -0
  103. package/dist/cjs/apis/removeUserFromGroup.cjs +39 -0
  104. package/dist/cjs/apis/resetHiddenConversPin.cjs +25 -0
  105. package/dist/cjs/apis/reuseAvatar.cjs +31 -0
  106. package/dist/cjs/apis/reviewPendingMemberRequest.cjs +33 -11
  107. package/dist/cjs/apis/sendBankCard.cjs +50 -0
  108. package/dist/cjs/apis/sendCard.cjs +72 -0
  109. package/dist/cjs/apis/sendDeliveredEvent.cjs +68 -0
  110. package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
  111. package/dist/cjs/apis/sendLink.cjs +70 -0
  112. package/dist/cjs/apis/sendMessage.cjs +437 -11
  113. package/dist/cjs/apis/sendReport.cjs +48 -10
  114. package/dist/cjs/apis/sendSeenEvent.cjs +76 -0
  115. package/dist/cjs/apis/sendSticker.cjs +69 -0
  116. package/dist/cjs/apis/sendTypingEvent.cjs +46 -0
  117. package/dist/cjs/apis/sendVideo.cjs +131 -0
  118. package/dist/cjs/apis/sendVoice.cjs +86 -0
  119. package/dist/cjs/apis/setArchivedConversations.cjs +39 -0
  120. package/dist/cjs/apis/setHiddenConversations.cjs +52 -0
  121. package/dist/cjs/apis/setMute.cjs +57 -10
  122. package/dist/cjs/apis/setPinnedConversations.cjs +47 -0
  123. package/dist/cjs/apis/sharePoll.cjs +33 -0
  124. package/dist/cjs/apis/unblockUser.cjs +33 -0
  125. package/dist/cjs/apis/undo.cjs +55 -0
  126. package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
  127. package/dist/cjs/apis/updateActiveStatus.cjs +32 -0
  128. package/dist/cjs/apis/updateAutoDeleteChat.cjs +35 -10
  129. package/dist/cjs/apis/updateAutoReply.cjs +43 -0
  130. package/dist/cjs/apis/updateCatalog.cjs +35 -0
  131. package/dist/cjs/apis/updateGroupSettings.cjs +48 -0
  132. package/dist/cjs/apis/updateHiddenConversPin.cjs +35 -0
  133. package/dist/cjs/apis/updateLabels.cjs +39 -0
  134. package/dist/cjs/apis/updateLang.cjs +27 -11
  135. package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
  136. package/dist/cjs/apis/updateProfile.cjs +48 -0
  137. package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
  138. package/dist/cjs/apis/updateSettings.cjs +77 -11
  139. package/dist/cjs/apis/uploadAttachment.cjs +208 -0
  140. package/dist/cjs/apis/uploadProductPhoto.cjs +50 -0
  141. package/dist/cjs/apis/votePoll.cjs +34 -0
  142. package/dist/cjs/apis.cjs +292 -0
  143. package/dist/cjs/context.cjs +15 -0
  144. package/dist/cjs/core/enums/common.cjs +14 -0
  145. package/dist/cjs/core/utils/index.cjs +33 -0
  146. package/dist/cjs/models/GroupEvent.cjs +2 -4
  147. package/dist/cjs/utils.cjs +229 -3
  148. package/dist/cjs/zalo.cjs +18 -7
  149. package/dist/index.d.ts +1 -0
  150. package/dist/models/GroupEvent.d.ts +2 -2
  151. package/dist/models/GroupEvent.js +2 -4
  152. package/dist/models/Message.d.ts +6 -0
  153. package/dist/zalo.d.ts +17 -10
  154. package/dist/zalo.js +19 -8
  155. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getGroupInviteBoxInfoFactory = utils.apiFactory()((api, _, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/inv-box/inv-info`);
8
+ /**
9
+ * Get group invite box info
10
+ *
11
+ * @param payload - The payload of the request
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getGroupInviteBoxInfo(payload) {
16
+ var _a, _b;
17
+ const params = {
18
+ grId: payload.groupId,
19
+ mcount: (_a = payload.mcount) !== null && _a !== void 0 ? _a : 10,
20
+ mpage: (_b = payload.mpage) !== null && _b !== void 0 ? _b : 1,
21
+ };
22
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
23
+ if (!encryptedParams)
24
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
25
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
26
+ method: 'GET',
27
+ });
28
+ return utils.resolve(response, (result) => {
29
+ const data = result.data;
30
+ const topic = data.groupInfo.topic;
31
+ if (typeof topic.params == 'string') {
32
+ const params = JSON.parse(topic.params);
33
+ if (typeof params.extra == 'string') {
34
+ params.extra = JSON.parse(params.extra);
35
+ }
36
+ topic.params = params;
37
+ }
38
+ return data;
39
+ });
40
+ };
41
+ });
42
+
43
+ exports.getGroupInviteBoxInfoFactory = getGroupInviteBoxInfoFactory;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getGroupInviteBoxListFactory = utils.apiFactory()((api, _, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/inv-box/list`);
8
+ /**
9
+ * Get group invite box list
10
+ *
11
+ * @param payload - The payload of the request
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getGroupInviteBoxList(payload) {
16
+ var _a, _b, _c, _d;
17
+ const params = {
18
+ mpage: (_a = payload === null || payload === void 0 ? void 0 : payload.mpage) !== null && _a !== void 0 ? _a : 1,
19
+ page: (_b = payload === null || payload === void 0 ? void 0 : payload.page) !== null && _b !== void 0 ? _b : 0,
20
+ invPerPage: (_c = payload === null || payload === void 0 ? void 0 : payload.invPerPage) !== null && _c !== void 0 ? _c : 12,
21
+ mcount: (_d = payload === null || payload === void 0 ? void 0 : payload.mcount) !== null && _d !== void 0 ? _d : 10,
22
+ lastGroupId: null, // @TODO: check type
23
+ avatar_size: 120,
24
+ member_avatar_size: 120,
25
+ };
26
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
27
+ if (!encryptedParams)
28
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
29
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
30
+ method: 'GET',
31
+ });
32
+ return utils.resolve(response);
33
+ };
34
+ });
35
+
36
+ exports.getGroupInviteBoxListFactory = getGroupInviteBoxListFactory;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getGroupLinkDetailFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/link/detail`);
8
+ /**
9
+ * Get group link detail
10
+ *
11
+ * @param groupId The group id
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getGroupLinkDetail(groupId) {
16
+ const params = {
17
+ grid: groupId,
18
+ imei: ctx.imei,
19
+ };
20
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
21
+ if (!encryptedParams)
22
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
23
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
24
+ method: 'GET',
25
+ });
26
+ return utils.resolve(response);
27
+ };
28
+ });
29
+
30
+ exports.getGroupLinkDetailFactory = getGroupLinkDetailFactory;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getGroupLinkInfoFactory = utils.apiFactory()((api, _ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/link/ginfo`);
8
+ /**
9
+ * Get group link info
10
+ *
11
+ * @param payload - The payload of the request
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getGroupLinkInfo(payload) {
16
+ var _a;
17
+ const params = {
18
+ link: payload.link,
19
+ avatar_size: 120,
20
+ member_avatar_size: 120,
21
+ mpage: (_a = payload.memberPage) !== null && _a !== void 0 ? _a : 1,
22
+ };
23
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
24
+ if (!encryptedParams)
25
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
26
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
27
+ method: 'GET',
28
+ });
29
+ return utils.resolve(response);
30
+ };
31
+ });
32
+
33
+ exports.getGroupLinkInfoFactory = getGroupLinkInfoFactory;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getGroupMembersInfoFactory = utils.apiFactory()((api, _, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/group/members`);
8
+ /**
9
+ * Get group information
10
+ *
11
+ * @param memberId member id or array of member ids
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getGroupMembersInfo(memberId) {
16
+ if (!Array.isArray(memberId))
17
+ memberId = [memberId];
18
+ const params = {
19
+ friend_pversion_map: memberId.map((id) => (id.endsWith('_0') ? id : `${id}_0`)),
20
+ };
21
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
22
+ if (!encryptedParams)
23
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt message');
24
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }));
25
+ return utils.resolve(response);
26
+ };
27
+ });
28
+
29
+ exports.getGroupMembersInfoFactory = getGroupMembersInfoFactory;
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getHiddenConversationsFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/hiddenconvers/get-all`);
8
+ /**
9
+ * Get hidden conversations
10
+ *
11
+ * @throws {ZaloApiError}
12
+ *
13
+ */
14
+ return async function getHiddenConversations() {
15
+ const params = {
16
+ imei: ctx.imei,
17
+ };
18
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
19
+ if (!encryptedParams)
20
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
21
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
22
+ method: 'GET',
23
+ });
24
+ return utils.resolve(response);
25
+ };
26
+ });
27
+
28
+ exports.getHiddenConversationsFactory = getHiddenConversationsFactory;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getLabelsFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.label[0]}/api/convlabel/get`);
8
+ /**
9
+ * Get all labels
10
+ *
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getLabels() {
14
+ const params = {
15
+ imei: ctx.imei,
16
+ };
17
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
18
+ if (!encryptedParams)
19
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
20
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }));
21
+ return utils.resolve(response, (result) => {
22
+ const data = result.data;
23
+ const formattedData = {
24
+ labelData: JSON.parse(data.labelData),
25
+ version: data.version,
26
+ lastUpdateTime: data.lastUpdateTime,
27
+ };
28
+ return formattedData;
29
+ });
30
+ };
31
+ });
32
+
33
+ exports.getLabelsFactory = getLabelsFactory;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getLastMessageFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ return async function getLastMessage(threadIdLocalMsgId = {}) {
8
+ const params = {
9
+ threadIdLocalMsgId: JSON.stringify(threadIdLocalMsgId),
10
+ imei: ctx.imei,
11
+ };
12
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
13
+ if (!encryptedParams)
14
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt message');
15
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/preloadconvers/get-last-msgs`, {
16
+ params: encryptedParams,
17
+ });
18
+ const response = await utils.request(serviceURL, {
19
+ method: 'GET',
20
+ });
21
+ return utils.resolve(response);
22
+ };
23
+ });
24
+
25
+ exports.getLastMessageFactory = getLastMessageFactory;
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ require('../models/AutoReply.cjs');
5
+ var Board = require('../models/Board.cjs');
6
+ require('../models/Enum.cjs');
7
+ require('../models/FriendEvent.cjs');
8
+ require('../models/Group.cjs');
9
+ require('../models/GroupEvent.cjs');
10
+ var utils = require('../utils.cjs');
11
+ require('../models/Reaction.cjs');
12
+ require('../models/Reminder.cjs');
13
+ require('../models/ZBusiness.cjs');
14
+
15
+ const getListBoardFactory = utils.apiFactory()((api, ctx, utils) => {
16
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/list`);
17
+ /**
18
+ * Get list board items in a group
19
+ *
20
+ * @param options - The options for the request
21
+ * @param groupId - The ID of the group
22
+ *
23
+ * @throws {ZaloApiError}
24
+ *
25
+ */
26
+ return async function getListBoard(options, groupId) {
27
+ var _a, _b;
28
+ const requestParams = {
29
+ group_id: groupId,
30
+ board_type: 0,
31
+ page: (_a = options.page) !== null && _a !== void 0 ? _a : 1,
32
+ count: (_b = options.count) !== null && _b !== void 0 ? _b : 20,
33
+ last_id: 0,
34
+ last_type: 0,
35
+ imei: ctx.imei,
36
+ };
37
+ const encryptedParams = utils.encodeAES(JSON.stringify(requestParams));
38
+ if (!encryptedParams)
39
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
40
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
41
+ method: 'GET',
42
+ });
43
+ return utils.resolve(response, (result) => {
44
+ const data = result.data;
45
+ data.items.forEach((item) => {
46
+ if (item.boardType != Board.BoardType.Poll) {
47
+ const detailData = item.data;
48
+ if (typeof detailData.params === 'string') {
49
+ detailData.params = JSON.parse(detailData.params);
50
+ }
51
+ }
52
+ });
53
+ return data;
54
+ });
55
+ };
56
+ });
57
+
58
+ exports.getListBoardFactory = getListBoardFactory;
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ require('../models/AutoReply.cjs');
5
+ require('../models/Board.cjs');
6
+ var Enum = require('../models/Enum.cjs');
7
+ require('../models/FriendEvent.cjs');
8
+ require('../models/Group.cjs');
9
+ require('../models/GroupEvent.cjs');
10
+ var utils = require('../utils.cjs');
11
+ require('../models/Reaction.cjs');
12
+ require('../models/Reminder.cjs');
13
+ require('../models/ZBusiness.cjs');
14
+
15
+ const getListReminderFactory = utils.apiFactory()((api, ctx, utils) => {
16
+ const serviceURL = {
17
+ [Enum.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/oneone/list`),
18
+ [Enum.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/listReminder`),
19
+ };
20
+ /**
21
+ * Get list reminder
22
+ *
23
+ * @param options - The options for the request
24
+ * @param threadId - The ID of the thread
25
+ * @param type - The type of the thread (User or Group)
26
+ *
27
+ * @throws {ZaloApiError}
28
+ */
29
+ return async function getListReminder(options, threadId, type = Enum.ThreadType.User) {
30
+ var _a, _b, _c, _d;
31
+ const requestParams = Object.assign({ objectData: JSON.stringify(type === Enum.ThreadType.User
32
+ ? {
33
+ uid: threadId,
34
+ board_type: 1,
35
+ page: (_a = options.page) !== null && _a !== void 0 ? _a : 1,
36
+ count: (_b = options.count) !== null && _b !== void 0 ? _b : 20,
37
+ last_id: 0,
38
+ last_type: 0,
39
+ }
40
+ : {
41
+ group_id: threadId,
42
+ board_type: 1,
43
+ page: (_c = options.page) !== null && _c !== void 0 ? _c : 1,
44
+ count: (_d = options.count) !== null && _d !== void 0 ? _d : 20,
45
+ last_id: 0,
46
+ last_type: 0,
47
+ }) }, (type === Enum.ThreadType.Group && { imei: ctx.imei }));
48
+ const encryptedParams = utils.encodeAES(JSON.stringify(requestParams));
49
+ if (!encryptedParams)
50
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
51
+ const response = await utils.request(utils.makeURL(serviceURL[type], { params: encryptedParams }), {
52
+ method: 'GET',
53
+ });
54
+ return utils.resolve(response, (result) => {
55
+ return JSON.parse(result.data);
56
+ });
57
+ };
58
+ });
59
+
60
+ exports.getListReminderFactory = getListReminderFactory;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getMuteFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/getmute`);
8
+ /**
9
+ * Get mute
10
+ *
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getMute() {
14
+ const params = {
15
+ imei: ctx.imei,
16
+ };
17
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
18
+ if (!encryptedParams)
19
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
20
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
21
+ method: 'GET',
22
+ });
23
+ return utils.resolve(response);
24
+ };
25
+ });
26
+
27
+ exports.getMuteFactory = getMuteFactory;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils.cjs');
4
+
5
+ const getOwnIdFactory = utils.apiFactory()((_, ctx) => {
6
+ return () => ctx.uid;
7
+ });
8
+
9
+ exports.getOwnIdFactory = getOwnIdFactory;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getPendingGroupMembersFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/pending-mems/list`);
8
+ /**
9
+ * Get pending group members
10
+ *
11
+ * @param groupId - The id of the group to get the pending members
12
+ *
13
+ * @note Only the group leader and deputy group leader can view
14
+ *
15
+ * @throws {ZaloApiError}
16
+ */
17
+ return async function getPendingGroupMembers(groupId) {
18
+ const params = {
19
+ grid: groupId,
20
+ imei: ctx.imei,
21
+ };
22
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
23
+ if (!encryptedParams)
24
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
25
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
26
+ method: "GET",
27
+ });
28
+ return utils.resolve(response);
29
+ };
30
+ });
31
+
32
+ exports.getPendingGroupMembersFactory = getPendingGroupMembersFactory;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getPinConversationsFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/pinconvers/list`);
8
+ /**
9
+ * Get pin conversations
10
+ *
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getPinConversations() {
14
+ const params = {
15
+ imei: ctx.imei,
16
+ };
17
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
18
+ if (!encryptedParams)
19
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
20
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
21
+ method: "GET",
22
+ });
23
+ return utils.resolve(response);
24
+ };
25
+ });
26
+
27
+ exports.getPinConversationsFactory = getPinConversationsFactory;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getPollDetailFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/poll/detail`);
8
+ /**
9
+ * Get poll detail
10
+ *
11
+ * @param pollId Poll ID
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getPollDetail(pollId) {
16
+ if (!pollId)
17
+ throw new ZaloApiError.ZaloApiError('Missing poll id');
18
+ const params = {
19
+ poll_id: pollId,
20
+ imei: ctx.imei,
21
+ };
22
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
23
+ if (!encryptedParams)
24
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt message');
25
+ const response = await utils.request(serviceURL, {
26
+ method: 'POST',
27
+ body: new URLSearchParams({
28
+ params: encryptedParams,
29
+ }),
30
+ });
31
+ return utils.resolve(response);
32
+ };
33
+ });
34
+
35
+ exports.getPollDetailFactory = getPollDetailFactory;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getProductCatalogListFactory = utils.apiFactory()((api, _, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.catalog[0]}/api/prodcatalog/product/list`);
8
+ /**
9
+ * Get product catalog list?
10
+ *
11
+ * @param payload payload
12
+ *
13
+ * @note this API is used for zBusiness
14
+ * @throws {ZaloApiError}
15
+ */
16
+ return async function getProductCatalogList(payload) {
17
+ var _a, _b, _c, _d;
18
+ const params = {
19
+ catalog_id: payload.catalogId,
20
+ limit: (_a = payload.limit) !== null && _a !== void 0 ? _a : 100,
21
+ version_catalog: (_b = payload.versionCatalog) !== null && _b !== void 0 ? _b : 0,
22
+ last_product_id: (_c = payload.lastProductId) !== null && _c !== void 0 ? _c : -1,
23
+ page: (_d = payload.page) !== null && _d !== void 0 ? _d : 0,
24
+ };
25
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
26
+ if (!encryptedParams)
27
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
28
+ const response = await utils.request(serviceURL, {
29
+ method: 'POST',
30
+ body: new URLSearchParams({
31
+ params: encryptedParams,
32
+ }),
33
+ });
34
+ return utils.resolve(response);
35
+ };
36
+ });
37
+
38
+ exports.getProductCatalogListFactory = getProductCatalogListFactory;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getQRFactory = utils.apiFactory()((api, _, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/mget-qr`);
8
+ /**
9
+ * Get QR code for users
10
+ *
11
+ * @param userId User ID or list of user IDs
12
+ *
13
+ * @throws {ZaloApiError}
14
+ */
15
+ return async function getQR(userId) {
16
+ if (typeof userId == 'string')
17
+ userId = [userId];
18
+ const params = {
19
+ fids: userId,
20
+ };
21
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
22
+ if (!encryptedParams)
23
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
24
+ const response = await utils.request(serviceURL, {
25
+ method: 'POST',
26
+ body: new URLSearchParams({
27
+ params: encryptedParams,
28
+ }),
29
+ });
30
+ return utils.resolve(response);
31
+ };
32
+ });
33
+
34
+ exports.getQRFactory = getQRFactory;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const getQuickMessageListFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/list`);
8
+ /**
9
+ * Get quick message list
10
+ *
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getQuickMessageList() {
14
+ const params = {
15
+ version: 0,
16
+ lang: 0,
17
+ imei: ctx.imei,
18
+ };
19
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
20
+ if (!encryptedParams)
21
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
22
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
23
+ method: 'GET',
24
+ });
25
+ return utils.resolve(response);
26
+ };
27
+ });
28
+
29
+ exports.getQuickMessageListFactory = getQuickMessageListFactory;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils.cjs');
4
+
5
+ exports.FriendRequestType = void 0;
6
+ (function (FriendRequestType) {
7
+ FriendRequestType[FriendRequestType["Invitation"] = 1] = "Invitation";
8
+ FriendRequestType[FriendRequestType["Suggestion"] = 2] = "Suggestion";
9
+ })(exports.FriendRequestType || (exports.FriendRequestType = {}));
10
+ exports.RecommType = void 0;
11
+ (function (RecommType) {
12
+ RecommType[RecommType["Suggestion"] = 1] = "Suggestion";
13
+ RecommType[RecommType["Invitation"] = 2] = "Invitation";
14
+ })(exports.RecommType || (exports.RecommType = {}));
15
+ const getRecommendFriendsFactory = utils.apiFactory()((api, ctx, utils) => {
16
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/recommendsv2/list`);
17
+ return async function getRecommendFriends() {
18
+ const response = await utils.request(serviceURL, {
19
+ method: 'GET',
20
+ });
21
+ return utils.resolve(response);
22
+ };
23
+ });
24
+
25
+ exports.getRecommendFriendsFactory = getRecommendFriendsFactory;