export type UpdateApiApiV1WatchlistsRankWatchlistIdArgs = {'x-request-id': string, 'x-api-key': string, 'x-user-key': string, watchlistId: string, newRank: number}; export type UpdateApiApiV1WatchlistsRankWatchlistIdOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change watchlist rank * * PUT /api/v1/watchlists/rank/{watchlistId} * * Also accepts auth: oauth2, oauth2 */ export const updateApiApiV1WatchlistsRankWatchlistId = async (args: UpdateApiApiV1WatchlistsRankWatchlistIdArgs, options?: UpdateApiApiV1WatchlistsRankWatchlistIdOptions) => { const {baseUrl = "https://public-api.etoro.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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.newRank != null) query.append("newRank", String(args.newRank)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/watchlists/rank/${encodeURIComponent(String(args.watchlistId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };