@phuquy2203/n8n-nodes-zl-sumo 2.0.15

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 (350) hide show
  1. package/README.md +0 -0
  2. package/dist/credentials/ZaloApi.credentials.d.ts +7 -0
  3. package/dist/credentials/ZaloApi.credentials.js +49 -0
  4. package/dist/nodes/Zalo/Zalo.node.d.ts +5 -0
  5. package/dist/nodes/Zalo/Zalo.node.js +260 -0
  6. package/dist/nodes/Zalo/zalo.png +0 -0
  7. package/dist/nodes/Zalo/zalo.svg +3 -0
  8. package/dist/src/Errors/ZaloApiError.d.ts +4 -0
  9. package/dist/src/Errors/ZaloApiError.js +11 -0
  10. package/dist/src/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
  11. package/dist/src/Errors/ZaloApiLoginQRAborted.js +11 -0
  12. package/dist/src/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
  13. package/dist/src/Errors/ZaloApiLoginQRDeclined.js +11 -0
  14. package/dist/src/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
  15. package/dist/src/Errors/ZaloApiMissingImageMetadataGetter.js +11 -0
  16. package/dist/src/Errors/index.d.ts +4 -0
  17. package/dist/src/Errors/index.js +20 -0
  18. package/dist/src/apis/acceptFriendRequest.d.ts +2 -0
  19. package/dist/src/apis/acceptFriendRequest.js +31 -0
  20. package/dist/src/apis/addGroupBlockedMember.d.ts +2 -0
  21. package/dist/src/apis/addGroupBlockedMember.js +31 -0
  22. package/dist/src/apis/addGroupDeputy.d.ts +2 -0
  23. package/dist/src/apis/addGroupDeputy.js +33 -0
  24. package/dist/src/apis/addPollOptions.d.ts +14 -0
  25. package/dist/src/apis/addPollOptions.js +29 -0
  26. package/dist/src/apis/addQuickMessage.d.ts +11 -0
  27. package/dist/src/apis/addQuickMessage.js +63 -0
  28. package/dist/src/apis/addReaction.d.ts +18 -0
  29. package/dist/src/apis/addReaction.js +297 -0
  30. package/dist/src/apis/addUnreadMark.d.ts +8 -0
  31. package/dist/src/apis/addUnreadMark.js +55 -0
  32. package/dist/src/apis/addUserToGroup.d.ts +5 -0
  33. package/dist/src/apis/addUserToGroup.js +37 -0
  34. package/dist/src/apis/blockUser.d.ts +2 -0
  35. package/dist/src/apis/blockUser.js +31 -0
  36. package/dist/src/apis/blockViewFeed.d.ts +2 -0
  37. package/dist/src/apis/blockViewFeed.js +33 -0
  38. package/dist/src/apis/changeAccountAvatar.d.ts +3 -0
  39. package/dist/src/apis/changeAccountAvatar.js +58 -0
  40. package/dist/src/apis/changeFriendAlias.d.ts +2 -0
  41. package/dist/src/apis/changeFriendAlias.js +30 -0
  42. package/dist/src/apis/changeGroupAvatar.d.ts +3 -0
  43. package/dist/src/apis/changeGroupAvatar.js +50 -0
  44. package/dist/src/apis/changeGroupName.d.ts +4 -0
  45. package/dist/src/apis/changeGroupName.js +35 -0
  46. package/dist/src/apis/changeGroupOwner.d.ts +4 -0
  47. package/dist/src/apis/changeGroupOwner.js +33 -0
  48. package/dist/src/apis/createAutoReply.d.ts +14 -0
  49. package/dist/src/apis/createAutoReply.js +40 -0
  50. package/dist/src/apis/createCatalog.d.ts +7 -0
  51. package/dist/src/apis/createCatalog.js +32 -0
  52. package/dist/src/apis/createGroup.d.ts +28 -0
  53. package/dist/src/apis/createGroup.js +46 -0
  54. package/dist/src/apis/createNote.d.ts +7 -0
  55. package/dist/src/apis/createNote.js +50 -0
  56. package/dist/src/apis/createPoll.d.ts +36 -0
  57. package/dist/src/apis/createPoll.js +43 -0
  58. package/dist/src/apis/createProductCatalog.d.ts +23 -0
  59. package/dist/src/apis/createProductCatalog.js +53 -0
  60. package/dist/src/apis/createReminder.d.ts +12 -0
  61. package/dist/src/apis/createReminder.js +66 -0
  62. package/dist/src/apis/custom.d.ts +9 -0
  63. package/dist/src/apis/custom.js +17 -0
  64. package/dist/src/apis/deleteAutoReply.d.ts +5 -0
  65. package/dist/src/apis/deleteAutoReply.js +32 -0
  66. package/dist/src/apis/deleteAvatar.d.ts +9 -0
  67. package/dist/src/apis/deleteAvatar.js +30 -0
  68. package/dist/src/apis/deleteCatalog.d.ts +2 -0
  69. package/dist/src/apis/deleteCatalog.js +31 -0
  70. package/dist/src/apis/deleteChat.d.ts +19 -0
  71. package/dist/src/apis/deleteChat.js +53 -0
  72. package/dist/src/apis/deleteGroupInviteBox.d.ts +9 -0
  73. package/dist/src/apis/deleteGroupInviteBox.js +30 -0
  74. package/dist/src/apis/deleteMessage.d.ts +14 -0
  75. package/dist/src/apis/deleteMessage.js +55 -0
  76. package/dist/src/apis/deleteProductCatalog.d.ts +10 -0
  77. package/dist/src/apis/deleteProductCatalog.js +34 -0
  78. package/dist/src/apis/disableGroupLink.d.ts +2 -0
  79. package/dist/src/apis/disableGroupLink.js +27 -0
  80. package/dist/src/apis/disperseGroup.d.ts +2 -0
  81. package/dist/src/apis/disperseGroup.js +31 -0
  82. package/dist/src/apis/editNote.d.ts +17 -0
  83. package/dist/src/apis/editNote.js +49 -0
  84. package/dist/src/apis/editReminder.d.ts +13 -0
  85. package/dist/src/apis/editReminder.js +64 -0
  86. package/dist/src/apis/enableGroupLink.d.ts +6 -0
  87. package/dist/src/apis/enableGroupLink.js +28 -0
  88. package/dist/src/apis/fetchAccountInfo.d.ts +3 -0
  89. package/dist/src/apis/fetchAccountInfo.js +13 -0
  90. package/dist/src/apis/findUser.d.ts +15 -0
  91. package/dist/src/apis/findUser.js +43 -0
  92. package/dist/src/apis/forwardMessage.d.ts +24 -0
  93. package/dist/src/apis/forwardMessage.js +102 -0
  94. package/dist/src/apis/getAliasList.d.ts +8 -0
  95. package/dist/src/apis/getAliasList.js +30 -0
  96. package/dist/src/apis/getAllFriends.d.ts +3 -0
  97. package/dist/src/apis/getAllFriends.js +35 -0
  98. package/dist/src/apis/getAllGroups.d.ts +7 -0
  99. package/dist/src/apis/getAllGroups.js +13 -0
  100. package/dist/src/apis/getArchivedChatList.d.ts +5 -0
  101. package/dist/src/apis/getArchivedChatList.js +26 -0
  102. package/dist/src/apis/getAutoDeleteChat.d.ts +9 -0
  103. package/dist/src/apis/getAutoDeleteChat.js +24 -0
  104. package/dist/src/apis/getAutoReplyList.d.ts +6 -0
  105. package/dist/src/apis/getAutoReplyList.js +27 -0
  106. package/dist/src/apis/getAvatarList.d.ts +12 -0
  107. package/dist/src/apis/getAvatarList.js +31 -0
  108. package/dist/src/apis/getBizAccount.d.ts +24 -0
  109. package/dist/src/apis/getBizAccount.js +30 -0
  110. package/dist/src/apis/getCatalogList.d.ts +18 -0
  111. package/dist/src/apis/getCatalogList.js +35 -0
  112. package/dist/src/apis/getContext.d.ts +1 -0
  113. package/dist/src/apis/getContext.js +7 -0
  114. package/dist/src/apis/getCookie.d.ts +1 -0
  115. package/dist/src/apis/getCookie.js +12 -0
  116. package/dist/src/apis/getFriendBoardList.d.ts +5 -0
  117. package/dist/src/apis/getFriendBoardList.js +29 -0
  118. package/dist/src/apis/getFriendOnlines.d.ts +10 -0
  119. package/dist/src/apis/getFriendOnlines.js +38 -0
  120. package/dist/src/apis/getFriendRecommendations.d.ts +42 -0
  121. package/dist/src/apis/getFriendRecommendations.js +30 -0
  122. package/dist/src/apis/getFriendRequestStatus.d.ts +8 -0
  123. package/dist/src/apis/getFriendRequestStatus.js +28 -0
  124. package/dist/src/apis/getGroupBlockedMember.d.ts +23 -0
  125. package/dist/src/apis/getGroupBlockedMember.js +32 -0
  126. package/dist/src/apis/getGroupInfo.d.ts +16 -0
  127. package/dist/src/apis/getGroupInfo.js +35 -0
  128. package/dist/src/apis/getGroupInviteBoxInfo.d.ts +32 -0
  129. package/dist/src/apis/getGroupInviteBoxInfo.js +41 -0
  130. package/dist/src/apis/getGroupInviteBoxList.d.ts +38 -0
  131. package/dist/src/apis/getGroupInviteBoxList.js +34 -0
  132. package/dist/src/apis/getGroupLinkDetail.d.ts +9 -0
  133. package/dist/src/apis/getGroupLinkDetail.js +28 -0
  134. package/dist/src/apis/getGroupLinkInfo.d.ts +34 -0
  135. package/dist/src/apis/getGroupLinkInfo.js +31 -0
  136. package/dist/src/apis/getGroupMembersInfo.d.ts +17 -0
  137. package/dist/src/apis/getGroupMembersInfo.js +27 -0
  138. package/dist/src/apis/getHiddenConversations.d.ts +11 -0
  139. package/dist/src/apis/getHiddenConversations.js +26 -0
  140. package/dist/src/apis/getLabels.d.ts +7 -0
  141. package/dist/src/apis/getLabels.js +31 -0
  142. package/dist/src/apis/getListBoard.d.ts +21 -0
  143. package/dist/src/apis/getListBoard.js +48 -0
  144. package/dist/src/apis/getListReminder.d.ts +28 -0
  145. package/dist/src/apis/getListReminder.js +50 -0
  146. package/dist/src/apis/getMute.d.ts +13 -0
  147. package/dist/src/apis/getMute.js +25 -0
  148. package/dist/src/apis/getOwnId.d.ts +1 -0
  149. package/dist/src/apis/getOwnId.js +7 -0
  150. package/dist/src/apis/getPendingGroupMembers.d.ts +11 -0
  151. package/dist/src/apis/getPendingGroupMembers.js +30 -0
  152. package/dist/src/apis/getPinConversations.d.ts +5 -0
  153. package/dist/src/apis/getPinConversations.js +25 -0
  154. package/dist/src/apis/getPollDetail.d.ts +3 -0
  155. package/dist/src/apis/getPollDetail.js +33 -0
  156. package/dist/src/apis/getProductCatalogList.d.ts +20 -0
  157. package/dist/src/apis/getProductCatalogList.js +36 -0
  158. package/dist/src/apis/getQR.d.ts +4 -0
  159. package/dist/src/apis/getQR.js +32 -0
  160. package/dist/src/apis/getQuickMessageList.d.ts +7 -0
  161. package/dist/src/apis/getQuickMessageList.js +27 -0
  162. package/dist/src/apis/getRelatedFriendGroup.d.ts +6 -0
  163. package/dist/src/apis/getRelatedFriendGroup.js +33 -0
  164. package/dist/src/apis/getReminder.d.ts +3 -0
  165. package/dist/src/apis/getReminder.js +28 -0
  166. package/dist/src/apis/getReminderResponses.d.ts +5 -0
  167. package/dist/src/apis/getReminderResponses.js +27 -0
  168. package/dist/src/apis/getSentFriendRequest.d.ts +18 -0
  169. package/dist/src/apis/getSentFriendRequest.js +27 -0
  170. package/dist/src/apis/getSettings.d.ts +3 -0
  171. package/dist/src/apis/getSettings.js +23 -0
  172. package/dist/src/apis/getStickers.d.ts +1 -0
  173. package/dist/src/apis/getStickers.js +43 -0
  174. package/dist/src/apis/getStickersDetail.d.ts +24 -0
  175. package/dist/src/apis/getStickersDetail.js +43 -0
  176. package/dist/src/apis/getUnreadMark.d.ts +14 -0
  177. package/dist/src/apis/getUnreadMark.js +33 -0
  178. package/dist/src/apis/getUserInfo.d.ts +8 -0
  179. package/dist/src/apis/getUserInfo.js +45 -0
  180. package/dist/src/apis/inviteUserToGroups.d.ts +10 -0
  181. package/dist/src/apis/inviteUserToGroups.js +33 -0
  182. package/dist/src/apis/joinGroupInviteBox.d.ts +2 -0
  183. package/dist/src/apis/joinGroupInviteBox.js +28 -0
  184. package/dist/src/apis/joinGroupLink.d.ts +2 -0
  185. package/dist/src/apis/joinGroupLink.js +30 -0
  186. package/dist/src/apis/keepAlive.d.ts +4 -0
  187. package/dist/src/apis/keepAlive.js +25 -0
  188. package/dist/src/apis/lastOnline.d.ts +7 -0
  189. package/dist/src/apis/lastOnline.js +29 -0
  190. package/dist/src/apis/leaveGroup.d.ts +4 -0
  191. package/dist/src/apis/leaveGroup.js +36 -0
  192. package/dist/src/apis/listen.d.ts +103 -0
  193. package/dist/src/apis/listen.js +432 -0
  194. package/dist/src/apis/lockPoll.d.ts +2 -0
  195. package/dist/src/apis/lockPoll.js +31 -0
  196. package/dist/src/apis/login.d.ts +3 -0
  197. package/dist/src/apis/login.js +101 -0
  198. package/dist/src/apis/loginQR.d.ts +70 -0
  199. package/dist/src/apis/loginQR.js +369 -0
  200. package/dist/src/apis/parseLink.d.ts +21 -0
  201. package/dist/src/apis/parseLink.js +30 -0
  202. package/dist/src/apis/rejectFriendRequest.d.ts +2 -0
  203. package/dist/src/apis/rejectFriendRequest.js +30 -0
  204. package/dist/src/apis/removeFriend.d.ts +2 -0
  205. package/dist/src/apis/removeFriend.js +31 -0
  206. package/dist/src/apis/removeFriendAlias.d.ts +2 -0
  207. package/dist/src/apis/removeFriendAlias.js +27 -0
  208. package/dist/src/apis/removeGroupBlockedMember.d.ts +2 -0
  209. package/dist/src/apis/removeGroupBlockedMember.js +31 -0
  210. package/dist/src/apis/removeGroupDeputy.d.ts +2 -0
  211. package/dist/src/apis/removeGroupDeputy.js +33 -0
  212. package/dist/src/apis/removeQuickMessage.d.ts +5 -0
  213. package/dist/src/apis/removeQuickMessage.js +30 -0
  214. package/dist/src/apis/removeReminder.d.ts +3 -0
  215. package/dist/src/apis/removeReminder.js +43 -0
  216. package/dist/src/apis/removeUnreadMark.d.ts +8 -0
  217. package/dist/src/apis/removeUnreadMark.js +53 -0
  218. package/dist/src/apis/removeUserFromGroup.d.ts +4 -0
  219. package/dist/src/apis/removeUserFromGroup.js +37 -0
  220. package/dist/src/apis/resetHiddenConversPin.d.ts +2 -0
  221. package/dist/src/apis/resetHiddenConversPin.js +23 -0
  222. package/dist/src/apis/reuseAvatar.d.ts +2 -0
  223. package/dist/src/apis/reuseAvatar.js +29 -0
  224. package/dist/src/apis/reviewPendingMemberRequest.d.ts +14 -0
  225. package/dist/src/apis/reviewPendingMemberRequest.js +41 -0
  226. package/dist/src/apis/sendBankCard.d.ts +9 -0
  227. package/dist/src/apis/sendBankCard.js +40 -0
  228. package/dist/src/apis/sendCard.d.ts +10 -0
  229. package/dist/src/apis/sendCard.js +62 -0
  230. package/dist/src/apis/sendDeliveredEvent.d.ts +16 -0
  231. package/dist/src/apis/sendDeliveredEvent.js +58 -0
  232. package/dist/src/apis/sendFriendRequest.d.ts +2 -0
  233. package/dist/src/apis/sendFriendRequest.js +42 -0
  234. package/dist/src/apis/sendLink.d.ts +10 -0
  235. package/dist/src/apis/sendLink.js +64 -0
  236. package/dist/src/apis/sendMessage.d.ts +99 -0
  237. package/dist/src/apis/sendMessage.js +455 -0
  238. package/dist/src/apis/sendReport.d.ts +17 -0
  239. package/dist/src/apis/sendReport.js +56 -0
  240. package/dist/src/apis/sendSeenEvent.d.ts +16 -0
  241. package/dist/src/apis/sendSeenEvent.js +66 -0
  242. package/dist/src/apis/sendSticker.d.ts +10 -0
  243. package/dist/src/apis/sendSticker.js +60 -0
  244. package/dist/src/apis/sendTypingEvent.d.ts +5 -0
  245. package/dist/src/apis/sendTypingEvent.js +36 -0
  246. package/dist/src/apis/sendVideo.d.ts +35 -0
  247. package/dist/src/apis/sendVideo.js +121 -0
  248. package/dist/src/apis/sendVoice.d.ts +12 -0
  249. package/dist/src/apis/sendVoice.js +76 -0
  250. package/dist/src/apis/setArchivedConversations.d.ts +10 -0
  251. package/dist/src/apis/setArchivedConversations.js +37 -0
  252. package/dist/src/apis/setHiddenConversations.d.ts +3 -0
  253. package/dist/src/apis/setHiddenConversations.js +42 -0
  254. package/dist/src/apis/setMute.d.ts +20 -0
  255. package/dist/src/apis/setMute.js +70 -0
  256. package/dist/src/apis/setPinnedConversations.d.ts +3 -0
  257. package/dist/src/apis/setPinnedConversations.js +37 -0
  258. package/dist/src/apis/sharePoll.d.ts +2 -0
  259. package/dist/src/apis/sharePoll.js +31 -0
  260. package/dist/src/apis/unblockUser.d.ts +2 -0
  261. package/dist/src/apis/unblockUser.js +31 -0
  262. package/dist/src/apis/undo.d.ts +9 -0
  263. package/dist/src/apis/undo.js +45 -0
  264. package/dist/src/apis/undoFriendRequest.d.ts +2 -0
  265. package/dist/src/apis/undoFriendRequest.js +30 -0
  266. package/dist/src/apis/updateActiveStatus.d.ts +4 -0
  267. package/dist/src/apis/updateActiveStatus.js +30 -0
  268. package/dist/src/apis/updateAutoDeleteChat.d.ts +9 -0
  269. package/dist/src/apis/updateAutoDeleteChat.js +43 -0
  270. package/dist/src/apis/updateAutoReply.d.ts +15 -0
  271. package/dist/src/apis/updateAutoReply.js +41 -0
  272. package/dist/src/apis/updateCatalog.d.ts +11 -0
  273. package/dist/src/apis/updateCatalog.js +33 -0
  274. package/dist/src/apis/updateGroupSettings.d.ts +40 -0
  275. package/dist/src/apis/updateGroupSettings.js +46 -0
  276. package/dist/src/apis/updateHiddenConversPin.d.ts +2 -0
  277. package/dist/src/apis/updateHiddenConversPin.js +33 -0
  278. package/dist/src/apis/updateLabels.d.ts +15 -0
  279. package/dist/src/apis/updateLabels.js +37 -0
  280. package/dist/src/apis/updateLang.d.ts +6 -0
  281. package/dist/src/apis/updateLang.js +33 -0
  282. package/dist/src/apis/updateProductCatalog.d.ts +25 -0
  283. package/dist/src/apis/updateProductCatalog.js +54 -0
  284. package/dist/src/apis/updateProfile.d.ts +20 -0
  285. package/dist/src/apis/updateProfile.js +46 -0
  286. package/dist/src/apis/updateQuickMessage.d.ts +11 -0
  287. package/dist/src/apis/updateQuickMessage.js +64 -0
  288. package/dist/src/apis/updateSettings.d.ts +16 -0
  289. package/dist/src/apis/updateSettings.js +93 -0
  290. package/dist/src/apis/uploadAttachment.d.ts +50 -0
  291. package/dist/src/apis/uploadAttachment.js +202 -0
  292. package/dist/src/apis/uploadProductPhoto.d.ts +14 -0
  293. package/dist/src/apis/uploadProductPhoto.js +56 -0
  294. package/dist/src/apis/votePoll.d.ts +5 -0
  295. package/dist/src/apis/votePoll.js +32 -0
  296. package/dist/src/apis.d.ts +279 -0
  297. package/dist/src/apis.js +283 -0
  298. package/dist/src/context.d.ts +183 -0
  299. package/dist/src/context.js +33 -0
  300. package/dist/src/index.d.ts +146 -0
  301. package/dist/src/index.js +41 -0
  302. package/dist/src/models/Attachment.d.ts +11 -0
  303. package/dist/src/models/Attachment.js +2 -0
  304. package/dist/src/models/AutoReply.d.ts +20 -0
  305. package/dist/src/models/AutoReply.js +10 -0
  306. package/dist/src/models/Board.d.ts +60 -0
  307. package/dist/src/models/Board.js +9 -0
  308. package/dist/src/models/Catalog.d.ts +16 -0
  309. package/dist/src/models/Catalog.js +2 -0
  310. package/dist/src/models/DeliveredMessage.d.ts +27 -0
  311. package/dist/src/models/DeliveredMessage.js +22 -0
  312. package/dist/src/models/Enum.d.ts +247 -0
  313. package/dist/src/models/Enum.js +254 -0
  314. package/dist/src/models/FriendEvent.d.ts +107 -0
  315. package/dist/src/models/FriendEvent.js +87 -0
  316. package/dist/src/models/Group.d.ts +125 -0
  317. package/dist/src/models/Group.js +14 -0
  318. package/dist/src/models/GroupEvent.d.ts +178 -0
  319. package/dist/src/models/GroupEvent.js +94 -0
  320. package/dist/src/models/Label.d.ts +10 -0
  321. package/dist/src/models/Label.js +2 -0
  322. package/dist/src/models/Message.d.ts +91 -0
  323. package/dist/src/models/Message.js +34 -0
  324. package/dist/src/models/ProductCatalog.d.ts +17 -0
  325. package/dist/src/models/ProductCatalog.js +2 -0
  326. package/dist/src/models/QuickMessage.d.ts +25 -0
  327. package/dist/src/models/QuickMessage.js +2 -0
  328. package/dist/src/models/Reaction.d.ts +85 -0
  329. package/dist/src/models/Reaction.js +74 -0
  330. package/dist/src/models/Reminder.d.ts +51 -0
  331. package/dist/src/models/Reminder.js +10 -0
  332. package/dist/src/models/SeenMessage.d.ts +26 -0
  333. package/dist/src/models/SeenMessage.js +22 -0
  334. package/dist/src/models/Typing.d.ts +24 -0
  335. package/dist/src/models/Typing.js +22 -0
  336. package/dist/src/models/Undo.d.ts +34 -0
  337. package/dist/src/models/Undo.js +16 -0
  338. package/dist/src/models/User.d.ts +49 -0
  339. package/dist/src/models/User.js +2 -0
  340. package/dist/src/models/ZBusiness.d.ts +22 -0
  341. package/dist/src/models/ZBusiness.js +38 -0
  342. package/dist/src/models/index.d.ts +20 -0
  343. package/dist/src/models/index.js +36 -0
  344. package/dist/src/update.d.ts +2 -0
  345. package/dist/src/update.js +33 -0
  346. package/dist/src/utils.d.ts +169 -0
  347. package/dist/src/utils.js +737 -0
  348. package/dist/src/zalo.d.ts +41 -0
  349. package/dist/src/zalo.js +110 -0
  350. package/package.json +60 -0
