"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper


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

    Attributes:
        minimum_digits (int): Minimum number of digits allowable for the card number.
        maximum_digits (int): Maximum number of digits allowable for the card number.
        visual_formats (Dict[str, str]): How the card number should be visually
            displayed for a given number of digits.  Example:    ```     "16":
            "4,4,4,4"   ```   Would say that for card numbers with 16 digts, show the
            numbers in 4,4,4,4 chunks.    So the number 1234123412341234 should show
            as:     1234-1234-1234-1234
        bin_ranges (str): Location of file to retrieve bin ranges for this card
            scheme.  These bin ranges can be used to identify the card.
        luhn_verifiable (bool): If numbers for this card scheme are verifiable using
            Luhn's algorithm or not.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "minimum_digits": "minimumDigits",
        "maximum_digits": "maximumDigits",
        "visual_formats": "visualFormats",
        "bin_ranges": "binRanges",
        "luhn_verifiable": "luhnVerifiable",
    }

    def __init__(
        self,
        minimum_digits=None,
        maximum_digits=None,
        visual_formats=None,
        bin_ranges=None,
        luhn_verifiable=None,
        additional_properties=None):
        """Initialize a CardNumber instance."""
        # Initialize members of the class
        self.minimum_digits = minimum_digits
        self.maximum_digits = maximum_digits
        self.visual_formats = visual_formats
        self.bin_ranges = bin_ranges
        self.luhn_verifiable = luhn_verifiable

        # 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
        minimum_digits =\
            dictionary.get("minimumDigits")\
            if dictionary.get("minimumDigits")\
                else None
        maximum_digits =\
            dictionary.get("maximumDigits")\
            if dictionary.get("maximumDigits")\
                else None
        visual_formats =\
            dictionary.get("visualFormats")\
            if dictionary.get("visualFormats")\
                else None
        bin_ranges =\
            dictionary.get("binRanges")\
            if dictionary.get("binRanges")\
                else None
        luhn_verifiable =\
            dictionary.get("luhnVerifiable")\
            if "luhnVerifiable" in dictionary.keys()\
                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(minimum_digits,
                   maximum_digits,
                   visual_formats,
                   bin_ranges,
                   luhn_verifiable,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _minimum_digits=self.minimum_digits
        _maximum_digits=self.maximum_digits
        _visual_formats=self.visual_formats
        _bin_ranges=self.bin_ranges
        _luhn_verifiable=self.luhn_verifiable
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"minimum_digits={_minimum_digits!r}, "
            f"maximum_digits={_maximum_digits!r}, "
            f"visual_formats={_visual_formats!r}, "
            f"bin_ranges={_bin_ranges!r}, "
            f"luhn_verifiable={_luhn_verifiable!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _minimum_digits=self.minimum_digits
        _maximum_digits=self.maximum_digits
        _visual_formats=self.visual_formats
        _bin_ranges=self.bin_ranges
        _luhn_verifiable=self.luhn_verifiable
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"minimum_digits={_minimum_digits!s}, "
            f"maximum_digits={_maximum_digits!s}, "
            f"visual_formats={_visual_formats!s}, "
            f"bin_ranges={_bin_ranges!s}, "
            f"luhn_verifiable={_luhn_verifiable!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
