"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.agency import (
    Agency,
)
from visaacceptancemergedspec.models.auto_rental import (
    AutoRental,
)
from visaacceptancemergedspec.models.lodging import (
    Lodging,
)
from visaacceptancemergedspec.models.transit import (
    Transit,
)
from visaacceptancemergedspec.models.vehicle_data import (
    VehicleData,
)


class TravelInformation(object):
    """Implementation of the 'TravelInformation' model.

    Attributes:
        duration (str): Duration of the auto rental or lodging rental.  #### Auto
            rental This field is supported for Visa, MasterCard, and American
            Express. **Important** If this field is not included when the
            `processingInformation.industryDataType` is auto rental, the transaction
            is declined.
        agency (Agency): The model property of type Agency.
        auto_rental (AutoRental): The model property of type AutoRental.
        lodging (Lodging): The model property of type Lodging.
        transit (Transit): The model property of type Transit.
        vehicle_data (VehicleData): The model property of type VehicleData.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "duration": "duration",
        "agency": "agency",
        "auto_rental": "autoRental",
        "lodging": "lodging",
        "transit": "transit",
        "vehicle_data": "vehicleData",
    }

    _optionals = [
        "duration",
        "agency",
        "auto_rental",
        "lodging",
        "transit",
        "vehicle_data",
    ]

    def __init__(
        self,
        duration=APIHelper.SKIP,
        agency=APIHelper.SKIP,
        auto_rental=APIHelper.SKIP,
        lodging=APIHelper.SKIP,
        transit=APIHelper.SKIP,
        vehicle_data=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a TravelInformation instance."""
        # Initialize members of the class
        if duration is not APIHelper.SKIP:
            self.duration = duration
        if agency is not APIHelper.SKIP:
            self.agency = agency
        if auto_rental is not APIHelper.SKIP:
            self.auto_rental = auto_rental
        if lodging is not APIHelper.SKIP:
            self.lodging = lodging
        if transit is not APIHelper.SKIP:
            self.transit = transit
        if vehicle_data is not APIHelper.SKIP:
            self.vehicle_data = vehicle_data

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        duration =\
            dictionary.get("duration")\
            if dictionary.get("duration")\
                else APIHelper.SKIP
        agency =\
            Agency.from_dictionary(
                dictionary.get("agency"))\
                if "agency" in dictionary.keys()\
                else APIHelper.SKIP
        auto_rental =\
            AutoRental.from_dictionary(
                dictionary.get("autoRental"))\
                if "autoRental" in dictionary.keys()\
                else APIHelper.SKIP
        lodging =\
            Lodging.from_dictionary(
                dictionary.get("lodging"))\
                if "lodging" in dictionary.keys()\
                else APIHelper.SKIP
        transit =\
            Transit.from_dictionary(
                dictionary.get("transit"))\
                if "transit" in dictionary.keys()\
                else APIHelper.SKIP
        vehicle_data =\
            VehicleData.from_dictionary(
                dictionary.get("vehicleData"))\
                if "vehicleData" in dictionary.keys()\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(duration,
                   agency,
                   auto_rental,
                   lodging,
                   transit,
                   vehicle_data,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _duration=(
            self.duration
            if hasattr(self, "duration")
            else None
        )
        _agency=(
            self.agency
            if hasattr(self, "agency")
            else None
        )
        _auto_rental=(
            self.auto_rental
            if hasattr(self, "auto_rental")
            else None
        )
        _lodging=(
            self.lodging
            if hasattr(self, "lodging")
            else None
        )
        _transit=(
            self.transit
            if hasattr(self, "transit")
            else None
        )
        _vehicle_data=(
            self.vehicle_data
            if hasattr(self, "vehicle_data")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"duration={_duration!r}, "
            f"agency={_agency!r}, "
            f"auto_rental={_auto_rental!r}, "
            f"lodging={_lodging!r}, "
            f"transit={_transit!r}, "
            f"vehicle_data={_vehicle_data!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _duration=(
            self.duration
            if hasattr(self, "duration")
            else None
        )
        _agency=(
            self.agency
            if hasattr(self, "agency")
            else None
        )
        _auto_rental=(
            self.auto_rental
            if hasattr(self, "auto_rental")
            else None
        )
        _lodging=(
            self.lodging
            if hasattr(self, "lodging")
            else None
        )
        _transit=(
            self.transit
            if hasattr(self, "transit")
            else None
        )
        _vehicle_data=(
            self.vehicle_data
            if hasattr(self, "vehicle_data")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"duration={_duration!s}, "
            f"agency={_agency!s}, "
            f"auto_rental={_auto_rental!s}, "
            f"lodging={_lodging!s}, "
            f"transit={_transit!s}, "
            f"vehicle_data={_vehicle_data!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
