diff --git a/src/api/new_account_wallet.api.ts b/src/api/new_account_wallet.api.ts new file mode 100644 index 0000000..1333dab --- /dev/null +++ b/src/api/new_account_wallet.api.ts @@ -0,0 +1,69 @@ +import { InterceptedAPIHandler } from '../types/base.type'; +import { NewAccountWalletRequest } from '../types/new_account_wallet.type'; + +export const newAccountWallet = ({ data, ws, session }: InterceptedAPIHandler) => { + const { + new_account_wallet, + req_id, + account_type, + currency, + address_city, + address_line_1, + address_line_2, + address_postcode, + date_of_birth, + first_name, + last_name, + phone, + non_pep_declaration, + } = data as NewAccountWalletRequest; + + const response = { + echo_req: { + new_account_wallet, + req_id, + account_type, + currency, + address_city, + address_line_1, + address_line_2, + address_postcode, + date_of_birth, + first_name, + last_name, + phone, + non_pep_declaration, + }, + msg_type: 'new_account_wallet', + new_account_wallet: { + client_id: 'CRW123129', + currency, + landing_company: 'Deriv (SVG) LLC', + landing_company_short: 'svg', + landing_company_shortcode: 'svg', + oauth_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + }, + req_id, + }; + // add the new account wallet to the session + session.accounts = [ + ...session.accounts, + { + account_category: 'wallet', + account_type, + created_at: 1664784824, + currency, + balance: Math.floor(Math.random() * 100), + is_disabled: 0, + is_virtual: 0, + landing_company_name: 'svg', + landing_company_shortcode: 'svg', + loginid: `CRW${Math.floor(Math.random() * 100000)}`, + trading: {}, + email: 'example@test.com', + platform: 'deriv', + excluded_until: 0, + }, + ]; + return ws.send(JSON.stringify(response)); +}; diff --git a/src/interceptor/mock.interceptor.ts b/src/interceptor/mock.interceptor.ts index e818cad..1b4d80d 100644 --- a/src/interceptor/mock.interceptor.ts +++ b/src/interceptor/mock.interceptor.ts @@ -16,6 +16,7 @@ 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 { newAccountWallet } from '../api/new_account_wallet.api'; export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) => { const endpoint_type = getFirstMatchingKey( @@ -50,18 +51,21 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) = return await payoutCurrencies(intercepted_args); case 'topup_virtual': return await topupVirtual(intercepted_args); + case 'new_account_wallet': + return await newAccountWallet(intercepted_args); case 'account_security': case 'portfolio': case 'get_limits': case 'proposal_open_contract': case 'new_account_real': case 'new_account_virtual': - case 'new_account_wallet': + case 'get_self_exclusion': case 'get_available_accounts_to_transfer': case 'transfer_between_accounts': case 'p2p_order_list': case 'get_financial_assessment': + return; case 'trading_platform_accounts': return await tradingPlatformAccounts(intercepted_args); default: diff --git a/src/mock-store/default/session.json b/src/mock-store/default/session.json index 7912986..2e604d1 100644 --- a/src/mock-store/default/session.json +++ b/src/mock-store/default/session.json @@ -26,7 +26,7 @@ "currency": "USD", "balance": 40.12, "is_disabled": 0, - "is_virtual": 0, + "is_virtual": 1, "landing_company_name": "virtual", "landing_company_shortcode": "virtual", "loginid": "VRW142069", @@ -37,6 +37,42 @@ "accepted_bch": 0, "platform": "deriv" }, + { + "account_category": "wallet", + "account_type": "doughflow", + "created_at": 1664784824, + "currency": "USD", + "balance": 790.12, + "is_disabled": 0, + "is_virtual": 0, + "landing_company_name": "svg", + "landing_company_shortcode": "svg", + "loginid": "CRW142069", + "trading": {}, + "email": "example@test.com", + "excluded_until": "", + "session_start": 1687144472, + "accepted_bch": 0, + "platform": "deriv" + }, + { + "account_category": "wallet", + "account_type": "crypto", + "created_at": 1664784824, + "currency": "LTC", + "balance": 71190.12, + "is_disabled": 0, + "is_virtual": 0, + "landing_company_name": "svg", + "landing_company_shortcode": "svg", + "loginid": "CRW142069", + "trading": {}, + "email": "example@test.com", + "excluded_until": "", + "session_start": 1687144472, + "accepted_bch": 0, + "platform": "deriv" + }, { "account_category": "trading", "account_type": "standard", diff --git a/src/types/new_account_wallet.type.ts b/src/types/new_account_wallet.type.ts new file mode 100644 index 0000000..d620749 --- /dev/null +++ b/src/types/new_account_wallet.type.ts @@ -0,0 +1,16 @@ +import { GenericRequest } from './base.type'; + +export interface NewAccountWalletRequest extends GenericRequest { + new_account_wallet: 1; + address_city?: string; + address_line_1?: string; + address_line_2?: string; + address_postcode?: string; + date_of_birth?: string; + first_name?: string; + last_name?: string; + phone?: string; + non_pep_declaration?: string; + account_type: 'doughflow' | 'crypto'; + currency: string; +}