"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.account import Account
from cellpointapi.models.complete_person_name import (
    CompletePersonName,
)


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

    Buyer information.

    Attributes:
        name (CompletePersonName): Full name of an individual.
        is_guest (bool): If the buyer is using a guest account. If `true`, then
            `account` should not be passed. `account` *must* be passed if this is
            `false`.
        account (Account): Account information for the buyer.
        merchant_customer_id (str): Identifier of the customer in the merchant's
            system.
        locale (str): Buyer's set locale.  A combined string using a combination of
            standards for a language description - the ISO 639-1 standard and a
            locale description - the ISO 3166 standard, which together make up the
            BCP-47 standard.
        country (str): Country of residence set by Buyer.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "is_guest": "isGuest",
        "merchant_customer_id": "merchantCustomerId",
        "name": "name",
        "account": "account",
        "locale": "locale",
        "country": "country",
    }

    _optionals = [
        "name",
        "account",
        "locale",
        "country",
    ]

    def __init__(
        self,
        is_guest=None,
        merchant_customer_id=None,
        name=APIHelper.SKIP,
        account=APIHelper.SKIP,
        locale=APIHelper.SKIP,
        country=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Buyer instance."""
        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name
        self.is_guest = is_guest
        if account is not APIHelper.SKIP:
            self.account = account
        self.merchant_customer_id = merchant_customer_id
        if locale is not APIHelper.SKIP:
            self.locale = locale
        if country is not APIHelper.SKIP:
            self.country = country

        # 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
        is_guest =\
            dictionary.get("isGuest")\
            if "isGuest" in dictionary.keys()\
                else None
        merchant_customer_id =\
            dictionary.get("merchantCustomerId")\
            if dictionary.get("merchantCustomerId")\
                else None
        name =\
            CompletePersonName.from_dictionary(
                dictionary.get("name"))\
                if "name" in dictionary.keys()\
                else APIHelper.SKIP
        account =\
            Account.from_dictionary(
                dictionary.get("account"))\
                if "account" in dictionary.keys()\
                else APIHelper.SKIP
        locale =\
            dictionary.get("locale")\
            if dictionary.get("locale")\
                else APIHelper.SKIP
        country =\
            dictionary.get("country")\
            if dictionary.get("country")\
                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(is_guest,
                   merchant_customer_id,
                   name,
                   account,
                   locale,
                   country,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _is_guest=self.is_guest
        _account=(
            self.account
            if hasattr(self, "account")
            else None
        )
        _merchant_customer_id=self.merchant_customer_id
        _locale=(
            self.locale
            if hasattr(self, "locale")
            else None
        )
        _country=(
            self.country
            if hasattr(self, "country")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"is_guest={_is_guest!r}, "
            f"account={_account!r}, "
            f"merchant_customer_id={_merchant_customer_id!r}, "
            f"locale={_locale!r}, "
            f"country={_country!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _is_guest=self.is_guest
        _account=(
            self.account
            if hasattr(self, "account")
            else None
        )
        _merchant_customer_id=self.merchant_customer_id
        _locale=(
            self.locale
            if hasattr(self, "locale")
            else None
        )
        _country=(
            self.country
            if hasattr(self, "country")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"is_guest={_is_guest!s}, "
            f"account={_account!s}, "
            f"merchant_customer_id={_merchant_customer_id!s}, "
            f"locale={_locale!s}, "
            f"country={_country!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
