"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper


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

    Airline Ancillary details and codes.

    Attributes:
        subcode (str): Ancillary subcode defined by IATA.   Example:   <table>   <tr>
            <th>Sub Code</th>     <th>Group</th>     <th>Sub Group</th>
            <th>Description 1</th>     <th>Description 2</th>     <th>Commercial
            Name</th>     <th>RFIC</th>   </tr>   <tr>     <td>0MJ</td>     <td>BG -
            Baggage</td>     <td>CY - Carry On Hand Baggage</td>     <td>10 - Up to
            22 lb/10kg</td>     <td>4U - Up to 45 li/115 lcm</td>     <td>CARRY 10KG
            22LB UPTO 45LI 115LCM C</td>     <td>C</td>   </tr> </table>
        group (str): <table> <tr>   <th>Group</th>   <th>Description</th> </tr> <tr>
            <td>BD</td>   <td>Bundled Service</td> </tr> <tr>   <td>BF</td>
            <td>Branded Fares</td> </tr> <tr>   <td>BG</td>   <td>Baggage</td> </tr>
            <tr>   <td>CO</td>   <td>Carbon Offset</td> </tr> <tr>   <td>FF</td>
            <td>Frequent Flyer</td> </tr> <tr>   <td>GT</td>   <td>Ground
            Transportation and Non Air Services</td> </tr> <tr>   <td>IE</td>
            <td>In-flight entertainment</td> </tr> <tr>   <td>LG</td>
            <td>Lounge</td> </tr> <tr>   <td>MD</td>   <td>Medical</td> </tr> <tr>
            <td>ML</td>   <td>Meal/Beverage</td> </tr> <tr>   <td>PT</td>
            <td>Pets</td> </tr> <tr>   <td>RO</td>   <td>Rule Override *</td> </tr>
            <tr>   <td>SA</td>   <td>Pre-reserved Seat Assignment</td> </tr> <tr>
            <td>SB</td>   <td>Standby</td> </tr> <tr>   <td>ST</td>   <td>Store</td>
            </tr> <tr>   <td>TS</td>   <td>Travel Services</td> </tr> <tr>
            <td>UN</td>   <td>Unaccompanied Travel (Escort)</td> </tr> <tr>
            <td>UP</td>   <td>Upgrades</td> </tr> <tr>   <td>UU</td>
            <td>Unaccompanied Travel (Unescorted)</td> </tr> </table>
        subgroup (str): The model property of type str.
        rfic_code (str): <table> <thead>   <tr>     <th>RFIC</th>
            <th>Description</th>   </tr> </thead> <tbody>   <tr>     <td>A</td>
            <td>Air Transportation</td>   </tr>   <tr>     <td>B</td>     <td>Surface
            Transportation /Non Air Services</td>   </tr>   <tr>     <td>C</td>
            <td>Baggage</td>   </tr>   <tr>     <td>D</td>     <td>Financial
            Impact</td>   </tr>   <tr>     <td>E</td>     <td>Airport Services</td>
            </tr>   <tr>     <td>F</td>     <td>Merchandise</td>   </tr>   <tr>
            <td>G</td>     <td>In-flight Services</td>   </tr>   <tr>     <td>H</td>
            <td>Reserved for future use</td>   </tr>   <tr>     <td>I</td>
            <td>Individual Airline Use</td>   </tr> </tbody> </table>
        descriptions (Dict[str, str]): Ancillary description codes defined by IATA.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "subcode": "subcode",
        "group": "group",
        "subgroup": "subgroup",
        "rfic_code": "rficCode",
        "descriptions": "descriptions",
    }

    _optionals = [
        "rfic_code",
        "descriptions",
    ]

    def __init__(
        self,
        subcode=None,
        group=None,
        subgroup=None,
        rfic_code=APIHelper.SKIP,
        descriptions=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AncillaryDetails instance."""
        # Initialize members of the class
        self.subcode = subcode
        self.group = group
        self.subgroup = subgroup
        if rfic_code is not APIHelper.SKIP:
            self.rfic_code = rfic_code
        if descriptions is not APIHelper.SKIP:
            self.descriptions = descriptions

        # 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
        subcode =\
            dictionary.get("subcode")\
            if dictionary.get("subcode")\
                else None
        group =\
            dictionary.get("group")\
            if dictionary.get("group")\
                else None
        subgroup =\
            dictionary.get("subgroup")\
            if dictionary.get("subgroup")\
                else None
        rfic_code =\
            dictionary.get("rficCode")\
            if dictionary.get("rficCode")\
                else APIHelper.SKIP
        descriptions =\
            dictionary.get("descriptions")\
            if dictionary.get("descriptions")\
                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(subcode,
                   group,
                   subgroup,
                   rfic_code,
                   descriptions,
                   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.subcode,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.group,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.subgroup,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                ))

        if not isinstance(dictionary, dict):
            return False

        return APIHelper.is_valid_type(
                value=dictionary.get("subcode"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("group"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("subgroup"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            ))

    def __repr__(self):
        """Return a unambiguous string representation."""
        _subcode=self.subcode
        _group=self.group
        _subgroup=self.subgroup
        _rfic_code=(
            self.rfic_code
            if hasattr(self, "rfic_code")
            else None
        )
        _descriptions=(
            self.descriptions
            if hasattr(self, "descriptions")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"subcode={_subcode!r}, "
            f"group={_group!r}, "
            f"subgroup={_subgroup!r}, "
            f"rfic_code={_rfic_code!r}, "
            f"descriptions={_descriptions!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _subcode=self.subcode
        _group=self.group
        _subgroup=self.subgroup
        _rfic_code=(
            self.rfic_code
            if hasattr(self, "rfic_code")
            else None
        )
        _descriptions=(
            self.descriptions
            if hasattr(self, "descriptions")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"subcode={_subcode!s}, "
            f"group={_group!s}, "
            f"subgroup={_subgroup!s}, "
            f"rfic_code={_rfic_code!s}, "
            f"descriptions={_descriptions!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
