"""visaacceptancemergedspec.

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

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


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

    Attributes:
        id (str): Unique identifier for the Instrument Identifier token used in the
            transaction. When you include this value in your request, many of the
            fields that can be supplied for an authorization or credit become
            optional.
        state (str): Issuers state for the card number. Valid values: - ACTIVE -
            CLOSED : The account has been closed.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "id",
        "state": "state",
    }

    _optionals = [
        "id",
        "state",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        state=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a InstrumentIdentifier2 instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if state is not APIHelper.SKIP:
            self.state = state

        # 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
        id =\
            dictionary.get("id")\
            if dictionary.get("id")\
                else APIHelper.SKIP
        state =\
            dictionary.get("state")\
            if dictionary.get("state")\
                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(id,
                   state,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _state=(
            self.state
            if hasattr(self, "state")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"state={_state!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _state=(
            self.state
            if hasattr(self, "state")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"state={_state!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
