"""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


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

    Documents that identify an individual.

    Attributes:
        mtype (IdentifyingDocumentType): Identification document types.
        number (str): Identification number.
        description (str): Optional description or more information about the
            document.
        issuing_country (str): Country where identifying document was issued.
        issuing_authority (str): Authority that issued the identifying document.
        nationality (str): Country that person belongs to via origin, birth, or
            naturalization.
        place_of_birth (str): The model property of type str.
        issue_date (date): Issue date of identifying document.  Format ISO-8601:
            YYYY-MM-DD
        expiry_date (date): Expiry date of identification.  Format ISO-8601:
            YYYY-MM-DD
        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",
        "number": "number",
        "description": "description",
        "issuing_country": "issuingCountry",
        "issuing_authority": "issuingAuthority",
        "nationality": "nationality",
        "place_of_birth": "placeOfBirth",
        "issue_date": "issueDate",
        "expiry_date": "expiryDate",
    }

    _optionals = [
        "description",
        "issuing_country",
        "issuing_authority",
        "nationality",
        "place_of_birth",
        "issue_date",
        "expiry_date",
    ]

    def __init__(
        self,
        mtype=None,
        number=None,
        description=APIHelper.SKIP,
        issuing_country=APIHelper.SKIP,
        issuing_authority=APIHelper.SKIP,
        nationality=APIHelper.SKIP,
        place_of_birth=APIHelper.SKIP,
        issue_date=APIHelper.SKIP,
        expiry_date=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a IdentifyingDocument instance."""
        # Initialize members of the class
        self.mtype = mtype
        self.number = number
        if description is not APIHelper.SKIP:
            self.description = description
        if issuing_country is not APIHelper.SKIP:
            self.issuing_country = issuing_country
        if issuing_authority is not APIHelper.SKIP:
            self.issuing_authority = issuing_authority
        if nationality is not APIHelper.SKIP:
            self.nationality = nationality
        if place_of_birth is not APIHelper.SKIP:
            self.place_of_birth = place_of_birth
        if issue_date is not APIHelper.SKIP:
            self.issue_date = issue_date
        if expiry_date is not APIHelper.SKIP:
            self.expiry_date = expiry_date

        # 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
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else None
        number =\
            dictionary.get("number")\
            if dictionary.get("number")\
                else None
        description =\
            dictionary.get("description")\
            if dictionary.get("description")\
                else APIHelper.SKIP
        issuing_country =\
            dictionary.get("issuingCountry")\
            if dictionary.get("issuingCountry")\
                else APIHelper.SKIP
        issuing_authority =\
            dictionary.get("issuingAuthority")\
            if dictionary.get("issuingAuthority")\
                else APIHelper.SKIP
        nationality =\
            dictionary.get("nationality")\
            if dictionary.get("nationality")\
                else APIHelper.SKIP
        place_of_birth =\
            dictionary.get("placeOfBirth")\
            if dictionary.get("placeOfBirth")\
                else APIHelper.SKIP
        issue_date = dateutil.parser.parse(
            dictionary.get("issueDate")).date()\
            if dictionary.get("issueDate") else APIHelper.SKIP
        expiry_date = dateutil.parser.parse(
            dictionary.get("expiryDate")).date()\
            if dictionary.get("expiryDate") 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(mtype,
                   number,
                   description,
                   issuing_country,
                   issuing_authority,
                   nationality,
                   place_of_birth,
                   issue_date,
                   expiry_date,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=self.mtype
        _number=self.number
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _issuing_country=(
            self.issuing_country
            if hasattr(self, "issuing_country")
            else None
        )
        _issuing_authority=(
            self.issuing_authority
            if hasattr(self, "issuing_authority")
            else None
        )
        _nationality=(
            self.nationality
            if hasattr(self, "nationality")
            else None
        )
        _place_of_birth=(
            self.place_of_birth
            if hasattr(self, "place_of_birth")
            else None
        )
        _issue_date=(
            self.issue_date
            if hasattr(self, "issue_date")
            else None
        )
        _expiry_date=(
            self.expiry_date
            if hasattr(self, "expiry_date")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"number={_number!r}, "
            f"description={_description!r}, "
            f"issuing_country={_issuing_country!r}, "
            f"issuing_authority={_issuing_authority!r}, "
            f"nationality={_nationality!r}, "
            f"place_of_birth={_place_of_birth!r}, "
            f"issue_date={_issue_date!r}, "
            f"expiry_date={_expiry_date!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=self.mtype
        _number=self.number
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _issuing_country=(
            self.issuing_country
            if hasattr(self, "issuing_country")
            else None
        )
        _issuing_authority=(
            self.issuing_authority
            if hasattr(self, "issuing_authority")
            else None
        )
        _nationality=(
            self.nationality
            if hasattr(self, "nationality")
            else None
        )
        _place_of_birth=(
            self.place_of_birth
            if hasattr(self, "place_of_birth")
            else None
        )
        _issue_date=(
            self.issue_date
            if hasattr(self, "issue_date")
            else None
        )
        _expiry_date=(
            self.expiry_date
            if hasattr(self, "expiry_date")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"number={_number!s}, "
            f"description={_description!s}, "
            f"issuing_country={_issuing_country!s}, "
            f"issuing_authority={_issuing_authority!s}, "
            f"nationality={_nationality!s}, "
            f"place_of_birth={_place_of_birth!s}, "
            f"issue_date={_issue_date!s}, "
            f"expiry_date={_expiry_date!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
