"""visaacceptancemergedspec.

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

# ruff: noqa: E501
import dateutil.parser

from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.personal_identification_9 import (
    PersonalIdentification9,
)


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

    Attributes:
        company_tax_id (str): Company’s tax identifier. This is only used for eCheck
            service.
        currency (str): Currency used for the order. Use the three-character I[ISO
            Standard Currency Codes.](  For an authorization reversal
            (`reversalInformation`) or a capture (`processingOptions.capture` is set
            to `true`), you must use the same currency that you used in your payment
            authorization request.  #### DCC for First Data Your local currency. For
            details, see the `currency` field description in [Dynamic Currency
            Conversion For First Data Using the SCMP API]( # For details about
            currency as used in partial authorizations, see "Features for Debit Cards
            and Prepaid Cards" in the [Credit Card Services Using the SCMP API Guide](
        date_of_birth (date): Date of birth of the customer. Format: YYYY-MM-DD
        personal_identification (List[PersonalIdentification9]): The model property
            of type List[PersonalIdentification9].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "company_tax_id": "companyTaxID",
        "currency": "currency",
        "date_of_birth": "dateOfBirth",
        "personal_identification": "personalIdentification",
    }

    _optionals = [
        "company_tax_id",
        "currency",
        "date_of_birth",
        "personal_identification",
    ]

    def __init__(
        self,
        company_tax_id=APIHelper.SKIP,
        currency=APIHelper.SKIP,
        date_of_birth=APIHelper.SKIP,
        personal_identification=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a BuyerInformation13 instance."""
        # Initialize members of the class
        if company_tax_id is not APIHelper.SKIP:
            self.company_tax_id = company_tax_id
        if currency is not APIHelper.SKIP:
            self.currency = currency
        if date_of_birth is not APIHelper.SKIP:
            self.date_of_birth = date_of_birth
        if personal_identification is not APIHelper.SKIP:
            self.personal_identification = personal_identification

        # 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
        company_tax_id =\
            dictionary.get("companyTaxID")\
            if dictionary.get("companyTaxID")\
                else APIHelper.SKIP
        currency =\
            dictionary.get("currency")\
            if dictionary.get("currency")\
                else APIHelper.SKIP
        date_of_birth = dateutil.parser.parse(
            dictionary.get("dateOfBirth")).date()\
            if dictionary.get("dateOfBirth") else APIHelper.SKIP
        personal_identification = None
        if dictionary.get("personalIdentification") is not None:
            personal_identification = [
                PersonalIdentification9.from_dictionary(x)
                    for x in dictionary.get("personalIdentification")
            ]
        else:
            personal_identification = 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(company_tax_id,
                   currency,
                   date_of_birth,
                   personal_identification,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _company_tax_id=(
            self.company_tax_id
            if hasattr(self, "company_tax_id")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _date_of_birth=(
            self.date_of_birth
            if hasattr(self, "date_of_birth")
            else None
        )
        _personal_identification=(
            self.personal_identification
            if hasattr(self, "personal_identification")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"company_tax_id={_company_tax_id!r}, "
            f"currency={_currency!r}, "
            f"date_of_birth={_date_of_birth!r}, "
            f"personal_identification={_personal_identification!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _company_tax_id=(
            self.company_tax_id
            if hasattr(self, "company_tax_id")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _date_of_birth=(
            self.date_of_birth
            if hasattr(self, "date_of_birth")
            else None
        )
        _personal_identification=(
            self.personal_identification
            if hasattr(self, "personal_identification")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"company_tax_id={_company_tax_id!s}, "
            f"currency={_currency!s}, "
            f"date_of_birth={_date_of_birth!s}, "
            f"personal_identification={_personal_identification!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
