from datetime import datetime import enum from uuid import UUID from pydantic import BaseModel class TransactionStatus(enum.Enum): ONGOING = "ongoing" ENDED = "ended" class TransactionEventTriggerReason(enum.Enum): AUTHORIZED = "Authorized" CABLE_PLUGGED_IN = "CablePluggedIn" CHARGING_RATE_CHANGED = "ChargingRateChanged" CHARGING_STATE_CHANGED = "ChargingStateChanged" DEAUTHORIZED = "Deauthorized" ENERGY_LIMIT_REACHED = "EnergyLimitReached" EV_COMMUNICATION_LOST = "EVCommunicationLost" EV_CONNECT_TIMEOUT = "EVConnectTimeout" METER_VALUE_CLOCK = "MeterValueClock" METER_VALUE_PERIODIC = "MeterValuePeriodic" TIME_LIMIT_REACHED = "TimeLimitReached" TRIGGER = "Trigger" UNLOCK_COMMAND = "UnlockCommand" STOP_AUTHORIZED = "StopAuthorized" EV_DEPARTED = "EVDeparted" EV_DETECTED = "EVDetected" REMOTE_STOP = "RemoteStop" REMOTE_START = "RemoteStart" ABNORMAL_CONDITION = "AbnormalCondition" SIGNED_DATA_RECEIVED = "SignedDataReceived" RESET_COMMAND = "ResetCommand" class Transaction(BaseModel): id: UUID status: TransactionStatus started_at: datetime ended_at: datetime meter_start: float meter_end: float end_reason: TransactionEventTriggerReason connector_id: str id_token_id: str class Config: from_attributes = True