export type LeaderboardMemberUpdate = {member_id?: string | undefined, member_data?: string | undefined, image_url?: string | undefined, score?: number | undefined}; export type CreateApiV1LeaderboardsLeaderboardIdSubmitScoreArgs = {leaderboard_id: string, body: LeaderboardMemberUpdate}; export type CreateApiV1LeaderboardsLeaderboardIdSubmitScoreOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit Score * * POST /v1/leaderboards/{leaderboard_id}/submit_score */ export const createApiV1LeaderboardsLeaderboardIdSubmitScore = async (args: CreateApiV1LeaderboardsLeaderboardIdSubmitScoreArgs, options?: CreateApiV1LeaderboardsLeaderboardIdSubmitScoreOptions) => { const {baseUrl = "https://api.aghanim.com/s2s", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/leaderboards/${encodeURIComponent(String(args.leaderboard_id))}/submit_score${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 };