export type UpdateSubAccountUserTokenRequest = {scopeNames?: Array | undefined, ipsWhitelist?: Array | undefined, expiresAt?: string | undefined}; export type PatchApiApiV1SubAccountsEtoroTradingUserTokensUserTokenIdArgs = {'x-request-id': string, 'x-api-key': string, 'x-user-key': string, userTokenId: string, 'x-sub-account-id': string, body: UpdateSubAccountUserTokenRequest}; export type PatchApiApiV1SubAccountsEtoroTradingUserTokensUserTokenIdOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Sub-Account User Token * * PATCH /api/v1/sub-accounts/etoro-trading/user-tokens/{userTokenId} */ export const patchApiApiV1SubAccountsEtoroTradingUserTokensUserTokenId = async (args: PatchApiApiV1SubAccountsEtoroTradingUserTokensUserTokenIdArgs, options?: PatchApiApiV1SubAccountsEtoroTradingUserTokensUserTokenIdOptions) => { const {baseUrl = "https://public-api.etoro.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-request-id'] != null) headers.set("x-request-id", String(args['x-request-id'])) if (args['x-api-key'] != null) headers.set("x-api-key", String(args['x-api-key'])) if (args['x-user-key'] != null) headers.set("x-user-key", String(args['x-user-key'])) if (args['x-sub-account-id'] != null) headers.set("x-sub-account-id", String(args['x-sub-account-id'])) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/sub-accounts/etoro-trading/user-tokens/${encodeURIComponent(String(args.userTokenId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };