-
Notifications
You must be signed in to change notification settings - Fork 271
feat(api): add new apis #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JustKemForFun
wants to merge
17
commits into
RFS-ADRENO:main
Choose a base branch
from
JustKemForFun:dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+697
−242
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9bcb3da
feat: add bank account and supported banks APIs
JustKemForFun 9f91696
refactor: streamline type exports in index.ts and enhance bank accoun…
JustKemForFun ae85f18
refactor: improve type imports and update sendBankCardFactory
JustKemForFun f0995ba
feat: add createBankAccount API and related types
JustKemForFun 47e529c
feat: update Bank model with new bank codes and improve documentation
JustKemForFun 5ec26a9
fix: enhance normalizeHolderName function for improved validation
JustKemForFun c9445e6
feat: add new bank-related APIs and update type exports
JustKemForFun fd7a82a
feat: add delete and update bank account APIs with corresponding types
JustKemForFun ff78bcf
feat: add getListDevice API and corresponding types
JustKemForFun 3182c43
feat: add lostFocus API and corresponding types
JustKemForFun 86dde86
feat: add registerCatalog API and corresponding types
JustKemForFun d925e90
feat: add scanURL API and corresponding types
JustKemForFun c1bac16
feat: update User model and API response types
JustKemForFun 98c8ae2
feat: update API version and enhance type definitions
JustKemForFun 6635bfa
fix(apis): correct & revert unnecessary changes
RFS-ADRENO a80bb47
fix(createCatalog): restore to original
RFS-ADRENO 1c3e979
fix(createCatalog): revert format
RFS-ADRENO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<CreateBankAccountResponse>()((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); | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<DeleteBankAccountResponse>()((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); | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<GetListBankResponse>()((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); | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<GetListBankCardResponse>()((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); | ||
| }; | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.