simple-ocpp-cs/app/schemas/transaction.py

48 lines
1.5 KiB
Python
Raw Normal View History

2024-03-28 21:23:25 +01:00
from datetime import datetime
2024-04-19 00:08:29 +02:00
from decimal import Decimal
2024-03-28 21:23:25 +01:00
import enum
2024-04-19 00:08:29 +02:00
from typing import Optional
2024-04-13 22:43:03 +02:00
from uuid import UUID
2024-03-28 21:23:25 +01:00
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):
2024-04-19 00:08:29 +02:00
id: str
2024-03-28 21:23:25 +01:00
status: TransactionStatus
started_at: datetime
2024-04-19 00:08:29 +02:00
ended_at: Optional[datetime] = None
meter_start: Decimal
meter_end: Optional[Decimal] = None
end_reason: Optional[TransactionEventTriggerReason] = None
price: Decimal
user_id: Optional[UUID] = None
chargepoint_id: UUID
2024-03-28 21:23:25 +01:00
class Config:
from_attributes = True