import {z} from 'zod' export type CreateApiV1VehiclesVehicleIdCommandExecutionActuateFrontTrunkArgs = {vehicle_id: string}; export type CreateApiV1VehiclesVehicleIdCommandExecutionActuateFrontTrunkOptions = {baseUrl?: string | undefined, OAuth2ClientCredentialsBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const oEMDeviceCommandExecutionStatus = z.enum(["PENDING", "EXECUTED", "FAILED"]); export const vehicleCommandEnum = z.enum(["WAKE_UP", "UNLOCK_DOORS", "LOCK_DOORS", "HONK_HORN", "FLASH_LIGHTS", "START_HVAC_SYSTEM", "CLIMATE_ON", "CLIMATE_OFF", "SET_TEMPERATURE", "SET_CHARGE_LIMIT", "ACTUATE_FRONT_TRUNK", "ACTUATE_REAR_TRUNK", "OPEN_CHARGE_PORT", "CLOSE_CHARGE_PORT", "START_CHARGING", "STOP_CHARGING", "SET_VEHICLE_NAME", "SCHEDULE_SOFTWARE_UPDATE", "CANCEL_SOFTWARE_UPDATE", "WINDOW_HEATING_ON", "WINDOW_HEATING_OFF"]); export const vehicleCommandExecution = z.object({id: z.string().nullable().optional(), commandArguments: z.record(z.string(), z.unknown()).nullable().optional(), timeout: z.number().int().nullable().optional(), executedAt: z.string().nullable().optional(), status: oEMDeviceCommandExecutionStatus.nullable().optional(), failedReason: z.enum(["OEM_UNKNOWN_ERROR", "OEM_TIMEOUT", "OEM_UNAVAILABLE", "OEM_NETWORK_ERROR", "OEM_INCORRECT_REGION", "OEM_APP_REQUIRED_UPDATE", "OEM_USER_ACCOUNT_LOCKED", "OEM_OAUTH_TOKEN_EXPIRED", "OEM_VEHICLE_OFFLINE", "OEM_VEHICLE_REMOTE_ACCESS_DISABLED", "OEM_VEHICLE_LOCATION_SHARING_DISABLED", "OEM_AUTH_DRIVER_IS_NOT_PRIMARY_USER", "OEM_DEVICE_NOT_FOUND", "OEM_COMMAND_TIMEOUT", "OEM_COMMAND_FAILED", "OEM_COMMAND_SUCCEEDED_WITH_DOOR_AJAR", "OEM_RATE_LIMITED", "OEM_ACCOUNT_RATE_LIMITED", "OEM_DEVICE_RATE_LIMITED", "OEM_STOP_CHARGE_RATE_LIMITED", "OEM_COMMANDS_RATE_LIMITED", "OEM_VEHICLE_LOCATION_UNKNOWN", "OEM_VEHICLE_NOT_IN_AUTHORIZED_LOCATION", "OEM_VEHICLE_CHARGING_NOT_FINISHED", "OEM_VEHICLE_CHARGING_NOT_STOPPED", "OEM_VEHICLE_CHARGING_NOT_STARTED", "OEM_VEHICLE_CHARGING_NOT_PAUSED", "OEM_VEHICLE_CHARGING_REFUSED_PLAY_PROTECTION", "OEM_COMMAND_REFUSED_OTHER_SERVICE_RUNNING", "OEM_COMMAND_REFUSED_VEHICLE_AWAKE_IN_STAND_STILL_AND_RESTING_STATE", "OEM_COMMAND_REFUSED_VEHICLE_AWAKE_IN_STAND_STILL_AND_ACTIVE_STATE", "OEM_COMMAND_REFUSED_VEHICLE_AWAKE_IN_DRIVING_OR_READY_TO_DRIVE", "OEM_COMMAND_REFUSED_VEHICLE_AWAKE_IN_DIAGNOSTICS_MODE", "SERVER_ERROR", "INTERNAL_RATE_LIMITED", "AUTHENTICATION_ERROR", "NOT_PERMITTED"]).nullable().optional(), vehicleId: z.string(), command: vehicleCommandEnum}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Action Actuate Front Trunk * * POST /v1/vehicles/{vehicle_id}/command-execution:actuate-front-trunk */ export const createApiV1VehiclesVehicleIdCommandExecutionActuateFrontTrunk = async (args: CreateApiV1VehiclesVehicleIdCommandExecutionActuateFrontTrunkArgs, options?: CreateApiV1VehiclesVehicleIdCommandExecutionActuateFrontTrunkOptions) => { const {baseUrl = "https://api.volteras.com", fetch: fetchFn = fetch, OAuth2ClientCredentialsBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (OAuth2ClientCredentialsBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2ClientCredentialsBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/vehicles/${encodeURIComponent(String(args.vehicle_id))}/command-execution:actuate-front-trunk${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 validateResponse(vehicleCommandExecution, await res.json()) };