# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
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):
        """Constructor for the Patch class"""

        # 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):
        """Creates 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 (f'{self.__class__.__name__}('
                f'op={self.op!r}, '
                f'path={(self.path if hasattr(self, "path") else None)!r}, '
                f'value={(self.value if hasattr(self, "value") else None)!r}, '
                f'mfrom={(self.mfrom if hasattr(self, "mfrom") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'op={self.op!s}, '
                f'path={(self.path if hasattr(self, "path") else None)!s}, '
                f'value={(self.value if hasattr(self, "value") else None)!s}, '
                f'mfrom={(self.mfrom if hasattr(self, "mfrom") else None)!s})')
