zalo-toolkit 1.0.0
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.
- package/dist/Errors/ZaloApiError.d.ts +4 -0
- package/dist/Errors/ZaloApiError.js +7 -0
- package/dist/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRAborted.js +7 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.js +7 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.js +7 -0
- package/dist/Errors/index.d.ts +4 -0
- package/dist/Errors/index.js +4 -0
- package/dist/apis/acceptFriendRequest.d.ts +2 -0
- package/dist/apis/acceptFriendRequest.js +28 -0
- package/dist/apis/addGroupBlockedMember.d.ts +2 -0
- package/dist/apis/addGroupBlockedMember.js +28 -0
- package/dist/apis/addGroupDeputy.d.ts +2 -0
- package/dist/apis/addGroupDeputy.js +31 -0
- package/dist/apis/addPollOptions.d.ts +14 -0
- package/dist/apis/addPollOptions.js +26 -0
- package/dist/apis/addQuickMessage.d.ts +11 -0
- package/dist/apis/addQuickMessage.js +60 -0
- package/dist/apis/addReaction.d.ts +19 -0
- package/dist/apis/addReaction.js +292 -0
- package/dist/apis/addUnreadMark.d.ts +8 -0
- package/dist/apis/addUnreadMark.js +52 -0
- package/dist/apis/addUserToGroup.d.ts +5 -0
- package/dist/apis/addUserToGroup.js +34 -0
- package/dist/apis/blockUser.d.ts +2 -0
- package/dist/apis/blockUser.js +28 -0
- package/dist/apis/blockViewFeed.d.ts +2 -0
- package/dist/apis/blockViewFeed.js +30 -0
- package/dist/apis/changeAccountAvatar.d.ts +2 -0
- package/dist/apis/changeAccountAvatar.js +51 -0
- package/dist/apis/changeFriendAlias.d.ts +2 -0
- package/dist/apis/changeFriendAlias.js +27 -0
- package/dist/apis/changeGroupAvatar.d.ts +2 -0
- package/dist/apis/changeGroupAvatar.js +42 -0
- package/dist/apis/changeGroupName.d.ts +4 -0
- package/dist/apis/changeGroupName.js +32 -0
- package/dist/apis/changeGroupOwner.d.ts +4 -0
- package/dist/apis/changeGroupOwner.js +31 -0
- package/dist/apis/createAutoReply.d.ts +14 -0
- package/dist/apis/createAutoReply.js +37 -0
- package/dist/apis/createCatalog.d.ts +7 -0
- package/dist/apis/createCatalog.js +29 -0
- package/dist/apis/createGroup.d.ts +22 -0
- package/dist/apis/createGroup.js +43 -0
- package/dist/apis/createNote.d.ts +7 -0
- package/dist/apis/createNote.js +47 -0
- package/dist/apis/createPoll.d.ts +55 -0
- package/dist/apis/createPoll.js +40 -0
- package/dist/apis/createProductCatalog.d.ts +23 -0
- package/dist/apis/createProductCatalog.js +50 -0
- package/dist/apis/createReminder.d.ts +12 -0
- package/dist/apis/createReminder.js +63 -0
- package/dist/apis/custom.d.ts +9 -0
- package/dist/apis/custom.js +15 -0
- package/dist/apis/deleteAutoReply.d.ts +5 -0
- package/dist/apis/deleteAutoReply.js +29 -0
- package/dist/apis/deleteAvatar.d.ts +9 -0
- package/dist/apis/deleteAvatar.js +27 -0
- package/dist/apis/deleteCatalog.d.ts +2 -0
- package/dist/apis/deleteCatalog.js +28 -0
- package/dist/apis/deleteChat.d.ts +19 -0
- package/dist/apis/deleteChat.js +50 -0
- package/dist/apis/deleteGroupInviteBox.d.ts +9 -0
- package/dist/apis/deleteGroupInviteBox.js +27 -0
- package/dist/apis/deleteMessage.d.ts +14 -0
- package/dist/apis/deleteMessage.js +52 -0
- package/dist/apis/deleteProductCatalog.d.ts +10 -0
- package/dist/apis/deleteProductCatalog.js +31 -0
- package/dist/apis/disableGroupLink.d.ts +2 -0
- package/dist/apis/disableGroupLink.js +24 -0
- package/dist/apis/disperseGroup.d.ts +2 -0
- package/dist/apis/disperseGroup.js +28 -0
- package/dist/apis/editNote.d.ts +17 -0
- package/dist/apis/editNote.js +46 -0
- package/dist/apis/editReminder.d.ts +13 -0
- package/dist/apis/editReminder.js +61 -0
- package/dist/apis/enableGroupLink.d.ts +6 -0
- package/dist/apis/enableGroupLink.js +25 -0
- package/dist/apis/fetchAccountInfo.d.ts +3 -0
- package/dist/apis/fetchAccountInfo.js +10 -0
- package/dist/apis/findUser.d.ts +15 -0
- package/dist/apis/findUser.js +40 -0
- package/dist/apis/forwardAttachment.d.ts +16 -0
- package/dist/apis/forwardAttachment.js +80 -0
- package/dist/apis/forwardMessage.d.ts +33 -0
- package/dist/apis/forwardMessage.js +119 -0
- package/dist/apis/getAliasList.d.ts +8 -0
- package/dist/apis/getAliasList.js +28 -0
- package/dist/apis/getAllFriends.d.ts +3 -0
- package/dist/apis/getAllFriends.js +32 -0
- package/dist/apis/getAllGroups.d.ts +7 -0
- package/dist/apis/getAllGroups.js +10 -0
- package/dist/apis/getArchivedChatList.d.ts +5 -0
- package/dist/apis/getArchivedChatList.js +23 -0
- package/dist/apis/getAutoDeleteChat.d.ts +9 -0
- package/dist/apis/getAutoDeleteChat.js +21 -0
- package/dist/apis/getAutoReplyList.d.ts +6 -0
- package/dist/apis/getAutoReplyList.js +24 -0
- package/dist/apis/getAvatarList.d.ts +12 -0
- package/dist/apis/getAvatarList.js +28 -0
- package/dist/apis/getBizAccount.d.ts +24 -0
- package/dist/apis/getBizAccount.js +27 -0
- package/dist/apis/getCatalogList.d.ts +18 -0
- package/dist/apis/getCatalogList.js +32 -0
- package/dist/apis/getContext.d.ts +1 -0
- package/dist/apis/getContext.js +4 -0
- package/dist/apis/getCookie.d.ts +1 -0
- package/dist/apis/getCookie.js +9 -0
- package/dist/apis/getFriendBoardList.d.ts +5 -0
- package/dist/apis/getFriendBoardList.js +26 -0
- package/dist/apis/getFriendOnlines.d.ts +10 -0
- package/dist/apis/getFriendOnlines.js +35 -0
- package/dist/apis/getFriendRecommendations.d.ts +42 -0
- package/dist/apis/getFriendRecommendations.js +27 -0
- package/dist/apis/getFriendRequestStatus.d.ts +8 -0
- package/dist/apis/getFriendRequestStatus.js +25 -0
- package/dist/apis/getGroupBlockedMember.d.ts +23 -0
- package/dist/apis/getGroupBlockedMember.js +29 -0
- package/dist/apis/getGroupInfo.d.ts +16 -0
- package/dist/apis/getGroupInfo.js +32 -0
- package/dist/apis/getGroupInviteBoxInfo.d.ts +32 -0
- package/dist/apis/getGroupInviteBoxInfo.js +38 -0
- package/dist/apis/getGroupInviteBoxList.d.ts +38 -0
- package/dist/apis/getGroupInviteBoxList.js +31 -0
- package/dist/apis/getGroupLinkDetail.d.ts +9 -0
- package/dist/apis/getGroupLinkDetail.js +25 -0
- package/dist/apis/getGroupLinkInfo.d.ts +34 -0
- package/dist/apis/getGroupLinkInfo.js +28 -0
- package/dist/apis/getGroupMembersInfo.d.ts +17 -0
- package/dist/apis/getGroupMembersInfo.js +24 -0
- package/dist/apis/getHiddenConversations.d.ts +11 -0
- package/dist/apis/getHiddenConversations.js +23 -0
- package/dist/apis/getLabels.d.ts +7 -0
- package/dist/apis/getLabels.js +28 -0
- package/dist/apis/getLastMessage.d.ts +9 -0
- package/dist/apis/getLastMessage.js +20 -0
- package/dist/apis/getListBoard.d.ts +21 -0
- package/dist/apis/getListBoard.js +45 -0
- package/dist/apis/getListReminder.d.ts +28 -0
- package/dist/apis/getListReminder.js +47 -0
- package/dist/apis/getMute.d.ts +13 -0
- package/dist/apis/getMute.js +22 -0
- package/dist/apis/getOwnId.d.ts +1 -0
- package/dist/apis/getOwnId.js +4 -0
- package/dist/apis/getPendingGroupMembers.d.ts +11 -0
- package/dist/apis/getPendingGroupMembers.js +27 -0
- package/dist/apis/getPinConversations.d.ts +5 -0
- package/dist/apis/getPinConversations.js +22 -0
- package/dist/apis/getPollDetail.d.ts +3 -0
- package/dist/apis/getPollDetail.js +30 -0
- package/dist/apis/getProductCatalogList.d.ts +20 -0
- package/dist/apis/getProductCatalogList.js +33 -0
- package/dist/apis/getQR.d.ts +4 -0
- package/dist/apis/getQR.js +29 -0
- package/dist/apis/getQuickMessageList.d.ts +7 -0
- package/dist/apis/getQuickMessageList.js +24 -0
- package/dist/apis/getRecommendFriends.d.ts +40 -0
- package/dist/apis/getRecommendFriends.js +20 -0
- package/dist/apis/getRelatedFriendGroup.d.ts +6 -0
- package/dist/apis/getRelatedFriendGroup.js +30 -0
- package/dist/apis/getReminder.d.ts +3 -0
- package/dist/apis/getReminder.js +25 -0
- package/dist/apis/getReminderResponses.d.ts +5 -0
- package/dist/apis/getReminderResponses.js +24 -0
- package/dist/apis/getSentFriendRequest.d.ts +18 -0
- package/dist/apis/getSentFriendRequest.js +24 -0
- package/dist/apis/getSettings.d.ts +3 -0
- package/dist/apis/getSettings.js +20 -0
- package/dist/apis/getStickers.d.ts +1 -0
- package/dist/apis/getStickers.js +40 -0
- package/dist/apis/getStickersDetail.d.ts +24 -0
- package/dist/apis/getStickersDetail.js +40 -0
- package/dist/apis/getUnreadMark.d.ts +14 -0
- package/dist/apis/getUnreadMark.js +30 -0
- package/dist/apis/getUserInfo.d.ts +8 -0
- package/dist/apis/getUserInfo.js +42 -0
- package/dist/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/apis/inviteUserToGroups.js +30 -0
- package/dist/apis/joinGroupInviteBox.d.ts +2 -0
- package/dist/apis/joinGroupInviteBox.js +25 -0
- package/dist/apis/joinGroupLink.d.ts +2 -0
- package/dist/apis/joinGroupLink.js +27 -0
- package/dist/apis/keepAlive.d.ts +4 -0
- package/dist/apis/keepAlive.js +22 -0
- package/dist/apis/lastOnline.d.ts +7 -0
- package/dist/apis/lastOnline.js +26 -0
- package/dist/apis/leaveGroup.d.ts +4 -0
- package/dist/apis/leaveGroup.js +33 -0
- package/dist/apis/listen.d.ts +141 -0
- package/dist/apis/listen.js +822 -0
- package/dist/apis/lockPoll.d.ts +2 -0
- package/dist/apis/lockPoll.js +28 -0
- package/dist/apis/login.d.ts +3 -0
- package/dist/apis/login.js +96 -0
- package/dist/apis/loginQR.d.ts +42 -0
- package/dist/apis/loginQR.js +274 -0
- package/dist/apis/parseLink.d.ts +21 -0
- package/dist/apis/parseLink.js +27 -0
- package/dist/apis/rejectFriendRequest.d.ts +2 -0
- package/dist/apis/rejectFriendRequest.js +27 -0
- package/dist/apis/removeFriend.d.ts +2 -0
- package/dist/apis/removeFriend.js +28 -0
- package/dist/apis/removeFriendAlias.d.ts +2 -0
- package/dist/apis/removeFriendAlias.js +24 -0
- package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
- package/dist/apis/removeGroupBlockedMember.js +28 -0
- package/dist/apis/removeGroupDeputy.d.ts +2 -0
- package/dist/apis/removeGroupDeputy.js +30 -0
- package/dist/apis/removeQuickMessage.d.ts +5 -0
- package/dist/apis/removeQuickMessage.js +27 -0
- package/dist/apis/removeReminder.d.ts +3 -0
- package/dist/apis/removeReminder.js +40 -0
- package/dist/apis/removeUnreadMark.d.ts +8 -0
- package/dist/apis/removeUnreadMark.js +50 -0
- package/dist/apis/removeUserFromGroup.d.ts +4 -0
- package/dist/apis/removeUserFromGroup.js +34 -0
- package/dist/apis/resetHiddenConversPin.d.ts +2 -0
- package/dist/apis/resetHiddenConversPin.js +20 -0
- package/dist/apis/reuseAvatar.d.ts +2 -0
- package/dist/apis/reuseAvatar.js +26 -0
- package/dist/apis/reviewPendingMemberRequest.d.ts +14 -0
- package/dist/apis/reviewPendingMemberRequest.js +38 -0
- package/dist/apis/sendBankCard.d.ts +9 -0
- package/dist/apis/sendBankCard.js +37 -0
- package/dist/apis/sendCard.d.ts +10 -0
- package/dist/apis/sendCard.js +59 -0
- package/dist/apis/sendDeliveredEvent.d.ts +16 -0
- package/dist/apis/sendDeliveredEvent.js +55 -0
- package/dist/apis/sendFriendRequest.d.ts +2 -0
- package/dist/apis/sendFriendRequest.js +39 -0
- package/dist/apis/sendLink.d.ts +10 -0
- package/dist/apis/sendLink.js +57 -0
- package/dist/apis/sendMessage.d.ts +100 -0
- package/dist/apis/sendMessage.js +437 -0
- package/dist/apis/sendReport.d.ts +17 -0
- package/dist/apis/sendReport.js +53 -0
- package/dist/apis/sendSeenEvent.d.ts +16 -0
- package/dist/apis/sendSeenEvent.js +63 -0
- package/dist/apis/sendSticker.d.ts +10 -0
- package/dist/apis/sendSticker.js +56 -0
- package/dist/apis/sendTypingEvent.d.ts +5 -0
- package/dist/apis/sendTypingEvent.js +33 -0
- package/dist/apis/sendVideo.d.ts +35 -0
- package/dist/apis/sendVideo.js +118 -0
- package/dist/apis/sendVoice.d.ts +12 -0
- package/dist/apis/sendVoice.js +73 -0
- package/dist/apis/setArchivedConversations.d.ts +10 -0
- package/dist/apis/setArchivedConversations.js +34 -0
- package/dist/apis/setHiddenConversations.d.ts +3 -0
- package/dist/apis/setHiddenConversations.js +39 -0
- package/dist/apis/setMute.d.ts +20 -0
- package/dist/apis/setMute.js +67 -0
- package/dist/apis/setPinnedConversations.d.ts +3 -0
- package/dist/apis/setPinnedConversations.js +34 -0
- package/dist/apis/sharePoll.d.ts +2 -0
- package/dist/apis/sharePoll.js +28 -0
- package/dist/apis/unblockUser.d.ts +2 -0
- package/dist/apis/unblockUser.js +28 -0
- package/dist/apis/undo.d.ts +9 -0
- package/dist/apis/undo.js +42 -0
- package/dist/apis/undoFriendRequest.d.ts +2 -0
- package/dist/apis/undoFriendRequest.js +27 -0
- package/dist/apis/updateActiveStatus.d.ts +4 -0
- package/dist/apis/updateActiveStatus.js +27 -0
- package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
- package/dist/apis/updateAutoDeleteChat.js +40 -0
- package/dist/apis/updateAutoReply.d.ts +15 -0
- package/dist/apis/updateAutoReply.js +38 -0
- package/dist/apis/updateCatalog.d.ts +11 -0
- package/dist/apis/updateCatalog.js +30 -0
- package/dist/apis/updateGroupSettings.d.ts +40 -0
- package/dist/apis/updateGroupSettings.js +43 -0
- package/dist/apis/updateHiddenConversPin.d.ts +2 -0
- package/dist/apis/updateHiddenConversPin.js +30 -0
- package/dist/apis/updateLabels.d.ts +15 -0
- package/dist/apis/updateLabels.js +34 -0
- package/dist/apis/updateLang.d.ts +6 -0
- package/dist/apis/updateLang.js +30 -0
- package/dist/apis/updateProductCatalog.d.ts +25 -0
- package/dist/apis/updateProductCatalog.js +51 -0
- package/dist/apis/updateProfile.d.ts +20 -0
- package/dist/apis/updateProfile.js +43 -0
- package/dist/apis/updateQuickMessage.d.ts +11 -0
- package/dist/apis/updateQuickMessage.js +61 -0
- package/dist/apis/updateSettings.d.ts +16 -0
- package/dist/apis/updateSettings.js +90 -0
- package/dist/apis/uploadAttachment.d.ts +51 -0
- package/dist/apis/uploadAttachment.js +195 -0
- package/dist/apis/uploadProductPhoto.d.ts +13 -0
- package/dist/apis/uploadProductPhoto.js +45 -0
- package/dist/apis/votePoll.d.ts +5 -0
- package/dist/apis/votePoll.js +29 -0
- package/dist/apis.d.ts +293 -0
- package/dist/apis.js +287 -0
- package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
- package/dist/cjs/Errors/ZaloApiLoginQRAborted.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiLoginQRDeclined.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiMissingImageMetadataGetter.cjs +12 -0
- package/dist/cjs/apis/login.cjs +102 -0
- package/dist/cjs/apis/loginQR.cjs +282 -0
- package/dist/cjs/apis/reviewPendingMemberRequest.cjs +21 -0
- package/dist/cjs/apis/sendMessage.cjs +44 -0
- package/dist/cjs/apis/sendReport.cjs +28 -0
- package/dist/cjs/apis/setMute.cjs +33 -0
- package/dist/cjs/apis/updateAutoDeleteChat.cjs +28 -0
- package/dist/cjs/apis/updateLang.cjs +19 -0
- package/dist/cjs/apis/updateSettings.cjs +29 -0
- package/dist/cjs/context.cjs +19 -0
- package/dist/cjs/index.cjs +142 -0
- package/dist/cjs/models/AutoReply.cjs +9 -0
- package/dist/cjs/models/Board.cjs +8 -0
- package/dist/cjs/models/DeliveredMessage.cjs +23 -0
- package/dist/cjs/models/Enum.cjs +253 -0
- package/dist/cjs/models/FriendEvent.cjs +87 -0
- package/dist/cjs/models/Group.cjs +13 -0
- package/dist/cjs/models/GroupEvent.cjs +94 -0
- package/dist/cjs/models/Listen.cjs +134 -0
- package/dist/cjs/models/Message.cjs +40 -0
- package/dist/cjs/models/Reaction.cjs +74 -0
- package/dist/cjs/models/Reminder.cjs +9 -0
- package/dist/cjs/models/SeenMessage.cjs +23 -0
- package/dist/cjs/models/Typing.cjs +23 -0
- package/dist/cjs/models/Undo.cjs +16 -0
- package/dist/cjs/models/ZBusiness.cjs +39 -0
- package/dist/cjs/utils.cjs +320 -0
- package/dist/cjs/zalo.cjs +127 -0
- package/dist/context.d.ts +199 -0
- package/dist/context.js +27 -0
- package/dist/core/enums/common.d.ts +11 -0
- package/dist/core/enums/common.js +12 -0
- package/dist/core/interfaces/common.d.ts +7 -0
- package/dist/core/interfaces/common.js +1 -0
- package/dist/core/utils/deserializer.d.ts +4 -0
- package/dist/core/utils/deserializer.js +25 -0
- package/dist/core/utils/index.d.ts +2 -0
- package/dist/core/utils/index.js +28 -0
- package/dist/core/utils/serializer.d.ts +9 -0
- package/dist/core/utils/serializer.js +24 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +12 -0
- package/dist/models/AutoReply.d.ts +20 -0
- package/dist/models/AutoReply.js +7 -0
- package/dist/models/Board.d.ts +60 -0
- package/dist/models/Board.js +6 -0
- package/dist/models/Catalog.d.ts +16 -0
- package/dist/models/Catalog.js +1 -0
- package/dist/models/DeliveredMessage.d.ts +27 -0
- package/dist/models/DeliveredMessage.js +17 -0
- package/dist/models/Enum.d.ts +247 -0
- package/dist/models/Enum.js +251 -0
- package/dist/models/FriendEvent.d.ts +107 -0
- package/dist/models/FriendEvent.js +83 -0
- package/dist/models/Group.d.ts +125 -0
- package/dist/models/Group.js +11 -0
- package/dist/models/GroupEvent.d.ts +178 -0
- package/dist/models/GroupEvent.js +90 -0
- package/dist/models/Label.d.ts +10 -0
- package/dist/models/Label.js +1 -0
- package/dist/models/Listen.d.ts +186 -0
- package/dist/models/Listen.js +194 -0
- package/dist/models/Message.d.ts +97 -0
- package/dist/models/Message.js +34 -0
- package/dist/models/Mute.d.ts +10 -0
- package/dist/models/Mute.js +1 -0
- package/dist/models/ProductCatalog.d.ts +17 -0
- package/dist/models/ProductCatalog.js +1 -0
- package/dist/models/QuickMessage.d.ts +25 -0
- package/dist/models/QuickMessage.js +1 -0
- package/dist/models/Reaction.d.ts +85 -0
- package/dist/models/Reaction.js +70 -0
- package/dist/models/Reminder.d.ts +51 -0
- package/dist/models/Reminder.js +7 -0
- package/dist/models/SeenMessage.d.ts +26 -0
- package/dist/models/SeenMessage.js +17 -0
- package/dist/models/Typing.d.ts +24 -0
- package/dist/models/Typing.js +17 -0
- package/dist/models/Undo.d.ts +34 -0
- package/dist/models/Undo.js +12 -0
- package/dist/models/User.d.ts +49 -0
- package/dist/models/User.js +1 -0
- package/dist/models/ZBusiness.d.ts +22 -0
- package/dist/models/ZBusiness.js +35 -0
- package/dist/models/index.d.ts +19 -0
- package/dist/models/index.js +19 -0
- package/dist/socket/config-socket.d.ts +38 -0
- package/dist/socket/config-socket.js +202 -0
- package/dist/utils.d.ts +190 -0
- package/dist/utils.js +749 -0
- package/dist/zalo.d.ts +64 -0
- package/dist/zalo.js +103 -0
- package/package.json +61 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const updateQuickMessageFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/update`);
|
|
5
|
+
/**
|
|
6
|
+
* Update quick message
|
|
7
|
+
*
|
|
8
|
+
* @param updatePayload - The payload containing data to update the quick message
|
|
9
|
+
* @param itemId - The id of the quick message to update
|
|
10
|
+
*
|
|
11
|
+
* @note Zalo might throw an error with code 212 if the itemId does not exist.
|
|
12
|
+
*
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function updateQuickMessage(updatePayload, itemId) {
|
|
16
|
+
const isType = !updatePayload.media ? 0 : 1;
|
|
17
|
+
const params = {
|
|
18
|
+
itemId: itemId,
|
|
19
|
+
keyword: updatePayload.keyword,
|
|
20
|
+
message: {
|
|
21
|
+
title: updatePayload.title,
|
|
22
|
+
params: '',
|
|
23
|
+
},
|
|
24
|
+
type: isType,
|
|
25
|
+
};
|
|
26
|
+
if (isType === 1) {
|
|
27
|
+
if (!updatePayload.media)
|
|
28
|
+
throw new ZaloApiError('Media is required');
|
|
29
|
+
const uploadMedia = await api.uploadProductPhoto({
|
|
30
|
+
url: updatePayload.media,
|
|
31
|
+
});
|
|
32
|
+
const photoId = uploadMedia.photoId;
|
|
33
|
+
const thumbUrl = uploadMedia.thumbUrl;
|
|
34
|
+
const normalUrl = uploadMedia.normalUrl;
|
|
35
|
+
const hdUrl = uploadMedia.hdUrl;
|
|
36
|
+
params.media = {
|
|
37
|
+
items: [
|
|
38
|
+
{
|
|
39
|
+
type: 0,
|
|
40
|
+
photoId: photoId,
|
|
41
|
+
title: '',
|
|
42
|
+
width: '',
|
|
43
|
+
height: '',
|
|
44
|
+
previewThumb: thumbUrl,
|
|
45
|
+
rawUrl: normalUrl || hdUrl,
|
|
46
|
+
thumbUrl: thumbUrl,
|
|
47
|
+
normalUrl: normalUrl || hdUrl,
|
|
48
|
+
hdUrl: hdUrl || normalUrl,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
54
|
+
if (!encryptedParams)
|
|
55
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
56
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
});
|
|
59
|
+
return utils.resolve(response);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
@@ -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").ZaloAPI) => (type: UpdateSettingsType, value: number) => Promise<"">;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export var UpdateSettingsType;
|
|
4
|
+
(function (UpdateSettingsType) {
|
|
5
|
+
UpdateSettingsType["ViewBirthday"] = "view_birthday";
|
|
6
|
+
UpdateSettingsType["ShowOnlineStatus"] = "show_online_status";
|
|
7
|
+
UpdateSettingsType["DisplaySeenStatus"] = "display_seen_status";
|
|
8
|
+
UpdateSettingsType["ReceiveMessage"] = "receive_message";
|
|
9
|
+
UpdateSettingsType["AcceptCall"] = "accept_stranger_call";
|
|
10
|
+
UpdateSettingsType["AddFriendViaPhone"] = "add_friend_via_phone";
|
|
11
|
+
UpdateSettingsType["AddFriendViaQR"] = "add_friend_via_qr";
|
|
12
|
+
UpdateSettingsType["AddFriendViaGroup"] = "add_friend_via_group";
|
|
13
|
+
UpdateSettingsType["AddFriendViaContact"] = "add_friend_via_contact";
|
|
14
|
+
UpdateSettingsType["DisplayOnRecommendFriend"] = "display_on_recommend_friend";
|
|
15
|
+
UpdateSettingsType["ArchivedChat"] = "archivedChatStatus";
|
|
16
|
+
UpdateSettingsType["QuickMessage"] = "quickMessageStatus";
|
|
17
|
+
})(UpdateSettingsType || (UpdateSettingsType = {}));
|
|
18
|
+
export const updateSettingsFactory = apiFactory()((_api, _ctx, utils) => {
|
|
19
|
+
const serviceURL = utils.makeURL(`https://wpa.chat.zalo.me/api/setting/update`);
|
|
20
|
+
/**
|
|
21
|
+
* Set account settings
|
|
22
|
+
*
|
|
23
|
+
* @param type The type of setting to update
|
|
24
|
+
* @param value
|
|
25
|
+
*
|
|
26
|
+
* ViewBirthday
|
|
27
|
+
* * 0: hide
|
|
28
|
+
* * 1: show full day/month/year
|
|
29
|
+
* * 2: show day/month
|
|
30
|
+
*
|
|
31
|
+
* ShowOnlineStatus
|
|
32
|
+
* * 0: hide
|
|
33
|
+
* * 1: show
|
|
34
|
+
*
|
|
35
|
+
* DisplaySeenStatus
|
|
36
|
+
* * 0: hide
|
|
37
|
+
* * 1: show
|
|
38
|
+
*
|
|
39
|
+
* ReceiveMessage
|
|
40
|
+
* * 1: everyone
|
|
41
|
+
* * 2: only friends
|
|
42
|
+
*
|
|
43
|
+
* AcceptCall
|
|
44
|
+
* * 2: only friends
|
|
45
|
+
* * 3: everyone
|
|
46
|
+
* * 4: friends and person who contacted
|
|
47
|
+
*
|
|
48
|
+
* AddFriendViaPhone
|
|
49
|
+
* * 0: disable
|
|
50
|
+
* * 1: enable
|
|
51
|
+
*
|
|
52
|
+
* AddFriendViaQR
|
|
53
|
+
* * 0: disable
|
|
54
|
+
* * 1: enable
|
|
55
|
+
*
|
|
56
|
+
* AddFriendViaGroup
|
|
57
|
+
* * 0: disable
|
|
58
|
+
* * 1: enable
|
|
59
|
+
*
|
|
60
|
+
* AddFriendViaContact
|
|
61
|
+
* * 0: disable
|
|
62
|
+
* * 1: enable
|
|
63
|
+
*
|
|
64
|
+
* DisplayOnRecommendFriend
|
|
65
|
+
* * 0: disable
|
|
66
|
+
* * 1: enable
|
|
67
|
+
*
|
|
68
|
+
* ArchivedChat
|
|
69
|
+
* * 0: disable
|
|
70
|
+
* * 1: enable
|
|
71
|
+
*
|
|
72
|
+
* QuickMessage
|
|
73
|
+
* * 0: disable
|
|
74
|
+
* * 1: enable
|
|
75
|
+
*
|
|
76
|
+
* @throws {ZaloApiError}
|
|
77
|
+
*/
|
|
78
|
+
return async function updateSettings(type, value) {
|
|
79
|
+
const params = {
|
|
80
|
+
[type]: value,
|
|
81
|
+
};
|
|
82
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
83
|
+
if (!encryptedParams)
|
|
84
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
85
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
86
|
+
method: 'GET',
|
|
87
|
+
});
|
|
88
|
+
return utils.resolve(response);
|
|
89
|
+
};
|
|
90
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IFileUpload } from '../core/interfaces/common.js';
|
|
2
|
+
import { ThreadType } from '../models/index.js';
|
|
3
|
+
export type UploadAttachmentImageResponse = {
|
|
4
|
+
normalUrl: string;
|
|
5
|
+
photoId: string;
|
|
6
|
+
finished: number | boolean;
|
|
7
|
+
hdUrl: string;
|
|
8
|
+
thumbUrl: string;
|
|
9
|
+
clientFileId: number;
|
|
10
|
+
chunkId: number;
|
|
11
|
+
fileType: 'image';
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
totalSize: number;
|
|
15
|
+
hdSize: number;
|
|
16
|
+
};
|
|
17
|
+
export type UploadAttachmentVideoResponse = {
|
|
18
|
+
finished: number | boolean;
|
|
19
|
+
clientFileId: number;
|
|
20
|
+
chunkId: number;
|
|
21
|
+
fileType: 'video';
|
|
22
|
+
fileUrl: string;
|
|
23
|
+
fileId: string;
|
|
24
|
+
checksum: string;
|
|
25
|
+
totalSize: number;
|
|
26
|
+
fileName: string;
|
|
27
|
+
};
|
|
28
|
+
export type UploadAttachmentFileResponse = {
|
|
29
|
+
finished: number | boolean;
|
|
30
|
+
clientFileId: number;
|
|
31
|
+
chunkId: number;
|
|
32
|
+
fileType: 'others';
|
|
33
|
+
fileUrl: string;
|
|
34
|
+
fileId: string;
|
|
35
|
+
checksum: string;
|
|
36
|
+
totalSize: number;
|
|
37
|
+
fileName: string;
|
|
38
|
+
};
|
|
39
|
+
export type ImageData = {
|
|
40
|
+
fileName: string;
|
|
41
|
+
totalSize: number | undefined;
|
|
42
|
+
width: number | undefined;
|
|
43
|
+
height: number | undefined;
|
|
44
|
+
};
|
|
45
|
+
export type FileData = {
|
|
46
|
+
fileName: string;
|
|
47
|
+
totalSize: number;
|
|
48
|
+
};
|
|
49
|
+
export type UploadAttachmentType = UploadAttachmentImageResponse | UploadAttachmentVideoResponse | UploadAttachmentFileResponse;
|
|
50
|
+
export type UploadAttachmentResponse = UploadAttachmentType[];
|
|
51
|
+
export declare const uploadAttachmentFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (attachments: IFileUpload[], threadId: string, type?: ThreadType) => Promise<UploadAttachmentType[]>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import FormData from 'form-data';
|
|
2
|
+
import { CallbacksMap } from '../context.js';
|
|
3
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
4
|
+
import { ThreadType } from '../models/index.js';
|
|
5
|
+
import { apiFactory, getImageMetaData, getMd5LargeFileObject, resolveResponse } from '../utils.js';
|
|
6
|
+
const urlType = {
|
|
7
|
+
image: 'photo_original/upload',
|
|
8
|
+
video: 'asyncfile/upload',
|
|
9
|
+
others: 'asyncfile/upload',
|
|
10
|
+
};
|
|
11
|
+
export const uploadAttachmentFactory = apiFactory()((api, ctx, utils) => {
|
|
12
|
+
const serviceURL = `${api.zpwServiceMap.file[0]}/api`;
|
|
13
|
+
const { sharefile } = ctx.settings.features;
|
|
14
|
+
function isExceedMaxFile(totalFile) {
|
|
15
|
+
return totalFile > sharefile.max_file;
|
|
16
|
+
}
|
|
17
|
+
function isExceedMaxFileSize(fileSize) {
|
|
18
|
+
return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
|
|
19
|
+
}
|
|
20
|
+
function isExtensionValid(ext) {
|
|
21
|
+
return sharefile.restricted_ext_file.indexOf(ext) == -1;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Upload an attachment to a thread
|
|
25
|
+
*
|
|
26
|
+
* @param attachments List of attachments
|
|
27
|
+
* @param threadId Group or User ID
|
|
28
|
+
* @param type Message type (User or Group)
|
|
29
|
+
*
|
|
30
|
+
* @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
|
|
31
|
+
*/
|
|
32
|
+
return async function uploadAttachment(attachments, threadId, type = ThreadType.User) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!attachments || attachments.length == 0)
|
|
35
|
+
throw new ZaloApiError('Missing attachments');
|
|
36
|
+
if (isExceedMaxFile(attachments.length))
|
|
37
|
+
throw new ZaloApiError('Exceed maximum file of ' + sharefile.max_file);
|
|
38
|
+
if (!threadId)
|
|
39
|
+
throw new ZaloApiError('Missing threadId');
|
|
40
|
+
const chunkSize = ctx.settings.features.sharefile.chunk_size_file;
|
|
41
|
+
const isGroupMessage = type == ThreadType.Group;
|
|
42
|
+
const attachmentsData = [];
|
|
43
|
+
const url = `${serviceURL}/${isGroupMessage ? 'group' : 'message'}/`;
|
|
44
|
+
const typeParam = isGroupMessage ? '11' : '2';
|
|
45
|
+
let clientId = Date.now();
|
|
46
|
+
for (const attachment of attachments) {
|
|
47
|
+
const extFile = attachment.mimetype.split('/')[1];
|
|
48
|
+
const fileName = attachment.originalname;
|
|
49
|
+
if (isExtensionValid(extFile) == false)
|
|
50
|
+
throw new ZaloApiError(`File extension "${extFile}" is not allowed`);
|
|
51
|
+
const data = {
|
|
52
|
+
attachment: attachment,
|
|
53
|
+
chunkContent: [],
|
|
54
|
+
params: {},
|
|
55
|
+
};
|
|
56
|
+
if (isGroupMessage)
|
|
57
|
+
data.params.grid = threadId;
|
|
58
|
+
else
|
|
59
|
+
data.params.toid = threadId;
|
|
60
|
+
switch (extFile) {
|
|
61
|
+
case 'jpg':
|
|
62
|
+
case 'jpeg':
|
|
63
|
+
case 'png':
|
|
64
|
+
case 'webp': {
|
|
65
|
+
const imageData = await getImageMetaData(attachment);
|
|
66
|
+
if (isExceedMaxFileSize(imageData.totalSize))
|
|
67
|
+
throw new ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
68
|
+
data.fileData = imageData;
|
|
69
|
+
data.fileType = 'image';
|
|
70
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
71
|
+
data.params.fileName = fileName;
|
|
72
|
+
data.params.clientId = clientId++;
|
|
73
|
+
data.params.totalSize = imageData.totalSize;
|
|
74
|
+
data.params.imei = ctx.imei;
|
|
75
|
+
data.params.isE2EE = 0;
|
|
76
|
+
data.params.jxl = 0;
|
|
77
|
+
data.params.chunkId = 1;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case 'mp4': {
|
|
81
|
+
const videoSize = attachment.size;
|
|
82
|
+
if (isExceedMaxFileSize(videoSize))
|
|
83
|
+
throw new ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
84
|
+
data.fileType = 'video';
|
|
85
|
+
data.fileData = {
|
|
86
|
+
fileName,
|
|
87
|
+
totalSize: videoSize,
|
|
88
|
+
};
|
|
89
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
90
|
+
data.params.fileName = fileName;
|
|
91
|
+
data.params.clientId = clientId++;
|
|
92
|
+
data.params.totalSize = videoSize;
|
|
93
|
+
data.params.imei = ctx.imei;
|
|
94
|
+
data.params.isE2EE = 0;
|
|
95
|
+
data.params.jxl = 0;
|
|
96
|
+
data.params.chunkId = 1;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
default: {
|
|
100
|
+
const fileSize = attachment.size;
|
|
101
|
+
if (isExceedMaxFileSize(fileSize))
|
|
102
|
+
throw new ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
103
|
+
data.fileType = 'others';
|
|
104
|
+
data.fileData = {
|
|
105
|
+
fileName,
|
|
106
|
+
totalSize: fileSize,
|
|
107
|
+
};
|
|
108
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
109
|
+
data.params.fileName = fileName;
|
|
110
|
+
data.params.clientId = clientId++;
|
|
111
|
+
data.params.totalSize = fileSize;
|
|
112
|
+
data.params.imei = ctx.imei;
|
|
113
|
+
data.params.isE2EE = 0;
|
|
114
|
+
data.params.jxl = 0;
|
|
115
|
+
data.params.chunkId = 1;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const fileBuffer = attachment.buffer;
|
|
120
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
121
|
+
const formData = new FormData();
|
|
122
|
+
const slicedBuffer = fileBuffer.subarray(i * chunkSize, (i + 1) * chunkSize);
|
|
123
|
+
formData.append('chunkContent', slicedBuffer, {
|
|
124
|
+
filename: fileName,
|
|
125
|
+
contentType: 'application/octet-stream',
|
|
126
|
+
});
|
|
127
|
+
data.chunkContent[i] = formData;
|
|
128
|
+
}
|
|
129
|
+
attachmentsData.push(data);
|
|
130
|
+
}
|
|
131
|
+
const requests = [], results = [];
|
|
132
|
+
const callbackResolvers = new CallbacksMap();
|
|
133
|
+
(_a = api.onUploadCompleted) === null || _a === void 0 ? void 0 : _a.call(api, (dataEvent) => {
|
|
134
|
+
if (!dataEvent || !dataEvent.callbackId)
|
|
135
|
+
return;
|
|
136
|
+
const resolver = callbackResolvers.get(dataEvent.callbackId);
|
|
137
|
+
if (resolver) {
|
|
138
|
+
resolver(dataEvent.data);
|
|
139
|
+
callbackResolvers.delete(dataEvent.callbackId);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
for (const data of attachmentsData) {
|
|
143
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
144
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(data.params));
|
|
145
|
+
if (!encryptedParams)
|
|
146
|
+
throw new ZaloApiError('Failed to encrypt message');
|
|
147
|
+
requests.push(utils
|
|
148
|
+
.request(utils.makeURL(url + urlType[data.fileType], { type: typeParam, params: encryptedParams }), {
|
|
149
|
+
method: 'POST',
|
|
150
|
+
headers: data.chunkContent[i].getHeaders(),
|
|
151
|
+
body: data.chunkContent[i].getBuffer(),
|
|
152
|
+
})
|
|
153
|
+
.then(async (response) => {
|
|
154
|
+
/**
|
|
155
|
+
* @TODO: better type rather than any
|
|
156
|
+
*/
|
|
157
|
+
const resData = await resolveResponse(ctx, response);
|
|
158
|
+
if (resData && resData.fileId != '-1' && resData.photoId != '-1')
|
|
159
|
+
await new Promise((resolve) => {
|
|
160
|
+
if (data.fileType == 'video' || data.fileType == 'others') {
|
|
161
|
+
const callbackId = `${ctx.uid}_${resData.fileId}`;
|
|
162
|
+
const uploadCallback = async (wsData) => {
|
|
163
|
+
let result = Object.assign(Object.assign(Object.assign({ fileType: data.fileType }, resData), wsData), { totalSize: data.fileData.totalSize, fileName: data.fileData.fileName, checksum: (await getMd5LargeFileObject(data.attachment)).data });
|
|
164
|
+
results.push(result);
|
|
165
|
+
resolve();
|
|
166
|
+
};
|
|
167
|
+
callbackResolvers.set(callbackId, uploadCallback);
|
|
168
|
+
}
|
|
169
|
+
if (data.fileType == 'image') {
|
|
170
|
+
const result = {
|
|
171
|
+
fileType: 'image',
|
|
172
|
+
width: data.fileData.width,
|
|
173
|
+
height: data.fileData.height,
|
|
174
|
+
totalSize: data.fileData.totalSize,
|
|
175
|
+
hdSize: data.fileData.totalSize,
|
|
176
|
+
finished: resData.finished,
|
|
177
|
+
normalUrl: resData.normalUrl,
|
|
178
|
+
hdUrl: resData.hdUrl,
|
|
179
|
+
thumbUrl: resData.thumbUrl,
|
|
180
|
+
chunkId: resData.chunkId,
|
|
181
|
+
photoId: resData.photoId,
|
|
182
|
+
clientFileId: resData.clientFileId,
|
|
183
|
+
};
|
|
184
|
+
results.push(result);
|
|
185
|
+
resolve();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}));
|
|
189
|
+
data.params.chunkId++;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
await Promise.all(requests);
|
|
193
|
+
return results;
|
|
194
|
+
};
|
|
195
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type UploadProductPhotoPayload = {
|
|
2
|
+
url: string;
|
|
3
|
+
};
|
|
4
|
+
export type UploadProductPhotoResponse = {
|
|
5
|
+
normalUrl: string;
|
|
6
|
+
photoId: string;
|
|
7
|
+
finished: number;
|
|
8
|
+
hdUrl: string;
|
|
9
|
+
thumbUrl: string;
|
|
10
|
+
clientFileId: number;
|
|
11
|
+
chunkId: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const uploadProductPhotoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (payload: UploadProductPhotoPayload) => Promise<UploadProductPhotoResponse>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import FormData from 'form-data';
|
|
2
|
+
import { getFileUpload } from '../core/utils/index.js';
|
|
3
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
4
|
+
import { apiFactory, getImageMetaData } from '../utils.js';
|
|
5
|
+
export const uploadProductPhotoFactory = apiFactory()((api, ctx, utils) => {
|
|
6
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/product/upload/photo`);
|
|
7
|
+
/**
|
|
8
|
+
* Upload product photo for api quick message, product catalog or custom local storage
|
|
9
|
+
*
|
|
10
|
+
* @param payload file path or attachment source
|
|
11
|
+
*
|
|
12
|
+
* @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
|
|
13
|
+
*/
|
|
14
|
+
return async function uploadProductPhoto(payload) {
|
|
15
|
+
const file = await getFileUpload(payload.url);
|
|
16
|
+
const fileMetaData = await getImageMetaData(file);
|
|
17
|
+
const fileSize = fileMetaData.totalSize || 0;
|
|
18
|
+
const formData = new FormData();
|
|
19
|
+
formData.append('chunkContent', file.buffer, {
|
|
20
|
+
filename: 'undefined',
|
|
21
|
+
contentType: 'application/octet-stream',
|
|
22
|
+
});
|
|
23
|
+
const params = {
|
|
24
|
+
totalChunk: 1,
|
|
25
|
+
fileName: `Base64_Img_Picker_${Date.now()}.jpg`,
|
|
26
|
+
clientId: Date.now(),
|
|
27
|
+
totalSize: fileSize,
|
|
28
|
+
imei: ctx.imei,
|
|
29
|
+
chunkId: 1,
|
|
30
|
+
toid: ctx.loginInfo.send2me_id,
|
|
31
|
+
featureId: 1,
|
|
32
|
+
};
|
|
33
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
34
|
+
if (!encryptedParams)
|
|
35
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
36
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
37
|
+
params: encryptedParams,
|
|
38
|
+
}), {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: formData.getHeaders(),
|
|
41
|
+
body: formData.getBuffer(),
|
|
42
|
+
});
|
|
43
|
+
return utils.resolve(response);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
@@ -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").ZaloAPI) => (pollId: number, optionId: number | number[]) => Promise<VotePollResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
2
|
+
import { apiFactory } from '../utils.js';
|
|
3
|
+
export const votePollFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/poll/vote`);
|
|
5
|
+
/**
|
|
6
|
+
* Vote on a poll
|
|
7
|
+
*
|
|
8
|
+
* @param pollId The ID of the poll to vote on
|
|
9
|
+
* @param optionId The ID(s) of the option to vote on
|
|
10
|
+
*
|
|
11
|
+
* @throws ZaloApiError
|
|
12
|
+
*/
|
|
13
|
+
return async function votePoll(pollId, optionId) {
|
|
14
|
+
if (!Array.isArray(optionId))
|
|
15
|
+
optionId = [optionId];
|
|
16
|
+
const params = {
|
|
17
|
+
poll_id: pollId,
|
|
18
|
+
option_ids: optionId, // unvote = empty array
|
|
19
|
+
imei: ctx.imei,
|
|
20
|
+
};
|
|
21
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
22
|
+
if (!encryptedParams)
|
|
23
|
+
throw new ZaloApiError('Failed to encrypt params');
|
|
24
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
25
|
+
method: 'GET',
|
|
26
|
+
});
|
|
27
|
+
return utils.resolve(response);
|
|
28
|
+
};
|
|
29
|
+
});
|