diff --git a/src/apis.ts b/src/apis.ts index a3c914af..96890591 100644 --- a/src/apis.ts +++ b/src/apis.ts @@ -16,6 +16,7 @@ import { changeGroupAvatarFactory } from "./apis/changeGroupAvatar.js"; import { changeGroupNameFactory } from "./apis/changeGroupName.js"; import { changeGroupOwnerFactory } from "./apis/changeGroupOwner.js"; import { createAutoReplyFactory } from "./apis/createAutoReply.js"; +import { createBankAccountFactory } from "./apis/createBankAccount.js"; import { createCatalogFactory } from "./apis/createCatalog.js"; import { createGroupFactory } from "./apis/createGroup.js"; import { createNoteFactory } from "./apis/createNote.js"; @@ -24,6 +25,7 @@ import { createProductCatalogFactory } from "./apis/createProductCatalog.js"; import { createReminderFactory } from "./apis/createReminder.js"; import { deleteAutoReplyFactory } from "./apis/deleteAutoReply.js"; import { deleteAvatarFactory } from "./apis/deleteAvatar.js"; +import { deleteBankAccountFactory } from "./apis/deleteBankAccount.js"; import { deleteCatalogFactory } from "./apis/deleteCatalog.js"; import { deleteChatFactory } from "./apis/deleteChat.js"; import { deleteGroupInviteBoxFactory } from "./apis/deleteGroupInviteBox.js"; @@ -66,7 +68,10 @@ import { getGroupLinkInfoFactory } from "./apis/getGroupLinkInfo.js"; import { getGroupMembersInfoFactory } from "./apis/getGroupMembersInfo.js"; import { getHiddenConversationsFactory } from "./apis/getHiddenConversations.js"; import { getLabelsFactory } from "./apis/getLabels.js"; +import { getListBankFactory } from "./apis/getListBank.js"; +import { getListBankCardFactory } from "./apis/getListBankCard.js"; import { getListBoardFactory } from "./apis/getListBoard.js"; +import { getListDeviceFactory } from "./apis/getListDevice.js"; import { getListReminderFactory } from "./apis/getListReminder.js"; import { getMultiUsersByPhonesFactory } from "./apis/getMultiUsersByPhones.js"; import { getMuteFactory } from "./apis/getMute.js"; @@ -94,7 +99,9 @@ import { keepAliveFactory } from "./apis/keepAlive.js"; import { lastOnlineFactory } from "./apis/lastOnline.js"; import { leaveGroupFactory } from "./apis/leaveGroup.js"; import { lockPollFactory } from "./apis/lockPoll.js"; +import { lostFocusFactory } from "./apis/lostFocus.js"; import { parseLinkFactory } from "./apis/parseLink.js"; +import { registerCatalogFactory } from "./apis/registerCatalog.js"; import { rejectFriendRequestFactory } from "./apis/rejectFriendRequest.js"; import { removeFriendFactory } from "./apis/removeFriend.js"; import { removeFriendAliasFactory } from "./apis/removeFriendAlias.js"; @@ -107,6 +114,7 @@ import { removeUserFromGroupFactory } from "./apis/removeUserFromGroup.js"; import { resetHiddenConversPinFactory } from "./apis/resetHiddenConversPin.js"; import { reuseAvatarFactory } from "./apis/reuseAvatar.js"; import { reviewPendingMemberRequestFactory } from "./apis/reviewPendingMemberRequest.js"; +import { scanURLFactory } from "./apis/scanURL.js"; import { searchStickerFactory } from "./apis/searchSticker.js"; import { sendBankCardFactory } from "./apis/sendBankCard.js"; import { sendCardFactory } from "./apis/sendCard.js"; @@ -131,6 +139,7 @@ import { updateActiveStatusFactory } from "./apis/updateActiveStatus.js"; import { updateArchivedChatListFactory } from "./apis/updateArchivedChatList.js"; import { updateAutoDeleteChatFactory } from "./apis/updateAutoDeleteChat.js"; import { updateAutoReplyFactory } from "./apis/updateAutoReply.js"; +import { updateBankAccountFactory } from "./apis/updateBankAccount.js"; import { updateCatalogFactory } from "./apis/updateCatalog.js"; import { updateGroupSettingsFactory } from "./apis/updateGroupSettings.js"; import { updateHiddenConversPinFactory } from "./apis/updateHiddenConversPin.js"; @@ -168,6 +177,7 @@ export class API { public changeGroupName: ReturnType; public changeGroupOwner: ReturnType; public createAutoReply: ReturnType; + public createBankAccount: ReturnType; public createCatalog: ReturnType; public createGroup: ReturnType; public createNote: ReturnType; @@ -176,6 +186,7 @@ export class API { public createReminder: ReturnType; public deleteAutoReply: ReturnType; public deleteAvatar: ReturnType; + public deleteBankAccount: ReturnType; public deleteCatalog: ReturnType; public deleteChat: ReturnType; public deleteGroupInviteBox: ReturnType; @@ -218,7 +229,10 @@ export class API { public getGroupMembersInfo: ReturnType; public getHiddenConversations: ReturnType; public getLabels: ReturnType; + public getListBank: ReturnType; + public getListBankCard: ReturnType; public getListBoard: ReturnType; + public getListDevice: ReturnType; public getListReminder: ReturnType; public getMultiUsersByPhones: ReturnType; public getMute: ReturnType; @@ -246,7 +260,9 @@ export class API { public lastOnline: ReturnType; public leaveGroup: ReturnType; public lockPoll: ReturnType; + public lostFocus: ReturnType; public parseLink: ReturnType; + public registerCatalog: ReturnType; public rejectFriendRequest: ReturnType; public removeFriend: ReturnType; public removeFriendAlias: ReturnType; @@ -259,6 +275,7 @@ export class API { public resetHiddenConversPin: ReturnType; public reuseAvatar: ReturnType; public reviewPendingMemberRequest: ReturnType; + public scanURL: ReturnType; public searchSticker: ReturnType; public sendBankCard: ReturnType; public sendCard: ReturnType; @@ -283,6 +300,7 @@ export class API { public updateArchivedChatList: ReturnType; public updateAutoDeleteChat: ReturnType; public updateAutoReply: ReturnType; + public updateBankAccount: ReturnType; public updateCatalog: ReturnType; public updateGroupSettings: ReturnType; public updateHiddenConversPin: ReturnType; @@ -320,6 +338,7 @@ export class API { this.changeGroupName = changeGroupNameFactory(ctx, this); this.changeGroupOwner = changeGroupOwnerFactory(ctx, this); this.createAutoReply = createAutoReplyFactory(ctx, this); + this.createBankAccount = createBankAccountFactory(ctx, this); this.createCatalog = createCatalogFactory(ctx, this); this.createGroup = createGroupFactory(ctx, this); this.createNote = createNoteFactory(ctx, this); @@ -328,6 +347,7 @@ export class API { this.createReminder = createReminderFactory(ctx, this); this.deleteAutoReply = deleteAutoReplyFactory(ctx, this); this.deleteAvatar = deleteAvatarFactory(ctx, this); + this.deleteBankAccount = deleteBankAccountFactory(ctx, this); this.deleteCatalog = deleteCatalogFactory(ctx, this); this.deleteChat = deleteChatFactory(ctx, this); this.deleteGroupInviteBox = deleteGroupInviteBoxFactory(ctx, this); @@ -370,7 +390,10 @@ export class API { this.getGroupMembersInfo = getGroupMembersInfoFactory(ctx, this); this.getHiddenConversations = getHiddenConversationsFactory(ctx, this); this.getLabels = getLabelsFactory(ctx, this); + this.getListBank = getListBankFactory(ctx, this); + this.getListBankCard = getListBankCardFactory(ctx, this); this.getListBoard = getListBoardFactory(ctx, this); + this.getListDevice = getListDeviceFactory(ctx, this); this.getListReminder = getListReminderFactory(ctx, this); this.getMultiUsersByPhones = getMultiUsersByPhonesFactory(ctx, this); this.getMute = getMuteFactory(ctx, this); @@ -398,7 +421,9 @@ export class API { this.lastOnline = lastOnlineFactory(ctx, this); this.leaveGroup = leaveGroupFactory(ctx, this); this.lockPoll = lockPollFactory(ctx, this); + this.lostFocus = lostFocusFactory(ctx, this); this.parseLink = parseLinkFactory(ctx, this); + this.registerCatalog = registerCatalogFactory(ctx, this); this.rejectFriendRequest = rejectFriendRequestFactory(ctx, this); this.removeFriend = removeFriendFactory(ctx, this); this.removeFriendAlias = removeFriendAliasFactory(ctx, this); @@ -411,6 +436,7 @@ export class API { this.resetHiddenConversPin = resetHiddenConversPinFactory(ctx, this); this.reuseAvatar = reuseAvatarFactory(ctx, this); this.reviewPendingMemberRequest = reviewPendingMemberRequestFactory(ctx, this); + this.scanURL = scanURLFactory(ctx, this); this.searchSticker = searchStickerFactory(ctx, this); this.sendBankCard = sendBankCardFactory(ctx, this); this.sendCard = sendCardFactory(ctx, this); @@ -435,6 +461,7 @@ export class API { this.updateArchivedChatList = updateArchivedChatListFactory(ctx, this); this.updateAutoDeleteChat = updateAutoDeleteChatFactory(ctx, this); this.updateAutoReply = updateAutoReplyFactory(ctx, this); + this.updateBankAccount = updateBankAccountFactory(ctx, this); this.updateCatalog = updateCatalogFactory(ctx, this); this.updateGroupSettings = updateGroupSettingsFactory(ctx, this); this.updateHiddenConversPin = updateHiddenConversPinFactory(ctx, this); diff --git a/src/apis/createBankAccount.ts b/src/apis/createBankAccount.ts new file mode 100644 index 00000000..21dc3525 --- /dev/null +++ b/src/apis/createBankAccount.ts @@ -0,0 +1,43 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import type { BankAccount, BinBankCard } from "../models/index.js"; +import { apiFactory, normalizeHolderName } from "../utils.js"; + +export type CreateBankAccountPayload = { + binBank: BinBankCard; + numAccBank: string; + nameAccBank: string; +}; + +export type CreateBankAccountResponse = BankAccount; + +export const createBankAccountFactory = apiFactory()((api, ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/create`); + + /** + * Create bank account + * + * @param payload The payload containing the bank account information + * + * @throws {ZaloApiError} + */ + return async function createBankAccount(payload: CreateBankAccountPayload) { + const params = { + bin: payload.binBank, + bank_number: payload.numAccBank, + holder_name: normalizeHolderName(payload.nameAccBank), + language: ctx.language, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/deleteBankAccount.ts b/src/apis/deleteBankAccount.ts new file mode 100644 index 00000000..84e43aa9 --- /dev/null +++ b/src/apis/deleteBankAccount.ts @@ -0,0 +1,49 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import type { BankAccount } from "../models/index.js"; +import { apiFactory } from "../utils.js"; + +export type DeleteBankAccountPayload = { + accountId: number; + isDefault: boolean; +}; + +/** + * I'm really confused that the list of accounts that are not mine is returned by this `api.deleteBankAccount()` T.T + * @TODO check again later + */ +export type DeleteBankAccountResponse = { + hasMore: boolean; + total: number; + myBanks: BankAccount[]; +}; + +export const deleteBankAccountFactory = apiFactory()((api, ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/delete`); + + /** + * Delete bank account + * + * @param payload The payload containing the bank account information to delete + * + * @throws {ZaloApiError} + */ + return async function deleteBankAccount(payload: DeleteBankAccountPayload) { + const params = { + account_id: payload.accountId, + is_default: payload.isDefault, + language: ctx.language, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/getGroupLinkInfo.ts b/src/apis/getGroupLinkInfo.ts index 367eceeb..8b95de52 100644 --- a/src/apis/getGroupLinkInfo.ts +++ b/src/apis/getGroupLinkInfo.ts @@ -1,5 +1,5 @@ import { ZaloApiError } from "../Errors/ZaloApiError.js"; -import type { GroupSetting } from "../models/index.js"; +import type { GroupSetting, GroupType } from "../models/index.js"; import { apiFactory } from "../utils.js"; export type GetGroupLinkInfoPayload = { @@ -14,7 +14,7 @@ export type GetGroupLinkInfoResponse = { groupId: string; name: string; desc: string; - type: number; + type: GroupType; creatorId: string; avt: string; fullAvt: string; diff --git a/src/apis/getListBank.ts b/src/apis/getListBank.ts new file mode 100644 index 00000000..e1b11f4d --- /dev/null +++ b/src/apis/getListBank.ts @@ -0,0 +1,29 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import type { BankInfo } from "../models/index.js"; +import { apiFactory } from "../utils.js"; + +export type GetListBankResponse = { + banks: BankInfo[]; +}; + +export const getListBankFactory = apiFactory()((api, _ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/conf`); + + /** + * Get list bank + * + * @throws {ZaloApiError} + */ + return async function getListBank() { + const params = {}; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), { + method: "GET", + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/getListBankCard.ts b/src/apis/getListBankCard.ts new file mode 100644 index 00000000..1c0f3a35 --- /dev/null +++ b/src/apis/getListBankCard.ts @@ -0,0 +1,37 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import type { BankAccount } from "../models/index.js"; +import { apiFactory } from "../utils.js"; + +export type GetListBankCardResponse = { + hasMore: boolean; + total: number; + myBanks: BankAccount[]; +}; + +export const getListBankCardFactory = apiFactory()((api, _ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/list`); + + /** + * Get list bank card + * + * @param page Page number (default: 0) + * @param limit Number of items to retrieve (default: 20) + * + * @throws {ZaloApiError} + */ + return async function getListBankCard(page: number = 0, limit: number = 20) { + const params = { + page: page, + limit: limit, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), { + method: "GET", + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/getListDevice.ts b/src/apis/getListDevice.ts new file mode 100644 index 00000000..f9a6830b --- /dev/null +++ b/src/apis/getListDevice.ts @@ -0,0 +1,36 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import { apiFactory } from "../utils.js"; + +export type GetListDeviceResponse = { + devices: { + masterId: string; + encIdentity: string; + lastUpdateTs: number; + encSignature: string; + companions: string[] | unknown[]; // @TODO check type later + }; +}; + +export const getListDeviceFactory = apiFactory()((api, ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.aext[0]}/api/devices/linked`); + + /** + * Get list device + * + * @throws {ZaloApiError} + */ + return async function getListDevice() { + const params = { + imei: ctx.imei, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), { + method: "GET", + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/getUserInfo.ts b/src/apis/getUserInfo.ts index d160836e..d94df799 100644 --- a/src/apis/getUserInfo.ts +++ b/src/apis/getUserInfo.ts @@ -1,12 +1,12 @@ import { ZaloApiError } from "../Errors/ZaloApiError.js"; import { apiFactory } from "../utils.js"; -import { AvatarSize, type User } from "../models/index.js"; +import { AvatarSize, type UnchangedProfileInfo, type User } from "../models/index.js"; export type ProfileInfo = User; export type UserInfoResponse = { - unchanged_profiles: Record; + unchanged_profiles: Record>; phonebook_version: number; changed_profiles: Record; }; diff --git a/src/apis/lostFocus.ts b/src/apis/lostFocus.ts new file mode 100644 index 00000000..558c397f --- /dev/null +++ b/src/apis/lostFocus.ts @@ -0,0 +1,31 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import { apiFactory } from "../utils.js"; + +export type LostFocusResponse = { + status: boolean; +}; + +export const lostFocusFactory = apiFactory()((api, _ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/changefgtobg`); + + /** + * Lost focus + * + * @throws {ZaloApiError} + */ + return async function lostFocus() { + const params = {}; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/registerCatalog.ts b/src/apis/registerCatalog.ts new file mode 100644 index 00000000..c5b862d5 --- /dev/null +++ b/src/apis/registerCatalog.ts @@ -0,0 +1,35 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import { apiFactory } from "../utils.js"; + +export type RegisterCatalogResponse = { + status: boolean; +}; + +export const registerCatalogFactory = apiFactory()((api, _ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.catalog[0]}/api/prodcatalog/catalog/register`); + + /** + * Register catalog + * + * @param enable enable or disable catalog + * + * @throws {ZaloApiError} + */ + return async function registerCatalog(enable: boolean) { + const params = { + enable: enable ? 1 : 0, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/scanURL.ts b/src/apis/scanURL.ts new file mode 100644 index 00000000..75d9ce5f --- /dev/null +++ b/src/apis/scanURL.ts @@ -0,0 +1,36 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import { apiFactory } from "../utils.js"; + +export type ScanURLResponse = { + isSafe: boolean; +}; + +export const scanURLFactory = apiFactory()((api, _ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/scanurl`); + + /** + * Scan URL + * + * @param url URL to scan check if it is safe (https) + * + * @throws {ZaloApiError} + */ + return async function scanURL(url: string) { + + const params = { + url: url, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/apis/sendBankCard.ts b/src/apis/sendBankCard.ts index 810c4222..e10d146d 100644 --- a/src/apis/sendBankCard.ts +++ b/src/apis/sendBankCard.ts @@ -11,7 +11,7 @@ export type SendBankCardPayload = { export type SendBankCardResponse = ""; -export const sendBankCardFactory = apiFactory()((api, ctx, utils) => { +export const sendBankCardFactory = apiFactory()((api, _, utils) => { const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/card`); /** diff --git a/src/apis/updateBankAccount.ts b/src/apis/updateBankAccount.ts new file mode 100644 index 00000000..82d1a192 --- /dev/null +++ b/src/apis/updateBankAccount.ts @@ -0,0 +1,45 @@ +import { ZaloApiError } from "../Errors/ZaloApiError.js"; +import type { BankAccount, BinBankCard } from "../models/index.js"; +import { apiFactory, normalizeHolderName } from "../utils.js"; + +export type UpdateBankAccountPayload = { + accountId: number; + binBank: BinBankCard; + numAccBank: string; + nameAccBank: string; +}; + +export type UpdateBankAccountResponse = BankAccount; + +export const updateBankAccountFactory = apiFactory()((api, ctx, utils) => { + const serviceURL = utils.makeURL(`${api.zpwServiceMap.zimsg[0]}/api/transfer/update`); + + /** + * Update bank account + * + * @param payload The payload containing the bank account information to update + * + * @throws {ZaloApiError} + */ + return async function updateBankAccount(payload: UpdateBankAccountPayload) { + const params = { + account_id: payload.accountId, + bin: payload.binBank, + bank_number: payload.numAccBank, + holder_name: normalizeHolderName(payload.nameAccBank), + language: ctx.language, + }; + + const encryptedParams = utils.encodeAES(JSON.stringify(params)); + if (!encryptedParams) throw new ZaloApiError("Failed to encrypt params"); + + const response = await utils.request(serviceURL, { + method: "POST", + body: new URLSearchParams({ + params: encryptedParams, + }), + }); + + return utils.resolve(response); + }; +}); diff --git a/src/context.ts b/src/context.ts index 21f2b20d..adfff166 100644 --- a/src/context.ts +++ b/src/context.ts @@ -193,7 +193,7 @@ export type AppContextExtended = { export type ContextBase = Partial & AppContextExtended; -export const createContext = (apiType = 30, apiVersion = 671) => +export const createContext = (apiType = 30, apiVersion = 685) => ({ API_TYPE: apiType, API_VERSION: apiVersion, diff --git a/src/index.ts b/src/index.ts index ce84709c..7753bc42 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ export * from "./Errors/index.js"; export * from "./models/index.js"; export * from "./zalo.js"; -export type { ContextSession, ContextBase, AppContextExtended, AppContextBase, Options, ZPWServiceMap, ImageMetadataGetter,ImageMetadataGetterResponse } from "./context.js"; +export type { ContextSession, ContextBase, AppContextExtended, AppContextBase, Options, ZPWServiceMap, ImageMetadataGetter, ImageMetadataGetterResponse } from "./context.js"; // API TYPES export type { AcceptFriendRequestResponse } from "./apis/acceptFriendRequest.js"; @@ -21,6 +21,7 @@ export type { ChangeGroupAvatarResponse } from "./apis/changeGroupAvatar.js"; export type { ChangeGroupNameResponse } from "./apis/changeGroupName.js"; export type { ChangeGroupOwnerResponse } from "./apis/changeGroupOwner.js"; export type { CreateAutoReplyPayload, CreateAutoReplyResponse } from "./apis/createAutoReply.js"; +export type { CreateBankAccountPayload, CreateBankAccountResponse } from "./apis/createBankAccount.js"; export type { CreateCatalogResponse } from "./apis/createCatalog.js"; export type { CreateGroupOptions, CreateGroupResponse } from "./apis/createGroup.js"; export type { CreateNoteOptions, CreateNoteResponse } from "./apis/createNote.js"; @@ -29,6 +30,7 @@ export type { CreateProductCatalogPayload, CreateProductCatalogResponse } from " export type { CreateReminderOptions, CreateReminderResponse, CreateReminderUser, CreateReminderGroup } from "./apis/createReminder.js"; export type { DeleteAutoReplyResponse } from "./apis/deleteAutoReply.js"; export type { DeleteAvatarResponse } from "./apis/deleteAvatar.js"; +export type { DeleteBankAccountPayload, DeleteBankAccountResponse } from "./apis/deleteBankAccount.js"; export type { DeleteCatalogResponse } from "./apis/deleteCatalog.js"; export type { DeleteChatLastMessage, DeleteChatResponse } from "./apis/deleteChat.js"; export type { DeleteGroupInviteBoxResponse } from "./apis/deleteGroupInviteBox.js"; @@ -69,7 +71,10 @@ export type { GetGroupLinkInfoPayload, GetGroupLinkInfoResponse } from "./apis/g export type { GetGroupMembersInfoResponse, GroupMemberProfile } from "./apis/getGroupMembersInfo.js"; export type { GetHiddenConversationsResponse } from "./apis/getHiddenConversations.js"; export type { GetLabelsResponse } from "./apis/getLabels.js"; +export type { GetListBankResponse } from "./apis/getListBank.js"; +export type { GetListBankCardResponse } from "./apis/getListBankCard.js"; export type { BoardItem, GetListBoardResponse, ListBoardOptions } from "./apis/getListBoard.js"; +export type { GetListDeviceResponse } from "./apis/getListDevice.js"; export type { GetListReminderResponse, ListReminderOptions, ReminderListGroup, ReminderListUser } from "./apis/getListReminder.js"; export type { GetMultiUsersByPhonesResponse } from "./apis/getMultiUsersByPhones.js"; export type { GetMuteResponse, MuteEntriesInfo } from "./apis/getMute.js"; @@ -96,7 +101,9 @@ export type { LastOnlineResponse } from "./apis/lastOnline.js"; export type { LeaveGroupResponse } from "./apis/leaveGroup.js"; export type { LockPollResponse } from "./apis/lockPoll.js"; export type { LoginQRCallback, LoginQRCallbackEvent } from "./apis/loginQR.js"; +export type { LostFocusResponse } from "./apis/lostFocus.js"; export type { ParseLinkErrorMaps, ParseLinkResponse } from "./apis/parseLink.js"; +export type { RegisterCatalogResponse } from "./apis/registerCatalog.js"; export type { RejectFriendRequestResponse } from "./apis/rejectFriendRequest.js"; export type { RemoveFriendResponse } from "./apis/removeFriend.js"; export type { RemoveFriendAliasResponse } from "./apis/removeFriendAlias.js"; @@ -109,6 +116,7 @@ export type { RemoveUserFromGroupResponse } from "./apis/removeUserFromGroup.js" export type { ResetHiddenConversPinResponse } from "./apis/resetHiddenConversPin.js"; export type { ReuseAvatarResponse } from "./apis/reuseAvatar.js"; export type { ReviewPendingMemberRequestPayload, ReviewPendingMemberRequestResponse } from "./apis/reviewPendingMemberRequest.js"; +export type { ScanURLResponse } from "./apis/scanURL.js"; export type { SearchStickerResponse } from "./apis/searchSticker.js"; export type { SendBankCardPayload, SendBankCardResponse } from "./apis/sendBankCard.js"; export type { SendCardOptions, SendCardResponse } from "./apis/sendCard.js"; @@ -133,6 +141,7 @@ export type { UpdateActiveStatusResponse } from "./apis/updateActiveStatus.js"; export type { UpdateArchivedChatListTarget, UpdateArchivedChatListResponse } from "./apis/updateArchivedChatList.js"; export type { UpdateAutoDeleteChatResponse } from "./apis/updateAutoDeleteChat.js"; export type { UpdateAutoReplyPayload, UpdateAutoReplyResponse } from "./apis/updateAutoReply.js"; +export type { UpdateBankAccountPayload, UpdateBankAccountResponse } from "./apis/updateBankAccount.js"; export type { UpdateCatalogPayload, UpdateCatalogResponse } from "./apis/updateCatalog.js"; export type { UpdateGroupSettingsOptions, UpdateGroupSettingsResponse } from "./apis/updateGroupSettings.js"; export type { UpdateHiddenConversPinResponse } from "./apis/updateHiddenConversPin.js"; diff --git a/src/models/Bank.ts b/src/models/Bank.ts new file mode 100644 index 00000000..9ec7481a --- /dev/null +++ b/src/models/Bank.ts @@ -0,0 +1,286 @@ +export type BankInfo = { + bin: number; + logo: string; + name: string; + name_eng: string; + short_name: string; + search_key_word: string; +}; + +export type BankAccount = { + /** + * The fields marked with `?` may or may not be present for the getBankAccounts and createBankAccount APIs. + */ + id: string; + bin: number; + default: boolean; + bank_number: string; + bank_logo?: string; + holder_name: string; + created_at: number; + updated_at: number; + account_id: number; + bank_name?: string; + is_default: boolean; +}; + +/** + * @note Bank codes list after Mitm on Mobile, WEB and Bank's supported by Zalo + * @documents https://developers.zalo.me/docs/zalo-notification-service/phu-luc/danh-sach-bin-code - docs missing bin code and short_name bank + */ +export enum BinBankCard { + /** + * NH TMCP An Bình + */ + ABBank = 970425, + /** + * NH TMCP Á Châu + */ + ACB = 970416, + /** + * NH Nông nghiệp và Phát triển Nông thôn Việt Nam + */ + Agribank = 970405, + /** + * NH TMCP Đầu tư và Phát triển Việt Nam + */ + BIDV = 970418, + /** + * Ngân hàng BNP Paribas - CN TP. Hồ Chí Minh + */ + BNP_Paribas_HCM = 963666, + /** + * Ngân hàng BNP Paribas - CN Hà Nội + */ + BNP_Paribas_HN = 963668, + /** + * NH TMCP Bản Việt + */ + BVBank = 970454, + /** + * NH TMCP Bắc Á + */ + BacA_Bank = 970409, + /** + * NH TMCP Bảo Việt + */ + BaoViet_Bank = 970438, + /** + * NH số CAKE by VPBank - TMCP Việt Nam Thịnh Vượng + */ + CAKE = 546034, + /** + * Ngân hàng Cathay United - CN TP. Hồ Chí Minh + */ + Cathay_United_HCM = 168999, + /** + * NH Thương mại TNHH MTV Xây dựng Việt Nam + * + * @note Also observed as "VCBNeo" in supported banks list (same bin) - Old is bank: CB_Bank + */ + VCBNeo = 970444, + /** + * NH TNHH MTV CIMB Việt Nam + */ + CIMB_Bank = 422589, + /** + * NH Hợp tác xã Việt Nam + */ + Coop_Bank = 970446, + /** + * NH TNHH MTV Phát triển Singapore - CN TP. Hồ Chí Minh + */ + DBS_Bank = 796500, + /** + * NH TMCP Đông Á + */ + DongA_Bank = 970406, + /** + * NH TMCP Xuất Nhập khẩu Việt Nam + */ + Eximbank = 970431, + /** + * Ngân hàng Citibank Việt Nam + */ + Citibank = 533948, + /** + * NH TMCP Dầu khí Toàn cầu + */ + GPBank = 970408, + /** + * NH TMCP Phát triển TP. Hồ Chí Minh + */ + HDBank = 970437, + /** + * NH TNHH MTV HSBC (Việt Nam) + */ + HSBC = 458761, + /** + * NH TNHH MTV Hong Leong Việt Nam + */ + HongLeong_Bank = 970442, + /** + * NH Công nghiệp Hàn Quốc - CN TP. Hồ Chí Minh + */ + IBK_HCM = 970456, + /** + * NH Công nghiệp Hàn Quốc - CN Hà Nội + */ + IBK_HN = 970455, + /** + * NH TNHH Indovina + */ + Indovina_Bank = 970434, + /** + * NH Đại chúng TNHH Kasikornbank - CN TP. Hồ Chí Minh + */ + KBank = 668888, + /** + * NH TMCP Kiên Long + */ + KienlongBank = 970452, + /** + * NH Kookmin - CN TP. Hồ Chí Minh + */ + Kookmin_Bank_HCM = 970463, + /** + * NH Kookmin - CN Hà Nội + */ + Kookmin_Bank_HN = 970462, + /** + * Liobank by OCB + */ + Liobank = 963369, + /** + * NH TMCP Lộc Phát Việt Nam + */ + LPBank = 970449, + /** + * NH TMCP Quân đội + */ + MB_Bank = 970422, + /** + * NH TMCP Hàng Hải + */ + MSB = 970426, + /** + * MoMo + */ + MoMo = 971025, + /** + * NH TMCP Quốc Dân + */ + NCB = 970419, + /** + * NH TMCP Nam Á + */ + Nam_A_Bank = 970428, + /** + * NH Nonghyup - CN Hà Nội + */ + NongHyup_Bank = 801011, + /** + * NH TMCP Phương Đông + */ + OCB = 970448, + /** + * NH Thương mại TNHH MTV Đại Dương + */ + Ocean_Bank = 970414, + /** + * NH TMCP Thịnh vượng và Phát triển + */ + PGBank = 970430, + /** + * NH TMCP Đại Chúng Việt Nam + */ + PVcomBank = 970412, + /** + * NH TNHH MTV Public Việt Nam + */ + Public_Bank_Vietnam = 970439, + /** + * NH TMCP Sài Gòn + */ + SCB = 970429, + /** + * NH TMCP Sài Gòn - Hà Nội + */ + SHB = 970443, + /** + * NH TMCP Sài Gòn Thương Tín + */ + Sacombank = 970403, + /** + * NH TMCP Sài Gòn Công Thương + */ + Saigon_Bank = 970400, + /** + * NH TMCP Đông Nam Á + */ + SeABank = 970440, + /** + * NH TNHH MTV Shinhan Việt Nam + */ + Shinhan_Bank = 970424, + /** + * NH TNHH MTV Standard Chartered Bank Việt Nam + */ + Standard_Chartered_Vietnam = 970410, + /** + * NH số TNEX + */ + TNEX = 963326, + /** + * NH TMCP Tiên Phong + */ + TPBank = 970423, + /** + * NH TMCP Kỹ thương Việt Nam + */ + Techcombank = 970407, + /** + * NH số Timo by Bản Việt Bank + */ + Timo = 963388, + /** + * NH số UBank by VPBank + */ + UBank = 546035, + /** + * NH United Overseas Bank Việt Nam + */ + United_Overseas_Bank_Vietnam = 970458, + /** + * NH TMCP Quốc tế Việt Nam + */ + VIB = 970441, + /** + * NH TMCP Việt Nam Thịnh Vượng + */ + VPBank = 970432, + /** + * NH Liên doanh Việt - Nga + */ + VRB = 970421, + /** + * NH TMCP Việt Á + */ + VietABank = 970427, + /** + * NH TMCP Việt Nam Thương Tín + */ + VietBank = 970433, + /** + * NH TMCP Ngoại Thương Việt Nam + */ + Vietcombank = 970436, + /** + * NH TMCP Công thương Việt Nam + */ + VietinBank = 970415, + /** + * NH TNHH MTV Woori Việt Nam + */ + Woori_Bank = 970457, +}; diff --git a/src/models/Enum.ts b/src/models/Enum.ts index 2f6cdbff..9ce5cf04 100644 --- a/src/models/Enum.ts +++ b/src/models/Enum.ts @@ -16,240 +16,7 @@ export enum Gender { export enum AvatarSize { Small = 120, + Medium = 180, Large = 240, -} - -/** - * @note Bank codes list after Mitm on Mobile and Bank's supported by Zalo - * @documents https://developers.zalo.me/docs/zalo-notification-service/phu-luc/danh-sach-bin-code - docs missing bin code and short_name bank - */ -export enum BinBankCard { - /** - * NH TMCP An Bình - */ - ABBank = 970425, - /** - * NH TMCP Á Châu - */ - ACB = 970416, - /** - * NH Nông nghiệp và Phát triển Nông thôn Việt Nam - */ - Agribank = 970405, - /** - * NH TMCP Đầu tư và Phát triển Việt Nam - */ - BIDV = 970418, - /** - * NH TMCP Bản Việt - */ - BVBank = 970454, - /** - * NH TMCP Bắc Á - */ - BacA_Bank = 970409, - /** - * NH TMCP Bảo Việt - */ - BaoViet_Bank = 970438, - /** - * NH số CAKE by VPBank - TMCP Việt Nam Thịnh Vượng - */ - CAKE = 546034, - /** - * NH Thương mại TNHH MTV Xây dựng Việt Nam - */ - CB_Bank = 970444, - /** - * NH TNHH MTV CIMB Việt Nam - */ - CIMB_Bank = 422589, - /** - * NH Hợp tác xã Việt Nam - */ - Coop_Bank = 970446, - /** - * NH TNHH MTV Phát triển Singapore - CN TP. Hồ Chí Minh - */ - DBS_Bank = 796500, - /** - * NH TMCP Đông Á - */ - DongA_Bank = 970406, - /** - * NH TMCP Xuất Nhập khẩu Việt Nam - */ - Eximbank = 970431, - /** - * NH TMCP Dầu khí Toàn cầu - */ - GPBank = 970408, - /** - * NH TMCP Phát triển TP. Hồ Chí Minh - */ - HDBank = 970437, - /** - * NH TNHH MTV HSBC (Việt Nam) - */ - HSBC = 458761, - /** - * NH TNHH MTV Hong Leong Việt Nam - */ - HongLeong_Bank = 970442, - /** - * NH Công nghiệp Hàn Quốc - CN TP. Hồ Chí Minh - */ - IBK_HCM = 970456, - /** - * NH Công nghiệp Hàn Quốc - CN Hà Nội - */ - IBK_HN = 970455, - /** - * NH TNHH Indovina - */ - Indovina_Bank = 970434, - /** - * NH Đại chúng TNHH Kasikornbank - CN TP. Hồ Chí Minh - */ - KBank = 668888, - /** - * NH TMCP Kiên Long - */ - KienlongBank = 970452, - /** - * NH Kookmin - CN TP. Hồ Chí Minh - */ - Kookmin_Bank_HCM = 970463, - /** - * NH Kookmin - CN Hà Nội - */ - Kookmin_Bank_HN = 970462, - /** - * NH TMCP Lộc Phát Việt Nam - */ - LPBank = 970449, - /** - * NH TMCP Quân đội - */ - MB_Bank = 970422, - /** - * NH TMCP Hàng Hải - */ - MSB = 970426, - /** - * NH TMCP Quốc Dân - */ - NCB = 970419, - /** - * NH TMCP Nam Á - */ - Nam_A_Bank = 970428, - /** - * NH Nonghyup - CN Hà Nội - */ - NongHyup_Bank = 801011, - /** - * NH TMCP Phương Đông - */ - OCB = 970448, - /** - * NH Thương mại TNHH MTV Đại Dương - */ - Ocean_Bank = 970414, - /** - * NH TMCP Thịnh vượng và Phát triển - */ - PGBank = 970430, - /** - * NH TMCP Đại Chúng Việt Nam - */ - PVcomBank = 970412, - /** - * NH TNHH MTV Public Việt Nam - */ - Public_Bank_Vietnam = 970439, - /** - * NH TMCP Sài Gòn - */ - SCB = 970429, - /** - * NH TMCP Sài Gòn - Hà Nội - */ - SHB = 970443, - /** - * NH TMCP Sài Gòn Thương Tín - */ - Sacombank = 970403, - /** - * NH TMCP Sài Gòn Công Thương - */ - Saigon_Bank = 970400, - /** - * NH TMCP Đông Nam Á - */ - SeABank = 970440, - /** - * NH TNHH MTV Shinhan Việt Nam - */ - Shinhan_Bank = 970424, - /** - * NH TNHH MTV Standard Chartered Bank Việt Nam - */ - Standard_Chartered_Vietnam = 970410, - /** - * NH số TNEX - */ - TNEX = 9704261, - /** - * NH TMCP Tiên Phong - */ - TPBank = 970423, - /** - * NH TMCP Kỹ thương Việt Nam - */ - Techcombank = 970407, - /** - * NH số Timo by Bản Việt Bank - */ - Timo = 963388, - /** - * NH số UBank by VPBank - */ - UBank = 546035, - /** - * NH United Overseas Bank Việt Nam - */ - United_Overseas_Bank_Vietnam = 970458, - /** - * NH TMCP Quốc tế Việt Nam - */ - VIB = 970441, - /** - * NH TMCP Việt Nam Thịnh Vượng - */ - VPBank = 970432, - /** - * NH Liên doanh Việt - Nga - */ - VRB = 970421, - /** - * NH TMCP Việt Á - */ - VietABank = 970427, - /** - * NH TMCP Việt Nam Thương Tín - */ - VietBank = 970433, - /** - * NH TMCP Ngoại Thương Việt Nam - */ - Vietcombank = 970436, - /** - * NH TMCP Công thương Việt Nam - */ - VietinBank = 970415, - /** - * NH TNHH MTV Woori Việt Nam - */ - Woori_Bank = 970457, + ExtraLarge = 360, } diff --git a/src/models/User.ts b/src/models/User.ts index 03f52f15..3588fc1f 100644 --- a/src/models/User.ts +++ b/src/models/User.ts @@ -63,3 +63,12 @@ export type UserSetting = { view_birthday: number; setting_2FA_status: number; }; + +export type UnchangedProfileInfo = { + oa_status: { + blocked: number; + }; + isFr: number; + isBlocked: boolean; + lastActionTime: number; +}; diff --git a/src/models/index.ts b/src/models/index.ts index 46f087d4..ae081288 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,5 +1,6 @@ export * from "./Attachment.js"; export * from "./AutoReply.js"; +export * from "./Bank.js"; export * from "./Board.js"; export * from "./Catalog.js"; export * from "./DeliveredMessage.js"; diff --git a/src/utils.ts b/src/utils.ts index 6fcbeb7c..8aea7dae 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -789,3 +789,18 @@ export function negativeColorToHex(negativeColor: number): string { // return "#" + positiveColor.toString(16).padStart(6, "0"); // rgb no alpha return "#" + positiveColor.toString(16).slice(-6).padStart(6, "0"); // rgb with alpha } + +export function normalizeHolderName(input?: string) { + if (!input) return undefined; + const normalized = input + .normalize("NFD") + .replace(/[\u0300-\u036f]/g, "") + .replace(/đ/g, "d") + .replace(/Đ/g, "D") + .toUpperCase() + .replace(/[^A-Z0-9 ]+/g, " ") + .replace(/\s+/g, " ") + .trim(); + + return normalized.length >= 5 ? normalized : undefined; +}