"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.driver import Driver
from cellpointapi.models.rental_location import (
    RentalLocation,
)
from cellpointapi.models.vehicle import Vehicle


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

    Auto rental data for the order.

    Attributes:
        booking_reference (str): The booking reference number for the rental.
        vehicle (Vehicle): A vehicle that is being rented from an automobile rental
            company.
        is_similar_model_allowed (bool): If the rental company allows a similar model
            to be rented if the requested model is not available.
        unlimited_miles (bool): If the rental company allows unlimited miles.
        drivers (List[Driver]): The drivers of the vehicle.
        company_name (str): The name of the rental company.
        pickup_time (datetime): The date and time to pickup the vehicle.
        return_time (datetime): The date and time the vehicle must be returned before.
        pickup_location (RentalLocation): Location of Rental company.
        return_location (RentalLocation): Location of Rental company.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "booking_reference": "bookingReference",
        "vehicle": "vehicle",
        "is_similar_model_allowed": "isSimilarModelAllowed",
        "unlimited_miles": "unlimitedMiles",
        "drivers": "drivers",
        "company_name": "companyName",
        "pickup_time": "pickupTime",
        "return_time": "returnTime",
        "pickup_location": "pickupLocation",
        "return_location": "returnLocation",
    }

    def __init__(
        self,
        booking_reference=None,
        vehicle=None,
        is_similar_model_allowed=None,
        unlimited_miles=None,
        drivers=None,
        company_name=None,
        pickup_time=None,
        return_time=None,
        pickup_location=None,
        return_location=None,
        additional_properties=None):
        """Initialize a AutoRentalIndustryData instance."""
        # Initialize members of the class
        self.booking_reference = booking_reference
        self.vehicle = vehicle
        self.is_similar_model_allowed = is_similar_model_allowed
        self.unlimited_miles = unlimited_miles
        self.drivers = drivers
        self.company_name = company_name
        self.pickup_time =\
             APIHelper.apply_datetime_converter(
            pickup_time, APIHelper.RFC3339DateTime)\
             if pickup_time else None
        self.return_time =\
             APIHelper.apply_datetime_converter(
            return_time, APIHelper.RFC3339DateTime)\
             if return_time else None
        self.pickup_location = pickup_location
        self.return_location = return_location

        # 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
        booking_reference =\
            dictionary.get("bookingReference")\
            if dictionary.get("bookingReference")\
                else None
        vehicle =\
            Vehicle.from_dictionary(
                dictionary.get("vehicle"))\
                if dictionary.get("vehicle") else None
        is_similar_model_allowed =\
            dictionary.get("isSimilarModelAllowed")\
            if "isSimilarModelAllowed" in dictionary.keys()\
                else None
        unlimited_miles =\
            dictionary.get("unlimitedMiles")\
            if "unlimitedMiles" in dictionary.keys()\
                else None
        drivers = None
        if dictionary.get("drivers") is not None:
            drivers = [
                Driver.from_dictionary(x)
                    for x in dictionary.get("drivers")
            ]
        company_name =\
            dictionary.get("companyName")\
            if dictionary.get("companyName")\
                else None
        pickup_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("pickupTime")).datetime\
            if dictionary.get("pickupTime") else None
        return_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("returnTime")).datetime\
            if dictionary.get("returnTime") else None
        pickup_location =\
            RentalLocation.from_dictionary(
                dictionary.get("pickupLocation"))\
                if dictionary.get("pickupLocation") else None
        return_location =\
            RentalLocation.from_dictionary(
                dictionary.get("returnLocation"))\
                if dictionary.get("returnLocation") else None

        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(booking_reference,
                   vehicle,
                   is_similar_model_allowed,
                   unlimited_miles,
                   drivers,
                   company_name,
                   pickup_time,
                   return_time,
                   pickup_location,
                   return_location,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _booking_reference=self.booking_reference
        _vehicle=self.vehicle
        _is_similar_model_allowed=self.is_similar_model_allowed
        _unlimited_miles=self.unlimited_miles
        _drivers=self.drivers
        _company_name=self.company_name
        _pickup_time=self.pickup_time
        _return_time=self.return_time
        _pickup_location=self.pickup_location
        _return_location=self.return_location
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"booking_reference={_booking_reference!r}, "
            f"vehicle={_vehicle!r}, "
            f"is_similar_model_allowed={_is_similar_model_allowed!r}, "
            f"unlimited_miles={_unlimited_miles!r}, "
            f"drivers={_drivers!r}, "
            f"company_name={_company_name!r}, "
            f"pickup_time={_pickup_time!r}, "
            f"return_time={_return_time!r}, "
            f"pickup_location={_pickup_location!r}, "
            f"return_location={_return_location!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _booking_reference=self.booking_reference
        _vehicle=self.vehicle
        _is_similar_model_allowed=self.is_similar_model_allowed
        _unlimited_miles=self.unlimited_miles
        _drivers=self.drivers
        _company_name=self.company_name
        _pickup_time=self.pickup_time
        _return_time=self.return_time
        _pickup_location=self.pickup_location
        _return_location=self.return_location
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"booking_reference={_booking_reference!s}, "
            f"vehicle={_vehicle!s}, "
            f"is_similar_model_allowed={_is_similar_model_allowed!s}, "
            f"unlimited_miles={_unlimited_miles!s}, "
            f"drivers={_drivers!s}, "
            f"company_name={_company_name!s}, "
            f"pickup_time={_pickup_time!s}, "
            f"return_time={_return_time!s}, "
            f"pickup_location={_pickup_location!s}, "
            f"return_location={_return_location!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
