# coding: utf-8

"""
    Train Journey

    Demonstrate feature of Aladdin Graph services using train journeys, stations and trains.  # noqa: E501

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import date, datetime
from typing import List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist
from aladdinsdk.api.codegen.reference_architecture.demo.train_journey.v1.TrainJourneyAPI.models.train_station_train_station_facilities_slice import TrainStationTrainStationFacilitiesSlice
from aladdinsdk.api.codegen.reference_architecture.demo.train_journey.v1.TrainJourneyAPI.models.train_station_train_station_summary_slice import TrainStationTrainStationSummarySlice
from aladdinsdk.api.codegen.reference_architecture.demo.train_journey.v1.TrainJourneyAPI.models.train_train_summary_slice import TrainTrainSummarySlice

class V1TrainJourney(BaseModel):
    """
    A train journey represents a specific journey from one station to another one.
    """
    id: Optional[StrictStr] = Field(None, description="ID describes the computer or human assigned resource identifier.")
    short_code: Optional[StrictStr] = Field(None, alias="shortCode")
    train_id: Optional[StrictStr] = Field(None, alias="trainId")
    train_summary: Optional[TrainTrainSummarySlice] = Field(None, alias="trainSummary")
    departing_train_station_id: Optional[StrictStr] = Field(None, alias="departingTrainStationId")
    departing_station_summary_slice: Optional[TrainStationTrainStationSummarySlice] = Field(None, alias="departingStationSummarySlice")
    departing_station_facilities_slice: Optional[TrainStationTrainStationFacilitiesSlice] = Field(None, alias="departingStationFacilitiesSlice")
    destination_train_station_id: Optional[StrictStr] = Field(None, alias="destinationTrainStationId")
    destination_station_summary_slice: Optional[TrainStationTrainStationSummarySlice] = Field(None, alias="destinationStationSummarySlice")
    destination_station_facilities_slice: Optional[TrainStationTrainStationFacilitiesSlice] = Field(None, alias="destinationStationFacilitiesSlice")
    pass_through_station_ids: Optional[conlist(StrictStr)] = Field(None, alias="passThroughStationIds")
    journey_date: Optional[date] = Field(None, alias="journeyDate")
    journey_time: Optional[datetime] = Field(None, alias="journeyTime")
    journey_duration: Optional[StrictStr] = Field(None, alias="journeyDuration")
    __properties = ["id", "shortCode", "trainId", "trainSummary", "departingTrainStationId", "departingStationSummarySlice", "departingStationFacilitiesSlice", "destinationTrainStationId", "destinationStationSummarySlice", "destinationStationFacilitiesSlice", "passThroughStationIds", "journeyDate", "journeyTime", "journeyDuration"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1TrainJourney:
        """Create an instance of V1TrainJourney from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of train_summary
        if self.train_summary:
            _dict['trainSummary'] = self.train_summary.to_dict()
        # override the default output from pydantic by calling `to_dict()` of departing_station_summary_slice
        if self.departing_station_summary_slice:
            _dict['departingStationSummarySlice'] = self.departing_station_summary_slice.to_dict()
        # override the default output from pydantic by calling `to_dict()` of departing_station_facilities_slice
        if self.departing_station_facilities_slice:
            _dict['departingStationFacilitiesSlice'] = self.departing_station_facilities_slice.to_dict()
        # override the default output from pydantic by calling `to_dict()` of destination_station_summary_slice
        if self.destination_station_summary_slice:
            _dict['destinationStationSummarySlice'] = self.destination_station_summary_slice.to_dict()
        # override the default output from pydantic by calling `to_dict()` of destination_station_facilities_slice
        if self.destination_station_facilities_slice:
            _dict['destinationStationFacilitiesSlice'] = self.destination_station_facilities_slice.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1TrainJourney:
        """Create an instance of V1TrainJourney from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1TrainJourney.parse_obj(obj)

        _obj = V1TrainJourney.parse_obj({
            "id": obj.get("id"),
            "short_code": obj.get("shortCode"),
            "train_id": obj.get("trainId"),
            "train_summary": TrainTrainSummarySlice.from_dict(obj.get("trainSummary")) if obj.get("trainSummary") is not None else None,
            "departing_train_station_id": obj.get("departingTrainStationId"),
            "departing_station_summary_slice": TrainStationTrainStationSummarySlice.from_dict(obj.get("departingStationSummarySlice")) if obj.get("departingStationSummarySlice") is not None else None,
            "departing_station_facilities_slice": TrainStationTrainStationFacilitiesSlice.from_dict(obj.get("departingStationFacilitiesSlice")) if obj.get("departingStationFacilitiesSlice") is not None else None,
            "destination_train_station_id": obj.get("destinationTrainStationId"),
            "destination_station_summary_slice": TrainStationTrainStationSummarySlice.from_dict(obj.get("destinationStationSummarySlice")) if obj.get("destinationStationSummarySlice") is not None else None,
            "destination_station_facilities_slice": TrainStationTrainStationFacilitiesSlice.from_dict(obj.get("destinationStationFacilitiesSlice")) if obj.get("destinationStationFacilitiesSlice") is not None else None,
            "pass_through_station_ids": obj.get("passThroughStationIds"),
            "journey_date": obj.get("journeyDate"),
            "journey_time": obj.get("journeyTime"),
            "journey_duration": obj.get("journeyDuration")
        })
        return _obj

