export type UserWeightCreate = {user_weight?: ({weight?: number | undefined, recorded_on?: string | undefined}) | undefined}; export type CreateApiV1UsersUserIdUserWeightsArgs = {user_id: number, body: UserWeightCreate}; export type CreateApiV1UsersUserIdUserWeightsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create user weight entry * * POST /v1/users/{user_id}/user_weights */ export const createApiV1UsersUserIdUserWeights = async (args: CreateApiV1UsersUserIdUserWeightsArgs, options?: CreateApiV1UsersUserIdUserWeightsOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/users/${encodeURIComponent(String(args.user_id))}/user_weights${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 };