@@ -0,0 +1,20 @@
1
+ import type { BusinessCategory, Gender } from "../models/index.js";
2
+ export type UpdateProfilePayload = {
3
+ profile: {
4
+ name: string;
5
+ /**
6
+ * Date of birth in the format YYYY-MM-DD
7
+ */
8
+ dob: `${string}-${string}-${string}`;
9
+ gender: Gender;
10
+ };
11
+ biz?: Partial<{
12
+ cate: BusinessCategory;
13
+ description: string;
14
+ address: string;
15
+ website: string;
16
+ email: string;
17
+ }>;
18
+ };
19
+ export type UpdateProfileResponse = "";
20
+ export declare const updateProfileFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (payload: UpdateProfilePayload) => Promise<"">;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProfileFactory = void 0;
4
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ exports.updateProfileFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/update`);
8
+ /**
9
+ * Change account setting information
10
+ *
11
+ * @param payload payload
12
+ *
13
+ * @note If your account is a Business Account, include the biz.cate field; otherwise the category will be removed.
14
+ * You may leave the other biz fields empty if you don’t want to change them.
15
+ *
16
+ * @throws {ZaloApiError}
17
+ */
18
+ return async function updateProfile(payload) {
19
+ var _a, _b, _c, _d, _e;
20
+ const params = {
21
+ profile: JSON.stringify({
22
+ name: payload.profile.name,
23
+ dob: payload.profile.dob,
24
+ gender: payload.profile.gender,
25
+ }),
26
+ biz: JSON.stringify({
27
+ desc: (_a = payload.biz) === null || _a === void 0 ? void 0 : _a.description,
28
+ cate: (_b = payload.biz) === null || _b === void 0 ? void 0 : _b.cate,
29
+ addr: (_c = payload.biz) === null || _c === void 0 ? void 0 : _c.address,
30
+ website: (_d = payload.biz) === null || _d === void 0 ? void 0 : _d.website,
31
+ email: (_e = payload.biz) === null || _e === void 0 ? void 0 : _e.email,
32
+ }),
33
+ language: ctx.language,
34
+ };
35
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
36
+ if (!encryptedParams)
37
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
38
+ const response = await utils.request(serviceURL, {
39
+ method: "POST",
40
+ body: new URLSearchParams({
41
+ params: encryptedParams,
42
+ }),
43
+ });
44
+ return utils.resolve(response);
45
+ };
46
+ });
@@ -0,0 +1,11 @@
1
+ import type { QuickMessage, AttachmentSource } from "../models/index.js";
2
+ export type UpdateQuickMessagePayload = {
3
+ keyword: string;
4
+ title: string;
5
+ media?: AttachmentSource;
6
+ };
7
+ export type UpdateQuickMessageResponse = {
8
+ item: QuickMessage;
9
+ version: number;
10
+ };
11
+ export declare const updateQuickMessageFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (updatePayload: UpdateQuickMessagePayload, itemId: number) => Promise<UpdateQuickMessageResponse>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateQuickMessageFactory = void 0;
4
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ exports.updateQuickMessageFactory = (0, utils_js_1.apiFactory)()((api, _ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/update`);
8
+ /**
9
+ * Update quick message
10
+ *
11
+ * @param updatePayload - The payload containing data to update the quick message
12
+ * @param itemId - The id of the quick message to update
13
+ *
14
+ * @note Zalo might throw an error with code 212 if the itemId does not exist.
15
+ *
16
+ * @throws {ZaloApiError}
17
+ */
18
+ return async function updateQuickMessage(updatePayload, itemId) {
19
+ const isType = !updatePayload.media ? 0 : 1;
20
+ const params = {
21
+ itemId: itemId,
22
+ keyword: updatePayload.keyword,
23
+ message: {
24
+ title: updatePayload.title,
25
+ params: "",
26
+ },
27
+ type: isType,
28
+ };
29
+ if (isType === 1) {
30
+ if (!updatePayload.media)
31
+ throw new ZaloApiError_js_1.ZaloApiError("Media is required");
32
+ const uploadMedia = await api.uploadProductPhoto({
33
+ file: updatePayload.media,
34
+ });
35
+ const photoId = uploadMedia.photoId;
36
+ const thumbUrl = uploadMedia.thumbUrl;
37
+ const normalUrl = uploadMedia.normalUrl;
38
+ const hdUrl = uploadMedia.hdUrl;
39
+ params.media = {
40
+ items: [
41
+ {
42
+ type: 0,
43
+ photoId: photoId,
44
+ title: "",
45
+ width: "",
46
+ height: "",
47
+ previewThumb: thumbUrl,
48
+ rawUrl: normalUrl || hdUrl,
49
+ thumbUrl: thumbUrl,
50
+ normalUrl: normalUrl || hdUrl,
51
+ hdUrl: hdUrl || normalUrl,
52
+ },
53
+ ],
54
+ };
55
+ }
56
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
57
+ if (!encryptedParams)
58
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
59
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
60
+ method: "GET",
61
+ });
62
+ return utils.resolve(response);
63
+ };
64
+ });
@@ -0,0 +1,16 @@
1
+ export type UpdateSettingsResponse = "";
2
+ export declare enum UpdateSettingsType {
3
+ ViewBirthday = "view_birthday",
4
+ ShowOnlineStatus = "show_online_status",
5
+ DisplaySeenStatus = "display_seen_status",
6
+ ReceiveMessage = "receive_message",
7
+ AcceptCall = "accept_stranger_call",
8
+ AddFriendViaPhone = "add_friend_via_phone",
9
+ AddFriendViaQR = "add_friend_via_qr",
10
+ AddFriendViaGroup = "add_friend_via_group",
11
+ AddFriendViaContact = "add_friend_via_contact",
12
+ DisplayOnRecommendFriend = "display_on_recommend_friend",
13
+ ArchivedChat = "archivedChatStatus",
14
+ QuickMessage = "quickMessageStatus"
15
+ }
16
+ export declare const updateSettingsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (type: UpdateSettingsType, value: number) => Promise<"">;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateSettingsFactory = exports.UpdateSettingsType = void 0;
4
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ var UpdateSettingsType;
7
+ (function (UpdateSettingsType) {
8
+ UpdateSettingsType["ViewBirthday"] = "view_birthday";
9
+ UpdateSettingsType["ShowOnlineStatus"] = "show_online_status";
10
+ UpdateSettingsType["DisplaySeenStatus"] = "display_seen_status";
11
+ UpdateSettingsType["ReceiveMessage"] = "receive_message";
12
+ UpdateSettingsType["AcceptCall"] = "accept_stranger_call";
13
+ UpdateSettingsType["AddFriendViaPhone"] = "add_friend_via_phone";
14
+ UpdateSettingsType["AddFriendViaQR"] = "add_friend_via_qr";
15
+ UpdateSettingsType["AddFriendViaGroup"] = "add_friend_via_group";
16
+ UpdateSettingsType["AddFriendViaContact"] = "add_friend_via_contact";
17
+ UpdateSettingsType["DisplayOnRecommendFriend"] = "display_on_recommend_friend";
18
+ UpdateSettingsType["ArchivedChat"] = "archivedChatStatus";
19
+ UpdateSettingsType["QuickMessage"] = "quickMessageStatus";
20
+ })(UpdateSettingsType || (exports.UpdateSettingsType = UpdateSettingsType = {}));
21
+ exports.updateSettingsFactory = (0, utils_js_1.apiFactory)()((_api, _ctx, utils) => {
22
+ const serviceURL = utils.makeURL(`https://wpa.chat.zalo.me/api/setting/update`);
23
+ /**
24
+ * Set account settings
25
+ *
26
+ * @param type The type of setting to update
27
+ * @param value
28
+ *
29
+ * ViewBirthday
30
+ * * 0: hide
31
+ * * 1: show full day/month/year
32
+ * * 2: show day/month
33
+ *
34
+ * ShowOnlineStatus
35
+ * * 0: hide
36
+ * * 1: show
37
+ *
38
+ * DisplaySeenStatus
39
+ * * 0: hide
40
+ * * 1: show
41
+ *
42
+ * ReceiveMessage
43
+ * * 1: everyone
44
+ * * 2: only friends
45
+ *
46
+ * AcceptCall
47
+ * * 2: only friends
48
+ * * 3: everyone
49
+ * * 4: friends and person who contacted
50
+ *
51
+ * AddFriendViaPhone
52
+ * * 0: disable
53
+ * * 1: enable
54
+ *
55
+ * AddFriendViaQR
56
+ * * 0: disable
57
+ * * 1: enable
58
+ *
59
+ * AddFriendViaGroup
60
+ * * 0: disable
61
+ * * 1: enable
62
+ *
63
+ * AddFriendViaContact
64
+ * * 0: disable
65
+ * * 1: enable
66
+ *
67
+ * DisplayOnRecommendFriend
68
+ * * 0: disable
69
+ * * 1: enable
70
+ *
71
+ * ArchivedChat
72
+ * * 0: disable
73
+ * * 1: enable
74
+ *
75
+ * QuickMessage
76
+ * * 0: disable
77
+ * * 1: enable
78
+ *
79
+ * @throws {ZaloApiError}
80
+ */
81
+ return async function updateSettings(type, value) {
82
+ const params = {
83
+ [type]: value,
84
+ };
85
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
86
+ if (!encryptedParams)
87
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
88
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
89
+ method: "GET",
90
+ });
91
+ return utils.resolve(response);
92
+ };
93
+ });
@@ -0,0 +1,50 @@
1
+ import { ThreadType, type AttachmentSource } from "../models/index.js";
2
+ export type UploadAttachmentImageResponse = {
3
+ normalUrl: string;
4
+ photoId: string;
5
+ finished: number | boolean;
6
+ hdUrl: string;
7
+ thumbUrl: string;
8
+ clientFileId: number;
9
+ chunkId: number;
10
+ fileType: "image";
11
+ width: number;
12
+ height: number;
13
+ totalSize: number;
14
+ hdSize: number;
15
+ };
16
+ export type UploadAttachmentVideoResponse = {
17
+ finished: number | boolean;
18
+ clientFileId: number;
19
+ chunkId: number;
20
+ fileType: "video";
21
+ fileUrl: string;
22
+ fileId: string;
23
+ checksum: string;
24
+ totalSize: number;
25
+ fileName: string;
26
+ };
27
+ export type UploadAttachmentFileResponse = {
28
+ finished: number | boolean;
29
+ clientFileId: number;
30
+ chunkId: number;
31
+ fileType: "others";
32
+ fileUrl: string;
33
+ fileId: string;
34
+ checksum: string;
35
+ totalSize: number;
36
+ fileName: string;
37
+ };
38
+ export type ImageData = {
39
+ fileName: string;
40
+ totalSize: number | undefined;
41
+ width: number | undefined;
42
+ height: number | undefined;
43
+ };
44
+ export type FileData = {
45
+ fileName: string;
46
+ totalSize: number;
47
+ };
48
+ export type UploadAttachmentType = UploadAttachmentImageResponse | UploadAttachmentVideoResponse | UploadAttachmentFileResponse;
49
+ export type UploadAttachmentResponse = UploadAttachmentType[];
50
+ export declare const uploadAttachmentFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (sources: AttachmentSource | AttachmentSource[], threadId: string, type?: ThreadType) => Promise<UploadAttachmentType[]>;
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.uploadAttachmentFactory = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
10
+ const index_js_1 = require("../models/index.js");
11
+ const utils_js_1 = require("../utils.js");
12
+ const urlType = {
13
+ image: "photo_original/upload",
14
+ video: "asyncfile/upload",
15
+ others: "asyncfile/upload",
16
+ };
17
+ exports.uploadAttachmentFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
18
+ const serviceURL = `${api.zpwServiceMap.file[0]}/api`;
19
+ const { sharefile } = ctx.settings.features;
20
+ function isExceedMaxFile(totalFile) {
21
+ return totalFile > sharefile.max_file;
22
+ }
23
+ function isExceedMaxFileSize(fileSize) {
24
+ return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
25
+ }
26
+ function isExtensionValid(ext) {
27
+ return sharefile.restricted_ext_file.indexOf(ext) == -1;
28
+ }
29
+ /**
30
+ * Upload an attachment to a thread
31
+ *
32
+ * @param sources path to files or attachment sources
33
+ * @param threadId Group or User ID
34
+ * @param type Message type (User or Group)
35
+ *
36
+ * @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
37
+ */
38
+ return async function uploadAttachment(sources, threadId, type = index_js_1.ThreadType.User) {
39
+ if (!sources)
40
+ throw new ZaloApiError_js_1.ZaloApiError("Missing sources");
41
+ if (!Array.isArray(sources))
42
+ sources = [sources];
43
+ if (sources.length == 0)
44
+ throw new ZaloApiError_js_1.ZaloApiError("Missing sources");
45
+ if (isExceedMaxFile(sources.length))
46
+ throw new ZaloApiError_js_1.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
47
+ if (!threadId)
48
+ throw new ZaloApiError_js_1.ZaloApiError("Missing threadId");
49
+ const chunkSize = ctx.settings.features.sharefile.chunk_size_file;
50
+ const isGroupMessage = type == index_js_1.ThreadType.Group;
51
+ const attachmentsData = [];
52
+ const url = `${serviceURL}/${isGroupMessage ? "group" : "message"}/`;
53
+ const typeParam = isGroupMessage ? "11" : "2";
54
+ let clientId = Date.now();
55
+ for (const source of sources) {
56
+ const isFilePath = typeof source == "string";
57
+ const isBuffer = typeof source == "object" && source.data instanceof Buffer;
58
+ if (!isFilePath && !isBuffer)
59
+ throw new ZaloApiError_js_1.ZaloApiError("Invalid source type");
60
+ if (!isFilePath && !source.filename)
61
+ throw new ZaloApiError_js_1.ZaloApiError("Missing filename");
62
+ if (isFilePath && !node_fs_1.default.existsSync(source))
63
+ throw new ZaloApiError_js_1.ZaloApiError("File not found");
64
+ const extFile = (0, utils_js_1.getFileExtension)(isFilePath ? source : source.filename).toLowerCase();
65
+ const fileName = isFilePath ? (0, utils_js_1.getFileName)(source) : source.filename;
66
+ if (isExtensionValid(extFile) == false)
67
+ throw new ZaloApiError_js_1.ZaloApiError(`File extension "${extFile}" is not allowed`);
68
+ const data = {
69
+ filePath: isFilePath ? source : source.filename,
70
+ chunkContent: [],
71
+ params: {},
72
+ source,
73
+ };
74
+ if (isGroupMessage)
75
+ data.params.grid = threadId;
76
+ else
77
+ data.params.toid = threadId;
78
+ switch (extFile) {
79
+ case "jpg":
80
+ case "jpeg":
81
+ case "png":
82
+ case "webp": {
83
+ const imageData = isFilePath ? await (0, utils_js_1.getImageMetaData)(ctx, source) : Object.assign(Object.assign({}, source.metadata), { fileName });
84
+ if (isExceedMaxFileSize(imageData.totalSize))
85
+ throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
86
+ data.fileData = imageData;
87
+ data.fileType = "image";
88
+ data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
89
+ data.params.fileName = fileName;
90
+ data.params.clientId = clientId++;
91
+ data.params.totalSize = imageData.totalSize;
92
+ data.params.imei = ctx.imei;
93
+ data.params.isE2EE = 0;
94
+ data.params.jxl = 0;
95
+ data.params.chunkId = 1;
96
+ break;
97
+ }
98
+ case "mp4": {
99
+ const videoSize = isFilePath ? await (0, utils_js_1.getFileSize)(source) : source.metadata.totalSize;
100
+ if (isExceedMaxFileSize(videoSize))
101
+ throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
102
+ data.fileType = "video";
103
+ data.fileData = {
104
+ fileName,
105
+ totalSize: videoSize,
106
+ };
107
+ data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
108
+ data.params.fileName = fileName;
109
+ data.params.clientId = clientId++;
110
+ data.params.totalSize = videoSize;
111
+ data.params.imei = ctx.imei;
112
+ data.params.isE2EE = 0;
113
+ data.params.jxl = 0;
114
+ data.params.chunkId = 1;
115
+ break;
116
+ }
117
+ default: {
118
+ const fileSize = isFilePath ? await (0, utils_js_1.getFileSize)(source) : source.metadata.totalSize;
119
+ if (isExceedMaxFileSize(fileSize))
120
+ throw new ZaloApiError_js_1.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
121
+ data.fileType = "others";
122
+ data.fileData = {
123
+ fileName,
124
+ totalSize: fileSize,
125
+ };
126
+ data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
127
+ data.params.fileName = fileName;
128
+ data.params.clientId = clientId++;
129
+ data.params.totalSize = fileSize;
130
+ data.params.imei = ctx.imei;
131
+ data.params.isE2EE = 0;
132
+ data.params.jxl = 0;
133
+ data.params.chunkId = 1;
134
+ break;
135
+ }
136
+ }
137
+ const fileBuffer = isFilePath ? await node_fs_1.default.promises.readFile(source) : source.data;
138
+ for (let i = 0; i < data.params.totalChunk; i++) {
139
+ const formData = new form_data_1.default();
140
+ const slicedBuffer = fileBuffer.subarray(i * chunkSize, (i + 1) * chunkSize);
141
+ formData.append("chunkContent", slicedBuffer, {
142
+ filename: fileName,
143
+ contentType: "application/octet-stream",
144
+ });
145
+ data.chunkContent[i] = formData;
146
+ }
147
+ attachmentsData.push(data);
148
+ }
149
+ const requests = [], results = [];
150
+ for (const data of attachmentsData) {
151
+ for (let i = 0; i < data.params.totalChunk; i++) {
152
+ const encryptedParams = utils.encodeAES(JSON.stringify(data.params));
153
+ if (!encryptedParams)
154
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt message");
155
+ requests.push(utils
156
+ .request(utils.makeURL(url + urlType[data.fileType], { type: typeParam, params: encryptedParams }), {
157
+ method: "POST",
158
+ headers: data.chunkContent[i].getHeaders(),
159
+ body: data.chunkContent[i].getBuffer(),
160
+ })
161
+ .then(async (response) => {
162
+ /**
163
+ * @TODO: better type rather than any
164
+ */
165
+ const resData = await (0, utils_js_1.resolveResponse)(ctx, response);
166
+ if (resData && resData.fileId != "-1" && resData.photoId != "-1")
167
+ await new Promise((resolve) => {
168
+ if (data.fileType == "video" || data.fileType == "others") {
169
+ const uploadCallback = async (wsData) => {
170
+ const result = Object.assign(Object.assign(Object.assign({ fileType: data.fileType }, resData), wsData), { totalSize: data.fileData.totalSize, fileName: data.fileData.fileName, checksum: (await (0, utils_js_1.getMd5LargeFileObject)(data.source, data.fileData.totalSize)).data });
171
+ results.push(result);
172
+ resolve();
173
+ };
174
+ ctx.uploadCallbacks.set(resData.fileId.toString(), uploadCallback);
175
+ }
176
+ if (data.fileType == "image") {
177
+ const result = {
178
+ fileType: "image",
179
+ width: data.fileData.width,
180
+ height: data.fileData.height,
181
+ totalSize: data.fileData.totalSize,
182
+ hdSize: data.fileData.totalSize,
183
+ finished: resData.finished,
184
+ normalUrl: resData.normalUrl,
185
+ hdUrl: resData.hdUrl,
186
+ thumbUrl: resData.thumbUrl,
187
+ chunkId: resData.chunkId,
188
+ photoId: resData.photoId,
189
+ clientFileId: resData.clientFileId,
190
+ };
191
+ results.push(result);
192
+ resolve();
193
+ }
194
+ });
195
+ }));
196
+ data.params.chunkId++;
197
+ }
198
+ }
199
+ await Promise.all(requests);
200
+ return results;
201
+ };
202
+ });
@@ -0,0 +1,14 @@
1
+ import type { AttachmentSource } from "../models/index.js";
2
+ export type UploadProductPhotoPayload = {
3
+ file: AttachmentSource;
4
+ };
5
+ export type UploadProductPhotoResponse = {
6
+ normalUrl: string;
7
+ photoId: string;
8
+ finished: number;
9
+ hdUrl: string;
10
+ thumbUrl: string;
11
+ clientFileId: number;
12
+ chunkId: number;
13
+ };
14
+ export declare const uploadProductPhotoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (payload: UploadProductPhotoPayload) => Promise<UploadProductPhotoResponse>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.uploadProductPhotoFactory = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const form_data_1 = __importDefault(require("form-data"));
9
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
10
+ const utils_js_1 = require("../utils.js");
11
+ exports.uploadProductPhotoFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
12
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/product/upload/photo`);
13
+ /**
14
+ * Upload product photo for api quick message, product catalog or custom local storage
15
+ *
16
+ * @param payload file path or attachment source
17
+ *
18
+ * @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
19
+ */
20
+ return async function uploadProductPhoto(payload) {
21
+ const isSourceFilePath = typeof payload.file == "string";
22
+ const fileMetaData = isSourceFilePath
23
+ ? await (0, utils_js_1.getImageMetaData)(ctx, payload.file)
24
+ : payload.file.metadata;
25
+ const fileSize = fileMetaData.totalSize || 0;
26
+ const fileBuffer = isSourceFilePath
27
+ ? await node_fs_1.default.promises.readFile(payload.file)
28
+ : payload.file.data;
29
+ const formData = new form_data_1.default();
30
+ formData.append("chunkContent", fileBuffer, {
31
+ filename: "undefined",
32
+ contentType: "application/octet-stream",
33
+ });
34
+ const params = {
35
+ totalChunk: 1,
36
+ fileName: `Base64_Img_Picker_${Date.now()}.jpg`,
37
+ clientId: Date.now(),
38
+ totalSize: fileSize,
39
+ imei: ctx.imei,
40
+ chunkId: 1,
41
+ toid: ctx.loginInfo.send2me_id,
42
+ featureId: 1,
43
+ };
44
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
45
+ if (!encryptedParams)
46
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
47
+ const response = await utils.request(utils.makeURL(serviceURL, {
48
+ params: encryptedParams,
49
+ }), {
50
+ method: "POST",
51
+ headers: formData.getHeaders(),
52
+ body: formData.getBuffer(),
53
+ });
54
+ return utils.resolve(response);
55
+ };
56
+ });
@@ -0,0 +1,5 @@
1
+ import type { PollOptions } from "../models/index.js";
2
+ export type VotePollResponse = {
3
+ options: PollOptions[];
4
+ };
5
+ export declare const votePollFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (pollId: number, optionId: number | number[]) => Promise<VotePollResponse>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.votePollFactory = void 0;
4
+ const ZaloApiError_js_1 = require("../Errors/ZaloApiError.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ exports.votePollFactory = (0, utils_js_1.apiFactory)()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/poll/vote`);
8
+ /**
9
+ * Vote on a poll
10
+ *
11
+ * @param pollId The ID of the poll to vote on
12
+ * @param optionId The ID(s) of the option to vote on
13
+ *
14
+ * @throws ZaloApiError
15
+ */
16
+ return async function votePoll(pollId, optionId) {
17
+ if (!Array.isArray(optionId))
18
+ optionId = [optionId];
19
+ const params = {
20
+ poll_id: pollId,
21
+ option_ids: optionId, // unvote = empty array
22
+ imei: ctx.imei,
23
+ };
24
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
25
+ if (!encryptedParams)
26
+ throw new ZaloApiError_js_1.ZaloApiError("Failed to encrypt params");
27
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
28
+ method: "GET",
29
+ });
30
+ return utils.resolve(response);
31
+ };
32
+ });