export type Trainer = {trainer_id?: string | undefined, trainer_name?: string | undefined, unit_price?: number | undefined, business_start_at?: string | undefined, business_end_at?: string | undefined, public_mail_addr?: string | undefined, public_tel?: string | undefined, store_name?: string | undefined, gym_name?: string | undefined, star_count?: number | undefined}; export type CreateApiTrainerArgs = {body: Trainer}; export type CreateApiTrainerOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * API021 トレーナー登録 * * POST /trainer */ export const createApiTrainer = async (args: CreateApiTrainerArgs, options: CreateApiTrainerOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/trainer${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 };