"""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.passenger import Passenger
from cellpointapi.models.travel_journey import (
    TravelJourney,
)


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

    AirlineIndustryData for the order.

    Attributes:
        pnr (str): The model property of type str.
        itinerary_type (ItineraryType): Type of itinerary being booked for travel.
            <table> <thead>   <tr>     <th>Itinerary Type</th>
            <th>Description</th>   </tr> </thead> <tbody>   <tr>     <td>ONE_WAY</td>
            <td>Only a single journey is being taken, with no return journey
            booked.</td>   </tr>   <tr>     <td>ROUND_TRIP</td>     <td>Two journeys
            are being booked, one outbound and one inbound. Final inbound journey
            will be returning to where the traveler started.</td>   </tr>   <tr>
            <td>MULTI_CITY</td>     <td>Multiple journeys are being booked at once
            between various cities.</td>   </tr> </tbody> </table>
        passengers (List[Passenger]): Passengers that are traveling as part of this
            itinerary.
        itinerary (List[TravelJourney]): A collection of Journeys that Passengers
            have booked.  #### Journey Traveling from an origin to a destination. May
            have multiple Travel Legs as part of a journey to get to the final
            destination.  > Note that during a One-Way itinerary, there will be
            exactly 1 journey. > > On a Round-Trip itinerary, there will be exactly 2
            journeys. > > Multi-City may have between 2+ journeys.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "pnr": "pnr",
        "itinerary_type": "itineraryType",
        "passengers": "passengers",
        "itinerary": "itinerary",
    }

    def __init__(
        self,
        pnr=None,
        itinerary_type=None,
        passengers=None,
        itinerary=None,
        additional_properties=None):
        """Initialize a AirlineIndustryData instance."""
        # Initialize members of the class
        self.pnr = pnr
        self.itinerary_type = itinerary_type
        self.passengers = passengers
        self.itinerary = itinerary

        # 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
        pnr =\
            dictionary.get("pnr")\
            if dictionary.get("pnr")\
                else None
        itinerary_type =\
            dictionary.get("itineraryType")\
            if dictionary.get("itineraryType")\
                else None
        passengers = None
        if dictionary.get("passengers") is not None:
            passengers = [
                Passenger.from_dictionary(x)
                    for x in dictionary.get("passengers")
            ]
        itinerary = None
        if dictionary.get("itinerary") is not None:
            itinerary = [
                TravelJourney.from_dictionary(x)
                    for x in dictionary.get("itinerary")
            ]

        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(pnr,
                   itinerary_type,
                   passengers,
                   itinerary,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _pnr=self.pnr
        _itinerary_type=self.itinerary_type
        _passengers=self.passengers
        _itinerary=self.itinerary
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"pnr={_pnr!r}, "
            f"itinerary_type={_itinerary_type!r}, "
            f"passengers={_passengers!r}, "
            f"itinerary={_itinerary!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _pnr=self.pnr
        _itinerary_type=self.itinerary_type
        _passengers=self.passengers
        _itinerary=self.itinerary
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"pnr={_pnr!s}, "
            f"itinerary_type={_itinerary_type!s}, "
            f"passengers={_passengers!s}, "
            f"itinerary={_itinerary!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
