"""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.non_negative_amount import (
    NonNegativeAmount,
)


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

    Contains the request object that is being sent on manual captures

    Attributes:
        capture_amount (NonNegativeAmount): An amount that is a nonnegative number,
            i.e. {0, 1, 2, 3, 4, 5,…}
        note (str): Optional note to be added to the transaction.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "capture_amount": "captureAmount",
        "note": "note",
    }

    _optionals = [
        "note",
    ]

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

        # 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
        capture_amount =\
            NonNegativeAmount.from_dictionary(
                dictionary.get("captureAmount"))\
                if dictionary.get("captureAmount") else None
        note =\
            dictionary.get("note")\
            if dictionary.get("note")\
                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(capture_amount,
                   note,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _capture_amount=self.capture_amount
        _note=(
            self.note
            if hasattr(self, "note")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"capture_amount={_capture_amount!r}, "
            f"note={_note!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _capture_amount=self.capture_amount
        _note=(
            self.note
            if hasattr(self, "note")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"capture_amount={_capture_amount!s}, "
            f"note={_note!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
