export type CreateApiV3AdministrationsAdministrationIdPeriodClosuresArgs = {administration_id: string, 'fields[period_closure]'?: string | undefined, 'Accept-Language'?: string | undefined, body: {data?: ({type?: string | undefined, attributes?: ({closed_upto?: string | undefined}) | undefined, meta?: ({temp_id?: string | undefined}) | undefined}) | undefined}}; export type CreateApiV3AdministrationsAdministrationIdPeriodClosuresOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST close accounting period * * POST /v3/administrations/{administration_id}/period_closures * * Also accepts auth: OAuth2 */ export const createApiV3AdministrationsAdministrationIdPeriodClosures = async (args: CreateApiV3AdministrationsAdministrationIdPeriodClosuresArgs, options?: CreateApiV3AdministrationsAdministrationIdPeriodClosuresOptions) => { const {baseUrl = "https://api.bookingexperts.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") if (args['fields[period_closure]'] != null) query.append("fields[period_closure]", String(args['fields[period_closure]'])) if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v3/administrations/${encodeURIComponent(String(args.administration_id))}/period_closures${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 };