aboutsummaryrefslogtreecommitdiff
blob: ae891d5b99d8b132c5735731eaf50372193daa67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    
from .versions import _DICT_VERSION_STATUS, _DICT_VERSION_CARD, _DICT_VERSION_CONTEXT, _DICT_VERSION_ACCOUNT, _DICT_VERSION_SCHEDULED_STATUS
from .utility import api_version

from .internals import Mastodon as Internals


class Mastodon(Internals):    
    ###
    # Reading data: Statuses
    ###
    @api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
    def status(self, id):
        """
        Fetch information about a single toot.

        Does not require authentication for publicly visible statuses.

        Returns a :ref:`status dict <status dict>`.
        """
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}'.format(str(id))
        return self.__api_request('GET', url)

    @api_version("1.0.0", "3.0.0", _DICT_VERSION_CARD)
    def status_card(self, id):
        """
        Fetch a card associated with a status. A card describes an object (such as an
        external video or link) embedded into a status.

        Does not require authentication for publicly visible statuses.

        This function is deprecated as of 3.0.0 and the endpoint does not
        exist anymore - you should just use the "card" field of the status dicts
        instead. Mastodon.py will try to mimic the old behaviour, but this
        is somewhat inefficient and not guaranteed to be the case forever.

        Returns a :ref:`card dict <card dict>`.
        """
        if self.verify_minimum_version("3.0.0", cached=True):
            return self.status(id).card
        else:
            id = self.__unpack_id(id)
            url = '/api/v1/statuses/{0}/card'.format(str(id))
            return self.__api_request('GET', url)

    @api_version("1.0.0", "1.0.0", _DICT_VERSION_CONTEXT)
    def status_context(self, id):
        """
        Fetch information about ancestors and descendants of a toot.

        Does not require authentication for publicly visible statuses.

        Returns a :ref:`context dict <context dict>`.
        """
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}/context'.format(str(id))
        return self.__api_request('GET', url)

    @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
    def status_reblogged_by(self, id):
        """
        Fetch a list of users that have reblogged a status.

        Does not require authentication for publicly visible statuses.

        Returns a list of :ref:`account dicts <account dicts>`.
        """
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id))
        return self.__api_request('GET', url)

    @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
    def status_favourited_by(self, id):
        """
        Fetch a list of users that have favourited a status.

        Does not require authentication for publicly visible statuses.

        Returns a list of :ref:`account dicts <account dicts>`.
        """
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}/favourited_by'.format(str(id))
        return self.__api_request('GET', url)

    ###
    # Reading data: Scheduled statuses
    ###
    @api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
    def scheduled_statuses(self):
        """
        Fetch a list of scheduled statuses

        Returns a list of :ref:`scheduled status dicts <scheduled status dicts>`.
        """
        return self.__api_request('GET', '/api/v1/scheduled_statuses')

    @api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
    def scheduled_status(self, id):
        """
        Fetch information about the scheduled status with the given id.

        Returns a :ref:`scheduled status dict <scheduled status dict>`.
        """
        id = self.__unpack_id(id)
        url = '/api/v1/scheduled_statuses/{0}'.format(str(id))
        return self.__api_request('GET', url)
        
Powered by cgit v1.2.3 (git 2.41.0)