Skip to content

Commit

Permalink
Set payload on all Endpoint models to Optional with None as default
Browse files Browse the repository at this point in the history
  • Loading branch information
CM000n committed Nov 28, 2023
1 parent bc7415f commit 4e5d4b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
8 changes: 5 additions & 3 deletions mytoyota/models/endpoints/electric.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
""" Toyota Connected Services API - Electric Models """
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field

from .common import StatusModel, _Range
from mytoyota.models.endpoints.common import StatusModel, _Range

# pylint: disable=locally-disabled, missing-class-docstring, fixme

Expand All @@ -19,4 +21,4 @@ class ElectricStatusModel(BaseModel):


class ElectricResponseModel(StatusModel):
payload: ElectricStatusModel
payload: Optional[ElectricStatusModel] = None
11 changes: 10 additions & 1 deletion mytoyota/models/endpoints/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,44 @@

from mytoyota.models.endpoints.common import StatusModel


class _ValueModel(BaseModel):
value: str
status: int


class _SectionModel(BaseModel):
section: str
values: List[_ValueModel]


class _VehicleStatusModel(BaseModel):
category: str
display_order: int = Field(alias="displayOrder")
sections: List[_SectionModel]


class _FugageModel(BaseModel):
value: float
unit: str


class _RageModel(BaseModel):
value: float
unit: str


class _OdoModel(BaseModel):
value: float
unit: str


class _TelemetryModel(BaseModel):
fugage: _FugageModel
rage: _RageModel
odo: _OdoModel


class RemoteStatusModel(BaseModel):
vehicle_status: List[_VehicleStatusModel] = Field(alias="vehicleStatus")
telemetry: _TelemetryModel
Expand All @@ -45,5 +53,6 @@ class RemoteStatusModel(BaseModel):
longitude: float
location_acquisition_datetime: datetime = Field(alias="locationAcquisitionDatetime")


class RemoteStatusResponseModel(StatusModel):
payload: Optional[RemoteStatusModel]
payload: Optional[RemoteStatusModel] = None
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class TelemetryModel(BaseModel):


class TelemetryResponceModel(StatusModel):
payload: Optional[TelemetryModel]
payload: Optional[TelemetryModel] = None
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ class TripsModel(BaseModel):


class TripsResponseModel(StatusModel):
payload: TripsModel
payload: Optional[TripsModel] = None
2 changes: 1 addition & 1 deletion mytoyota/models/endpoints/vehicle_guid.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,4 @@ class VehicleGuidModel(BaseModel):


class VehiclesResponseModel(StatusModel):
payload: Optional[List[VehicleGuidModel]]
payload: Optional[List[VehicleGuidModel]] = None

0 comments on commit 4e5d4b0

Please sign in to comment.