export type ColorsDto = {red?: number | undefined, green?: number | undefined, blue?: number | undefined}; export type CabinetDto = {open?: ColorsDto | undefined, closed?: ColorsDto | undefined}; export type LedsDto = {upper?: CabinetDto | undefined, lower?: CabinetDto | undefined}; export type SaveCabinetLedsRequest = {leds?: LedsDto | undefined}; export type CreateApiV1ScaleLockerLocationIdLockerIdLedsArgs = {locationId: number, lockerId: string, Account: unknown, body: SaveCabinetLedsRequest}; export type CreateApiV1ScaleLockerLocationIdLockerIdLedsOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save seds configuration to cabinet * * POST /v1/ScaleLocker/{locationId}/{lockerId}/leds */ export const createApiV1ScaleLockerLocationIdLockerIdLeds = async (args: CreateApiV1ScaleLockerLocationIdLockerIdLedsArgs, options: CreateApiV1ScaleLockerLocationIdLockerIdLedsOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json; x-api-version=1.0") if (args.Account != null) query.append("Account", String(args.Account)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/ScaleLocker/${encodeURIComponent(String(args.locationId))}/${encodeURIComponent(String(args.lockerId))}/leds${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 };