export type CreateApiV2UserAccountsServerAccountIdTrackingLatencyArgs = {server: 'oanda' | 'oanda-demo' | 'otms' | 'v20' | 'v20-demo' | 'oj' | 'oj-demo' | 'opt' | 'ftmo-1', accountId: string, body: {clientRoundTripDuration: number, clientStartTime: number, clientReceivedTime: number, platform: string, requestedPrice: number, orderId: string, tradingAccountType?: ('OGM' | 'V20' | 'CRYPTO' | 'OTMS' | 'OEL' | 'OJ') | undefined, event: 'SubmittedOrder' | 'ModifyOrder' | 'CancelOrder' | 'ClosePosition' | 'CloseNetPosition' | 'ReducePosition' | 'ReduceNetPosition' | 'PushToFavourites' | 'RemoveFromFavourites' | 'SaveChartLayout' | 'CreateChartLayout' | 'CloseOrder' | 'ReduceOrder', userId: string, oandaAgent: string, engineAfterPreflightDuration: number, apiVersion: string, transactionId: string, size?: number | undefined, instrument: string, vwap: string, type?: ('MARKET' | 'STOP' | 'LIMIT') | undefined}}; export type CreateApiV2UserAccountsServerAccountIdTrackingLatencyOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v2/user/accounts/{server}/{accountId}/tracking/latency */ export const createApiV2UserAccountsServerAccountIdTrackingLatency = async (args: CreateApiV2UserAccountsServerAccountIdTrackingLatencyArgs, options: CreateApiV2UserAccountsServerAccountIdTrackingLatencyOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/accounts/${encodeURIComponent(String(args.server))}/${encodeURIComponent(String(args.accountId))}/tracking/latency${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };