"""paypalserversdk.

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

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


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

    The JSON patch object to apply partial updates to resources.

    Attributes:
        op (PatchOp): The operation.
        path (str): The JSON Pointer to the target document location at which to
            complete the operation.
        value (Any): The value to apply. The remove, copy, and move operations do not
            require a value. Since JSON Patch allows any type for value, the type
            property is not specified.
        mfrom (str): The JSON Pointer to the target document location from which to
            move the value. Required for the move operation.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "op": "op",
        "path": "path",
        "value": "value",
        "mfrom": "from",
    }

    _optionals = [
        "path",
        "value",
        "mfrom",
    ]

    def __init__(
        self,
        op=None,
        path=APIHelper.SKIP,
        value=APIHelper.SKIP,
        mfrom=APIHelper.SKIP):
        """Initialize a Patch instance."""
        # Initialize members of the class
        self.op = op
        if path is not APIHelper.SKIP:
            self.path = path
        if value is not APIHelper.SKIP:
            self.value = value
        if mfrom is not APIHelper.SKIP:
            self.mfrom = mfrom

    @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
        op =\
            dictionary.get("op")\
            if dictionary.get("op")\
                else None
        path =\
            dictionary.get("path")\
            if dictionary.get("path")\
                else APIHelper.SKIP
        value =\
            dictionary.get("value")\
            if dictionary.get("value")\
                else APIHelper.SKIP
        mfrom =\
            dictionary.get("from")\
            if dictionary.get("from")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(op,
                   path,
                   value,
                   mfrom)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _op=self.op
        _path=(
            self.path
            if hasattr(self, "path")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _mfrom=(
            self.mfrom
            if hasattr(self, "mfrom")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"op={_op!r}, "
            f"path={_path!r}, "
            f"value={_value!r}, "
            f"mfrom={_mfrom!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _op=self.op
        _path=(
            self.path
            if hasattr(self, "path")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _mfrom=(
            self.mfrom
            if hasattr(self, "mfrom")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"op={_op!s}, "
            f"path={_path!s}, "
            f"value={_value!s}, "
            f"mfrom={_mfrom!s}, "
            f")"
        )
