"""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.itinerary_type import (
    ItineraryType,
)
from cellpointapi.models.non_negative_amount import (
    NonNegativeAmount,
)


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

    Represents an airline fare that is part of a bundle.

    Attributes:
        mtype (str): Discriminator used to identify the type of line item.
        title (str): What should be shown as the title of the line item on a receipt
            or billing summary.
        authorization_group_id (str): AuthorizationGroup that the line item should be
            part of for splitting authorizations for Aggregate Payments Payments.  If
            this is set, there must be a matching AuthorizationGroup created in the
            PriceSummary.  > NOTE: Items within a Bundle should not have an
            `authorizationGroupId`, they will use the same `authorizationGroupId` as
            the top-level bundle.
        sku (str): Stock Keeping Unit (SKU) is a product and service identification
            code for a specific product.
        quantity (int): The model property of type int.
        unit_price (NonNegativeAmount): An amount that is a nonnegative number, i.e.
            {0, 1, 2, 3, 4, 5,…}
        total_price (NonNegativeAmount): Total Price for the line item. Should be
            equal to `unitPrice` * `quantity`, if `unitPrice` is specified.
        pnr (str): Passenger Name Record.  MUST match a PNR in
            `IndustryData.AirlineData`.
        carrier_name (str): The model property of type str.
        passenger_ids (List[str]): The model property of type List[str].
        fare_basis_codes (List[str]): The model property of type List[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>
        journey_segment (JourneySegment): Segment of the journey.   Given an the
            following `ItineraryType`, here are the example JourneySegment to use:
            <table> <thead>   <tr>     <th>Itinerary Type</th>     <th>Journey
            Segment</th>     <th>Description</th>   </tr> </thead> <tbody>   <tr>
            <td>ONE_WAY</td>     <td>OUTBOUND</td>     <td>Single Journey</td>
            </tr>   <tr>     <td>ROUND_TRIP</td>     <td>OUTBOUND</td>     <td>First
            Journey, leaving.</td>   </tr>   <tr>     <td>ROUND_TRIP</td>
            <td>INBOUND</td>     <td>Second Journey, returning.</td>   </tr>   <tr>
            <td>MULTI_CITY</td>     <td>MULTI_CITY_1</td>     <td>First Journey </td>
            </tr>   <tr>     <td>MULTI_CITY</td>     <td>MULTI_CITY_2</td>
            <td>Second Journey </td>   </tr>   <tr>     <td>MULTI_CITY</td>
            <td>MULTI_CITY_3</td>     <td>Third Journey </td>   </tr> </tbody>
            </table>
        passenger_type_code (str): Passenger type code (PTC). IATA PTC values are
            3-letter alphabetical. Example: ADT, SRC, CNN, INS.  Commonly used codes
            include (but definitely not limited to): - `ADT`: Adult - `CNN`: Child -
            `INF`: Infant without a seat - `INS`: Infant with a seat - `SRC`: Senior
            Citizen  However, several carriers use non-standard codes that can be up
            to 5 alphanumeric characters.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "mtype": "type",
        "title": "title",
        "sku": "sku",
        "quantity": "quantity",
        "unit_price": "unitPrice",
        "total_price": "totalPrice",
        "pnr": "pnr",
        "carrier_name": "carrierName",
        "fare_basis_codes": "fareBasisCodes",
        "itinerary_type": "itineraryType",
        "authorization_group_id": "authorizationGroupId",
        "passenger_ids": "passengerIds",
        "journey_segment": "journeySegment",
        "passenger_type_code": "passengerTypeCode",
    }

    _optionals = [
        "authorization_group_id",
        "passenger_ids",
        "journey_segment",
        "passenger_type_code",
    ]

    def __init__(
        self,
        title=None,
        sku=None,
        quantity=1,
        unit_price=None,
        total_price=None,
        pnr=None,
        carrier_name=None,
        fare_basis_codes=None,
        itinerary_type=None,
        authorization_group_id=APIHelper.SKIP,
        passenger_ids=APIHelper.SKIP,
        journey_segment=APIHelper.SKIP,
        passenger_type_code=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AirlineFare instance."""
        # Initialize members of the class
        self.mtype = "AIRLINE_FARE"
        self.title = title
        if authorization_group_id is not APIHelper.SKIP:
            self.authorization_group_id = authorization_group_id
        self.sku = sku
        self.quantity = quantity
        self.unit_price = unit_price
        self.total_price = total_price
        self.pnr = pnr
        self.carrier_name = carrier_name
        if passenger_ids is not APIHelper.SKIP:
            self.passenger_ids = passenger_ids
        self.fare_basis_codes = fare_basis_codes
        self.itinerary_type = itinerary_type
        if journey_segment is not APIHelper.SKIP:
            self.journey_segment = journey_segment
        if passenger_type_code is not APIHelper.SKIP:
            self.passenger_type_code = passenger_type_code

        # 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
        title =\
            dictionary.get("title")\
            if dictionary.get("title")\
                else None
        sku =\
            dictionary.get("sku")\
            if dictionary.get("sku")\
                else None
        quantity =\
            dictionary.get("quantity")\
            if dictionary.get("quantity")\
                else 1
        unit_price =\
            NonNegativeAmount.from_dictionary(
                dictionary.get("unitPrice"))\
                if dictionary.get("unitPrice") else None
        total_price =\
            NonNegativeAmount.from_dictionary(
                dictionary.get("totalPrice"))\
                if dictionary.get("totalPrice") else None
        pnr =\
            dictionary.get("pnr")\
            if dictionary.get("pnr")\
                else None
        carrier_name =\
            dictionary.get("carrierName")\
            if dictionary.get("carrierName")\
                else None
        fare_basis_codes =\
            dictionary.get("fareBasisCodes")\
            if dictionary.get("fareBasisCodes")\
                else None
        itinerary_type =\
            dictionary.get("itineraryType")\
            if dictionary.get("itineraryType")\
                else None
        authorization_group_id =\
            dictionary.get("authorizationGroupId")\
            if dictionary.get("authorizationGroupId")\
                else APIHelper.SKIP
        passenger_ids =\
            dictionary.get("passengerIds")\
            if dictionary.get("passengerIds")\
                else APIHelper.SKIP
        journey_segment =\
            dictionary.get("journeySegment")\
            if dictionary.get("journeySegment")\
                else APIHelper.SKIP
        passenger_type_code =\
            dictionary.get("passengerTypeCode")\
            if dictionary.get("passengerTypeCode")\
                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(title,
                   sku,
                   quantity,
                   unit_price,
                   total_price,
                   pnr,
                   carrier_name,
                   fare_basis_codes,
                   itinerary_type,
                   authorization_group_id,
                   passenger_ids,
                   journey_segment,
                   passenger_type_code,
                   additional_properties)

    @classmethod
    def validate(cls, dictionary):
        """Validate dictionary against class required properties

        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:
            boolean : if dictionary is valid contains required properties.

        """
        if isinstance(dictionary, cls):
            return APIHelper.is_valid_type(
                    value=dictionary.mtype,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.title,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.sku,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.quantity,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        int,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.unit_price,
                    type_callable=lambda value:
                        NonNegativeAmount.validate(value),
                    is_model_dict=True) \
                and APIHelper.is_valid_type(
                    value=dictionary.total_price,
                    type_callable=lambda value:
                        NonNegativeAmount.validate(value),
                    is_model_dict=True) \
                and APIHelper.is_valid_type(
                    value=dictionary.pnr,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.carrier_name,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.fare_basis_codes,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.itinerary_type,
                    type_callable=lambda value:
                        ItineraryType.validate(value))

        if not isinstance(dictionary, dict):
            return False

        return APIHelper.is_valid_type(
                value=dictionary.get("type"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("title"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("sku"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("quantity"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    int,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("unitPrice"),
                type_callable=lambda value:
                    NonNegativeAmount.validate(value),
                is_model_dict=True) \
            and APIHelper.is_valid_type(
                value=dictionary.get("totalPrice"),
                type_callable=lambda value:
                    NonNegativeAmount.validate(value),
                is_model_dict=True) \
            and APIHelper.is_valid_type(
                value=dictionary.get("pnr"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("carrierName"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("fareBasisCodes"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("itineraryType"),
                type_callable=lambda value:
                    ItineraryType.validate(value))

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=self.mtype
        _title=self.title
        _authorization_group_id=(
            self.authorization_group_id
            if hasattr(self, "authorization_group_id")
            else None
        )
        _sku=self.sku
        _quantity=self.quantity
        _unit_price=self.unit_price
        _total_price=self.total_price
        _pnr=self.pnr
        _carrier_name=self.carrier_name
        _passenger_ids=(
            self.passenger_ids
            if hasattr(self, "passenger_ids")
            else None
        )
        _fare_basis_codes=self.fare_basis_codes
        _itinerary_type=self.itinerary_type
        _journey_segment=(
            self.journey_segment
            if hasattr(self, "journey_segment")
            else None
        )
        _passenger_type_code=(
            self.passenger_type_code
            if hasattr(self, "passenger_type_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"title={_title!r}, "
            f"authorization_group_id={_authorization_group_id!r}, "
            f"sku={_sku!r}, "
            f"quantity={_quantity!r}, "
            f"unit_price={_unit_price!r}, "
            f"total_price={_total_price!r}, "
            f"pnr={_pnr!r}, "
            f"carrier_name={_carrier_name!r}, "
            f"passenger_ids={_passenger_ids!r}, "
            f"fare_basis_codes={_fare_basis_codes!r}, "
            f"itinerary_type={_itinerary_type!r}, "
            f"journey_segment={_journey_segment!r}, "
            f"passenger_type_code={_passenger_type_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=self.mtype
        _title=self.title
        _authorization_group_id=(
            self.authorization_group_id
            if hasattr(self, "authorization_group_id")
            else None
        )
        _sku=self.sku
        _quantity=self.quantity
        _unit_price=self.unit_price
        _total_price=self.total_price
        _pnr=self.pnr
        _carrier_name=self.carrier_name
        _passenger_ids=(
            self.passenger_ids
            if hasattr(self, "passenger_ids")
            else None
        )
        _fare_basis_codes=self.fare_basis_codes
        _itinerary_type=self.itinerary_type
        _journey_segment=(
            self.journey_segment
            if hasattr(self, "journey_segment")
            else None
        )
        _passenger_type_code=(
            self.passenger_type_code
            if hasattr(self, "passenger_type_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"title={_title!s}, "
            f"authorization_group_id={_authorization_group_id!s}, "
            f"sku={_sku!s}, "
            f"quantity={_quantity!s}, "
            f"unit_price={_unit_price!s}, "
            f"total_price={_total_price!s}, "
            f"pnr={_pnr!s}, "
            f"carrier_name={_carrier_name!s}, "
            f"passenger_ids={_passenger_ids!s}, "
            f"fare_basis_codes={_fare_basis_codes!s}, "
            f"itinerary_type={_itinerary_type!s}, "
            f"journey_segment={_journey_segment!s}, "
            f"passenger_type_code={_passenger_type_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
