"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.personal_identification_2 import (
    PersonalIdentification2,
)


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

    Attributes:
        merchant_customer_id (str): Your identifier for the customer.  When a
            subscription or customer profile is being created, the maximum length for
            this field for most processors is 30. Otherwise, the maximum length is
            100.  #### Comercio Latino For recurring payments in Mexico, the value is
            the customer’s contract number. Note Before you request the
            authorization, you must inform the issuer of the customer contract
            numbers that will be used for recurring transactions.  #### Worldpay VAP
            For a follow-on credit with Worldpay VAP, Visa Acceptance checks the
            following locations, in the order given, for a customer account ID value
            and uses the first value it finds: 1. `customer_account_id` value in the
            follow-on credit request 2. Customer account ID value that was used for
            the capture that is being credited 3. Customer account ID value that was
            used for the original authorization If a customer account ID value cannot
            be found in any of these locations, then no value is used.
        vat_registration_number (str): Customer’s government-assigned tax
            identification number.  #### Tax Calculation Optional for international
            and value added taxes only. Not applicable to U.S. and Canadian taxes.
        date_of_birth (str): Recipient’s date of birth. **Format**: `YYYYMMDD`.  This
            field is a `pass-through`, which means that Visa Acceptance ensures that
            the value is eight numeric characters but otherwise does not verify the
            value or modify it in any way before sending it to the processor. If the
            field is not required for the transaction, Visa Acceptance does not
            forward it to the processor.
        gender (str): Customer's gender. Possible values are F (female), M (male),O
            (other).
        language (str): language setting of the user.  Supports 2-character language
            codes (e.g., en, fr) and 5-character locale values (e.g., en-US, fr-CA).
        personal_identification (List[PersonalIdentification2]): The model property
            of type List[PersonalIdentification2].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "merchant_customer_id": "merchantCustomerId",
        "vat_registration_number": "vatRegistrationNumber",
        "date_of_birth": "dateOfBirth",
        "gender": "gender",
        "language": "language",
        "personal_identification": "personalIdentification",
    }

    _optionals = [
        "merchant_customer_id",
        "vat_registration_number",
        "date_of_birth",
        "gender",
        "language",
        "personal_identification",
    ]

    def __init__(
        self,
        merchant_customer_id=APIHelper.SKIP,
        vat_registration_number=APIHelper.SKIP,
        date_of_birth=APIHelper.SKIP,
        gender=APIHelper.SKIP,
        language=APIHelper.SKIP,
        personal_identification=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a BuyerInformation2 instance."""
        # Initialize members of the class
        if merchant_customer_id is not APIHelper.SKIP:
            self.merchant_customer_id = merchant_customer_id
        if vat_registration_number is not APIHelper.SKIP:
            self.vat_registration_number = vat_registration_number
        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 language is not APIHelper.SKIP:
            self.language = language
        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
        merchant_customer_id =\
            dictionary.get("merchantCustomerId")\
            if dictionary.get("merchantCustomerId")\
                else APIHelper.SKIP
        vat_registration_number =\
            dictionary.get("vatRegistrationNumber")\
            if dictionary.get("vatRegistrationNumber")\
                else APIHelper.SKIP
        date_of_birth =\
            dictionary.get("dateOfBirth")\
            if dictionary.get("dateOfBirth")\
                else APIHelper.SKIP
        gender =\
            dictionary.get("gender")\
            if dictionary.get("gender")\
                else APIHelper.SKIP
        language =\
            dictionary.get("language")\
            if dictionary.get("language")\
                else APIHelper.SKIP
        personal_identification = None
        if dictionary.get("personalIdentification") is not None:
            personal_identification = [
                PersonalIdentification2.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(merchant_customer_id,
                   vat_registration_number,
                   date_of_birth,
                   gender,
                   language,
                   personal_identification,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _merchant_customer_id=(
            self.merchant_customer_id
            if hasattr(self, "merchant_customer_id")
            else None
        )
        _vat_registration_number=(
            self.vat_registration_number
            if hasattr(self, "vat_registration_number")
            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
        )
        _language=(
            self.language
            if hasattr(self, "language")
            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"merchant_customer_id={_merchant_customer_id!r}, "
            f"vat_registration_number={_vat_registration_number!r}, "
            f"date_of_birth={_date_of_birth!r}, "
            f"gender={_gender!r}, "
            f"language={_language!r}, "
            f"personal_identification={_personal_identification!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _merchant_customer_id=(
            self.merchant_customer_id
            if hasattr(self, "merchant_customer_id")
            else None
        )
        _vat_registration_number=(
            self.vat_registration_number
            if hasattr(self, "vat_registration_number")
            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
        )
        _language=(
            self.language
            if hasattr(self, "language")
            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"merchant_customer_id={_merchant_customer_id!s}, "
            f"vat_registration_number={_vat_registration_number!s}, "
            f"date_of_birth={_date_of_birth!s}, "
            f"gender={_gender!s}, "
            f"language={_language!s}, "
            f"personal_identification={_personal_identification!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
