"""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.card_scheme_configuration import (
    CardSchemeConfiguration,
)


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

    Credit/Debit Card Payment Method that involves a card number (PAN), expiry, and
    security code.

    Attributes:
        supported_schemes (List[CardSchemeConfiguration]): Card Schemes supported for
            payment
        required_fields (List[PaymentField]): Required fields for processing a card
            payment
        max_splits (int): Maximum number of cards that the payment for the entire
            order can be split across
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "supported_schemes": "supportedSchemes",
        "required_fields": "requiredFields",
        "max_splits": "maxSplits",
    }

    def __init__(
        self,
        supported_schemes=None,
        required_fields=None,
        max_splits=None,
        additional_properties=None):
        """Initialize a CardConfig instance."""
        # Initialize members of the class
        self.supported_schemes = supported_schemes
        self.required_fields = required_fields
        self.max_splits = max_splits

        # 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
        supported_schemes = None
        if dictionary.get("supportedSchemes") is not None:
            supported_schemes = [
                CardSchemeConfiguration.from_dictionary(x)
                    for x in dictionary.get("supportedSchemes")
            ]
        required_fields =\
            dictionary.get("requiredFields")\
            if dictionary.get("requiredFields")\
                else None
        max_splits =\
            dictionary.get("maxSplits")\
            if dictionary.get("maxSplits")\
                else None

        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(supported_schemes,
                   required_fields,
                   max_splits,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _supported_schemes=self.supported_schemes
        _required_fields=self.required_fields
        _max_splits=self.max_splits
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"supported_schemes={_supported_schemes!r}, "
            f"required_fields={_required_fields!r}, "
            f"max_splits={_max_splits!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _supported_schemes=self.supported_schemes
        _required_fields=self.required_fields
        _max_splits=self.max_splits
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"supported_schemes={_supported_schemes!s}, "
            f"required_fields={_required_fields!s}, "
            f"max_splits={_max_splits!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
