export type CreateApiV1GameplaysIdClaimRewardArgs = {id: string, 'x-idempotency-key': string}; export type CreateApiV1GameplaysIdClaimRewardOptions = {baseUrl: string, accessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v1/gameplays/{id}/claim_reward */ export const createApiV1GameplaysIdClaimReward = async (args: CreateApiV1GameplaysIdClaimRewardArgs, options: CreateApiV1GameplaysIdClaimRewardOptions) => { const {baseUrl, fetch: fetchFn = fetch, accessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['x-idempotency-key'] != null) headers.set("x-idempotency-key", String(args['x-idempotency-key'])) if (accessToken !== undefined) headers.set('authorization', `Bearer ${accessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/gameplays/${encodeURIComponent(String(args.id))}/claim_reward${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };