export type GetApiV1Oauth2WalletArgs = {usertoken?: string | undefined, apikey: string}; export type GetApiV1Oauth2WalletOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Wallet Data * * GET /v1/oauth2/wallet */ export const getApiV1Oauth2Wallet = async (args: GetApiV1Oauth2WalletArgs, options: GetApiV1Oauth2WalletOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.usertoken != null) headers.set("usertoken", String(args.usertoken)) if (args.apikey != null) headers.set("apikey", String(args.apikey)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/oauth2/wallet${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };