1"""Provide the SavableMixin class."""
2from ....const import API_PATH
3
4
5class SavableMixin(object):
6    """Interface for RedditBase classes that can be saved."""
7
8    def save(self, category=None):
9        """Save the object.
10
11        :param category: (Gold) The category to save to. If your user does not
12            have gold this value is ignored by Reddit (default: None).
13
14        Example usage:
15
16        .. code:: python
17
18           submission = reddit.submission(id='5or86n')
19           submission.save(category="view later")
20
21           comment = reddit.comment(id='dxolpyc')
22           comment.save()
23
24        See also :meth:`~.unsave`
25
26        """
27        self._reddit.post(
28            API_PATH["save"], data={"category": category, "id": self.fullname}
29        )
30
31    def unsave(self):
32        """Unsave the object.
33
34        Example usage:
35
36        .. code:: python
37
38           submission = reddit.submission(id='5or86n')
39           submission.unsave()
40
41           comment = reddit.comment(id='dxolpyc')
42           comment.unsave()
43
44        See also :meth:`~.save`
45
46        """
47        self._reddit.post(API_PATH["unsave"], data={"id": self.fullname})
48