diff --git a/src/api/get-limits.api.ts b/src/api/get-limits.api.ts new file mode 100644 index 0000000..061734f --- /dev/null +++ b/src/api/get-limits.api.ts @@ -0,0 +1,45 @@ +import { GenericRequest, InterceptedAPIHandler } from '../types/base.type'; + +export const getLimits = async ({ data, ws }: InterceptedAPIHandler) => { + const { req_id } = data as GenericRequest; + + const response = { + get_limits: { + daily_transfers: { + ctrader: { + allowed: '50000.00', + available: '49500.00', + minimum: '0.01', + }, + derivez: { + allowed: '10000.00', + available: '9900.00', + limit_type: 'amount', + minimum: '0.01', + }, + }, + unverified_transfers: { + crypto_to_crypto: { + allowed: '200.00', + available: '100:00', + }, + crypto_to_fiat: { + allowed: '500.00', + available: '500:00', + }, + fiat_to_crypto: { + allowed: '1000.00', + available: '950.00', + }, + }, + }, + echo_req: { + get_limits: '', + req_id, + }, + msg_type: 'authorize', + req_id, + }; + + ws.send(JSON.stringify(response)); +}; diff --git a/src/api/trading-platform-accounts/index.ts b/src/api/trading-platform-accounts/index.ts index 87052ba..f5d3e70 100644 --- a/src/api/trading-platform-accounts/index.ts +++ b/src/api/trading-platform-accounts/index.ts @@ -5,18 +5,16 @@ import tradingPlatformAccountsResponse from '../../response/trading-platform-acc export const tradingPlatformAccounts = async ({ data, ws }: InterceptedAPIHandler) => { const { trading_platform_accounts, platform, req_id } = data as TradingPlatformAccountsRequest; - if (platform === 'dxtrade') { - return ws.send( - JSON.stringify({ - echo_req: { - trading_platform_accounts, - platform, - req_id, - }, - msg_type: 'trading_platform_accounts', + return ws.send( + JSON.stringify({ + echo_req: { + trading_platform_accounts, + platform, req_id, - trading_platform_accounts: tradingPlatformAccountsResponse, - }) - ); - } + }, + msg_type: 'trading_platform_accounts', + req_id, + trading_platform_accounts: tradingPlatformAccountsResponse, + }) + ); }; diff --git a/src/api/transfer-between-accounts.ts b/src/api/transfer-between-accounts.ts new file mode 100644 index 0000000..8c15389 --- /dev/null +++ b/src/api/transfer-between-accounts.ts @@ -0,0 +1,32 @@ +import { GenericRequest, InterceptedAPIHandler } from '../types/base.type'; + +export const transferBetweenAccounts = async ({ data, ws }: InterceptedAPIHandler) => { + const { req_id } = data as GenericRequest; + + const response = { + accounts: [ + { + account_type: 'wallet', + balance: '10422.12', + currency: 'USD', + demo_account: 0, + loginid: 'CRW1122', + }, + { + account_type: 'trading', + balance: '100', + currency: 'USD', + demo_account: 0, + loginid: 'CR1122', + }, + ], + echo_req: { + transfer_between_accounts: '0', + req_id, + }, + msg_type: 'transfer_between_accounts', + req_id, + }; + + ws.send(JSON.stringify(response)); +}; diff --git a/src/interceptor/mock.interceptor.ts b/src/interceptor/mock.interceptor.ts index e818cad..3e3ce07 100644 --- a/src/interceptor/mock.interceptor.ts +++ b/src/interceptor/mock.interceptor.ts @@ -16,6 +16,8 @@ import { payoutCurrencies } from '../api/payout-currencies.api'; import { getAccountTypes } from '../api/get-account-types'; import { tradingPlatformAccounts } from '../api/trading-platform-accounts'; import { topupVirtual } from '../api/topup-virtual.api'; +import { getLimits } from '../api/get-limits.api'; +import { transferBetweenAccounts } from '../api/transfer-between-accounts'; export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) => { const endpoint_type = getFirstMatchingKey( @@ -50,9 +52,14 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) = return await payoutCurrencies(intercepted_args); case 'topup_virtual': return await topupVirtual(intercepted_args); + case 'get_limits': + return await getLimits(intercepted_args); + case 'transfer_between_accounts': + return await transferBetweenAccounts(intercepted_args); + case 'trading_platform_accounts': + return await tradingPlatformAccounts(intercepted_args); case 'account_security': case 'portfolio': - case 'get_limits': case 'proposal_open_contract': case 'new_account_real': case 'new_account_virtual': @@ -62,8 +69,6 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) = case 'transfer_between_accounts': case 'p2p_order_list': case 'get_financial_assessment': - case 'trading_platform_accounts': - return await tradingPlatformAccounts(intercepted_args); default: return await proxyInterceptor(intercepted_args); } diff --git a/src/mock-store/transfer/session.json b/src/mock-store/transfer/session.json new file mode 100644 index 0000000..84a8ffe --- /dev/null +++ b/src/mock-store/transfer/session.json @@ -0,0 +1,46 @@ +{ + "session_id": "transfer", + "accounts": [ + { + "account_category": "wallet", + "account_type": "doughflow", + "created_at": 1664784824, + "currency": "USD", + "balance": 10422.12, + "is_disabled": 0, + "is_virtual": 0, + "landing_company_name": "SVG", + "landing_company_shortcode": "SVG", + "loginid": "CRW1122", + "linked_to": [{"loginid": "CR1122", "platform": "dtrader" }], + "trading": {}, + "email": "example@test.com", + "excluded_until": "", + "session_start": 1687144472, + "accepted_bch": 0, + "platform": "deriv" + }, + { + "account_category": "trading", + "account_type": "dtrader", + "created_at": 1664784824, + "currency": "USD", + "balance": 100, + "is_disabled": 0, + "is_virtual": 1, + "landing_company_name": "SVG", + "landing_company_shortcode": "SVG", + "loginid": "CR1122", + "linked_to": [{"loginid": "CRW1122", "platform": "wallet" }], + "trading": {}, + "email": "example@test.com", + "excluded_until": "", + "session_start": 1687144472, + "accepted_bch": 0, + "platform": "deriv" + } + ], + "wallet_migration_config": { + "status": "migrated" + } +} diff --git a/src/schema/account.schema.ts b/src/schema/account.schema.ts index a970924..f5bc440 100644 --- a/src/schema/account.schema.ts +++ b/src/schema/account.schema.ts @@ -13,8 +13,6 @@ export type LinkedAccount = z.infer; export const linked_account_schema = z.object({ loginid: z.string(), - account_category: z.enum(['trading', 'wallet']), - account_type: z.string(), platform: z.nativeEnum(Platform), }); @@ -29,7 +27,7 @@ export const account_schema = z is_virtual: z.number(), landing_company_name: z.string().regex(/(bvi|labuan|malta|maltainvest|svg|vanuatu)/), loginid: z.string().regex(/^(MX|MXW|MF|MFW|VRTC|VRW|MLT|MLTW|CR|CRW|FOG)[0-9]+$/), - linked_account: linked_account_schema, + linked_to: linked_account_schema, trading: z.any().optional(), token: z.string().optional(), // Full Account Details