"""cellpointapi.

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

# ruff: noqa: E501
import dateutil.parser

from cellpointapi.api_helper import APIHelper
from cellpointapi.models.identifying_document import (
    IdentifyingDocument,
)
from cellpointapi.models.loyalty_account import (
    LoyaltyAccount,
)
from cellpointapi.models.phone import Phone


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

    Passenger that is traveling.

    Attributes:
        given_name (str): Name bestowed upon an individual to differentiate them from
            other members of a group that share a family name.  In the U.S., the
            first name of a Person.
        family_name (str): Name bestowed upon an individual to denote membership in a
            group or family.  In the U.S., the last name of a Person.
        middle_name (str): Secondary name bestowed upon an individual to
            differentiate them from others that have the same given name.
        name_prefix (str): The portion of a name's full form of address that precedes
            the name itself.
        name_suffix (str): The portion of a name's full form of address that follows
            the name itself.
        date_of_birth (date): The shopper's date of birth.  Format ISO-8601:
            YYYY-MM-DD
        gender (Gender): Genders for individuals
        email (str): User email address
        phone (Phone): Telephone number.
        id (str): Identifier for passenger that is unique within this order. This
            identifier should be used for any reference to this passenger elsewhere,
            such as fares or ancillaries in the price summary.  How this identifier
            is generated is up to the merchant, as long as it is unique within the
            order.
        mtype (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.
        documents (List[IdentifyingDocument]): The model property of type
            List[IdentifyingDocument].
        loyalty_account (LoyaltyAccount): Loyalty account information.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "given_name": "givenName",
        "family_name": "familyName",
        "id": "id",
        "mtype": "type",
        "middle_name": "middleName",
        "name_prefix": "namePrefix",
        "name_suffix": "nameSuffix",
        "date_of_birth": "dateOfBirth",
        "gender": "gender",
        "email": "email",
        "phone": "phone",
        "documents": "documents",
        "loyalty_account": "loyaltyAccount",
    }

    _optionals = [
        "middle_name",
        "name_prefix",
        "name_suffix",
        "date_of_birth",
        "gender",
        "email",
        "phone",
        "documents",
        "loyalty_account",
    ]

    def __init__(
        self,
        given_name=None,
        family_name=None,
        id=None,
        mtype=None,
        middle_name=APIHelper.SKIP,
        name_prefix=APIHelper.SKIP,
        name_suffix=APIHelper.SKIP,
        date_of_birth=APIHelper.SKIP,
        gender=APIHelper.SKIP,
        email=APIHelper.SKIP,
        phone=APIHelper.SKIP,
        documents=APIHelper.SKIP,
        loyalty_account=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Passenger instance."""
        # Initialize members of the class
        self.given_name = given_name
        self.family_name = family_name
        if middle_name is not APIHelper.SKIP:
            self.middle_name = middle_name
        if name_prefix is not APIHelper.SKIP:
            self.name_prefix = name_prefix
        if name_suffix is not APIHelper.SKIP:
            self.name_suffix = name_suffix
        if date_of_birth is not APIHelper.SKIP:
            self.date_of_birth = date_of_birth
        if gender is not APIHelper.SKIP:
            self.gender = gender
        if email is not APIHelper.SKIP:
            self.email = email
        if phone is not APIHelper.SKIP:
            self.phone = phone
        self.id = id
        self.mtype = mtype
        if documents is not APIHelper.SKIP:
            self.documents = documents
        if loyalty_account is not APIHelper.SKIP:
            self.loyalty_account = loyalty_account

        # 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
        given_name =\
            dictionary.get("givenName")\
            if dictionary.get("givenName")\
                else None
        family_name =\
            dictionary.get("familyName")\
            if dictionary.get("familyName")\
                else None
        id =\
            dictionary.get("id")\
            if dictionary.get("id")\
                else None
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else None
        middle_name =\
            dictionary.get("middleName")\
            if dictionary.get("middleName")\
                else APIHelper.SKIP
        name_prefix =\
            dictionary.get("namePrefix")\
            if dictionary.get("namePrefix")\
                else APIHelper.SKIP
        name_suffix =\
            dictionary.get("nameSuffix")\
            if dictionary.get("nameSuffix")\
                else APIHelper.SKIP
        date_of_birth = dateutil.parser.parse(
            dictionary.get("dateOfBirth")).date()\
            if dictionary.get("dateOfBirth") else APIHelper.SKIP
        gender =\
            dictionary.get("gender")\
            if dictionary.get("gender")\
                else APIHelper.SKIP
        email =\
            dictionary.get("email")\
            if dictionary.get("email")\
                else APIHelper.SKIP
        phone =\
            Phone.from_dictionary(
                dictionary.get("phone"))\
                if "phone" in dictionary.keys()\
                else APIHelper.SKIP
        documents = None
        if dictionary.get("documents") is not None:
            documents = [
                IdentifyingDocument.from_dictionary(x)
                    for x in dictionary.get("documents")
            ]
        else:
            documents = APIHelper.SKIP
        loyalty_account =\
            LoyaltyAccount.from_dictionary(
                dictionary.get("loyaltyAccount"))\
                if "loyaltyAccount" 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(given_name,
                   family_name,
                   id,
                   mtype,
                   middle_name,
                   name_prefix,
                   name_suffix,
                   date_of_birth,
                   gender,
                   email,
                   phone,
                   documents,
                   loyalty_account,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _given_name=self.given_name
        _family_name=self.family_name
        _middle_name=(
            self.middle_name
            if hasattr(self, "middle_name")
            else None
        )
        _name_prefix=(
            self.name_prefix
            if hasattr(self, "name_prefix")
            else None
        )
        _name_suffix=(
            self.name_suffix
            if hasattr(self, "name_suffix")
            else None
        )
        _date_of_birth=(
            self.date_of_birth
            if hasattr(self, "date_of_birth")
            else None
        )
        _gender=(
            self.gender
            if hasattr(self, "gender")
            else None
        )
        _email=(
            self.email
            if hasattr(self, "email")
            else None
        )
        _phone=(
            self.phone
            if hasattr(self, "phone")
            else None
        )
        _id=self.id
        _mtype=self.mtype
        _documents=(
            self.documents
            if hasattr(self, "documents")
            else None
        )
        _loyalty_account=(
            self.loyalty_account
            if hasattr(self, "loyalty_account")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"given_name={_given_name!r}, "
            f"family_name={_family_name!r}, "
            f"middle_name={_middle_name!r}, "
            f"name_prefix={_name_prefix!r}, "
            f"name_suffix={_name_suffix!r}, "
            f"date_of_birth={_date_of_birth!r}, "
            f"gender={_gender!r}, "
            f"email={_email!r}, "
            f"phone={_phone!r}, "
            f"id={_id!r}, "
            f"mtype={_mtype!r}, "
            f"documents={_documents!r}, "
            f"loyalty_account={_loyalty_account!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _given_name=self.given_name
        _family_name=self.family_name
        _middle_name=(
            self.middle_name
            if hasattr(self, "middle_name")
            else None
        )
        _name_prefix=(
            self.name_prefix
            if hasattr(self, "name_prefix")
            else None
        )
        _name_suffix=(
            self.name_suffix
            if hasattr(self, "name_suffix")
            else None
        )
        _date_of_birth=(
            self.date_of_birth
            if hasattr(self, "date_of_birth")
            else None
        )
        _gender=(
            self.gender
            if hasattr(self, "gender")
            else None
        )
        _email=(
            self.email
            if hasattr(self, "email")
            else None
        )
        _phone=(
            self.phone
            if hasattr(self, "phone")
            else None
        )
        _id=self.id
        _mtype=self.mtype
        _documents=(
            self.documents
            if hasattr(self, "documents")
            else None
        )
        _loyalty_account=(
            self.loyalty_account
            if hasattr(self, "loyalty_account")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"given_name={_given_name!s}, "
            f"family_name={_family_name!s}, "
            f"middle_name={_middle_name!s}, "
            f"name_prefix={_name_prefix!s}, "
            f"name_suffix={_name_suffix!s}, "
            f"date_of_birth={_date_of_birth!s}, "
            f"gender={_gender!s}, "
            f"email={_email!s}, "
            f"phone={_phone!s}, "
            f"id={_id!s}, "
            f"mtype={_mtype!s}, "
            f"documents={_documents!s}, "
            f"loyalty_account={_loyalty_account!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
