export type CreateApiV2FriendsAddArgs = {body: {xuids?: string | undefined, xuid?: string | undefined}}; export type CreateApiV2FriendsAddOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add friend(s) * * POST /v2/friends/add */ export const createApiV2FriendsAdd = async (args: CreateApiV2FriendsAddArgs, options?: CreateApiV2FriendsAddOptions) => { const {baseUrl = "https://api.xbl.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/friends/add${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 };