diff options
-rw-r--r-- | docs/02_return_values.rst | 52 | ||||
-rw-r--r-- | mastodon/internals.py | 7 |
2 files changed, 49 insertions, 10 deletions
diff --git a/docs/02_return_values.rst b/docs/02_return_values.rst index 9cc1e77..94d2943 100644 --- a/docs/02_return_values.rst +++ b/docs/02_return_values.rst | |||
@@ -24,6 +24,10 @@ you can also just write | |||
24 | and everything will work as intended. The class used for this is exposed as | 24 | and everything will work as intended. The class used for this is exposed as |
25 | `AttribAccessDict`. | 25 | `AttribAccessDict`. |
26 | 26 | ||
27 | Currently, some of these may be out of date - refer to the Mastodon documentation at | ||
28 | https://docs.joinmastodon.org/entities/ for when fields seem to be missing. This will | ||
29 | be addressed in the next version of Mastodon.py. | ||
30 | |||
27 | User / account dicts | 31 | User / account dicts |
28 | -------------------- | 32 | -------------------- |
29 | .. _user dict: | 33 | .. _user dict: |
@@ -133,7 +137,13 @@ Status edit dicts | |||
133 | mastodonstatus_history(id)[0] | 137 | mastodonstatus_history(id)[0] |
134 | # Returns the following dictionary | 138 | # Returns the following dictionary |
135 | { | 139 | { |
136 | TODO | 140 | 'content': # Content for this version of the status |
141 | 'spoiler_text': # CW / Spoiler text for this version of the status | ||
142 | 'sensitive': # Whether media in this version of the status is marked as sensitive | ||
143 | 'created_at': # Time at which this version of the status was posted | ||
144 | 'account': # Account dict of the user that posted the status | ||
145 | 'media_attachments': # List of media dicts with the attached media for this version of the status | ||
146 | 'emojis'# List of emoji dicts for this version of the status | ||
137 | } | 147 | } |
138 | 148 | ||
139 | Mention dicts | 149 | Mention dicts |
@@ -658,7 +668,8 @@ Familiar follower dicts | |||
658 | mastodon.account_familiar_followers(1)[0] | 668 | mastodon.account_familiar_followers(1)[0] |
659 | # Returns the following dictionary: | 669 | # Returns the following dictionary: |
660 | { | 670 | { |
661 | 671 | 'id': # ID of the account for which the familiar followers are being returned | |
672 | 'accounts': # List of account dicts of the familiar followers | ||
662 | } | 673 | } |
663 | 674 | ||
664 | Admin account dicts | 675 | Admin account dicts |
@@ -683,7 +694,7 @@ Admin account dicts | |||
683 | 'disabled': # For local users, boolean indicating whether the user has had their login disabled | 694 | 'disabled': # For local users, boolean indicating whether the user has had their login disabled |
684 | 'approved': # For local users, False if the user is pending, True otherwise | 695 | 'approved': # For local users, False if the user is pending, True otherwise |
685 | 'locale': # For local users, the locale the user has set, | 696 | 'locale': # For local users, the locale the user has set, |
686 | 'invite_request': # If the user requested an invite, the invite request comment of that user. (TODO permanent?) | 697 | 'invite_request': # If the user requested an invite, the invite request comment of that user. |
687 | 'invited_by_account_id': # Present if the user was invited by another user and set to the inviting users id. | 698 | 'invited_by_account_id': # Present if the user was invited by another user and set to the inviting users id. |
688 | 'account': # The user's account, as a standard user dict | 699 | 'account': # The user's account, as a standard user dict |
689 | } | 700 | } |
@@ -717,7 +728,17 @@ Admin measure dicts | |||
717 | api.admin_measures(datetime.now() - timedelta(hours=24*5), datetime.now(), active_users=True) | 728 | api.admin_measures(datetime.now() - timedelta(hours=24*5), datetime.now(), active_users=True) |
718 | # Returns the following dictionary | 729 | # Returns the following dictionary |
719 | { | 730 | { |
720 | TODO | 731 | 'key': # Name of the measure returned |
732 | 'unit': # Unit for the measure, if available | ||
733 | 'total': # Value of the measure returned | ||
734 | 'human_value': # Human readable variant of the measure returned | ||
735 | 'data': # A list of dicts with the measure broken down by date, as below | ||
736 | } | ||
737 | |||
738 | # The data dicts: | ||
739 | [ | ||
740 | 'date': # Date for this row | ||
741 | 'value': # Value of the measure for this row | ||
721 | } | 742 | } |
722 | 743 | ||
723 | Admin dimension dicts | 744 | Admin dimension dicts |
@@ -729,9 +750,16 @@ Admin dimension dicts | |||
729 | api.admin_dimensions(datetime.now() - timedelta(hours=24*5), datetime.now(), languages=True) | 750 | api.admin_dimensions(datetime.now() - timedelta(hours=24*5), datetime.now(), languages=True) |
730 | # Returns the following dictionary | 751 | # Returns the following dictionary |
731 | { | 752 | { |
732 | TODO | 753 | 'key': # Name of the dimension returned |
754 | 'data': # A list of data dicts, as below | ||
733 | } | 755 | } |
734 | 756 | ||
757 | # the data dicts: | ||
758 | { | ||
759 | 'key': # category for this row | ||
760 | 'human_key': # Human readable name for the category for this row, when available | ||
761 | 'value': # Numeric value for the category | ||
762 | }, | ||
735 | Admin retention dicts | 763 | Admin retention dicts |
736 | --------------------- | 764 | --------------------- |
737 | .. _admin retention dict: | 765 | .. _admin retention dict: |
@@ -741,5 +769,15 @@ Admin retention dicts | |||
741 | api.admin_retention(datetime.now() - timedelta(hours=24*5), datetime.now()) | 769 | api.admin_retention(datetime.now() - timedelta(hours=24*5), datetime.now()) |
742 | # Returns the following dictionary | 770 | # Returns the following dictionary |
743 | { | 771 | { |
744 | TODO | 772 | 'period': # Starting time of the period that the data is being returned for |
773 | 'frequency': # Time resolution (day or month) for the returned data | ||
774 | 'data': # List of data dicts, as below | ||
775 | } | ||
776 | |||
777 | # the data dicts: | ||
778 | { | ||
779 | 'date': # Date for this entry | ||
780 | 'rate': # Fraction of users retained | ||
781 | 'value': # Absolute number of users retained | ||
745 | } | 782 | } |
783 | \ No newline at end of file | ||
diff --git a/mastodon/internals.py b/mastodon/internals.py index aa82553..758a1d4 100644 --- a/mastodon/internals.py +++ b/mastodon/internals.py | |||
@@ -62,7 +62,7 @@ class Mastodon(): | |||
62 | Parse dates in certain known json fields, if possible. | 62 | Parse dates in certain known json fields, if possible. |
63 | """ | 63 | """ |
64 | known_date_fields = ["created_at", "week", "day", "expires_at", "scheduled_at", | 64 | known_date_fields = ["created_at", "week", "day", "expires_at", "scheduled_at", |
65 | "updated_at", "last_status_at", "starts_at", "ends_at", "published_at", "edited_at"] | 65 | "updated_at", "last_status_at", "starts_at", "ends_at", "published_at", "edited_at", "date", "period"] |
66 | mark_delete = [] | 66 | mark_delete = [] |
67 | for k, v in json_object.items(): | 67 | for k, v in json_object.items(): |
68 | if k in known_date_fields: | 68 | if k in known_date_fields: |
@@ -85,7 +85,7 @@ class Mastodon(): | |||
85 | """ | 85 | """ |
86 | Parse 'True' / 'False' strings in certain known fields | 86 | Parse 'True' / 'False' strings in certain known fields |
87 | """ | 87 | """ |
88 | for key in ('follow', 'favourite', 'reblog', 'mention'): | 88 | for key in ('follow', 'favourite', 'reblog', 'mention', 'confirmed', 'suspended', 'silenced', 'disabled', 'approved', 'all_day'): |
89 | if (key in json_object and isinstance(json_object[key], six.text_type)): | 89 | if (key in json_object and isinstance(json_object[key], six.text_type)): |
90 | if json_object[key].lower() == 'true': | 90 | if json_object[key].lower() == 'true': |
91 | json_object[key] = True | 91 | json_object[key] = True |
@@ -98,7 +98,8 @@ class Mastodon(): | |||
98 | """ | 98 | """ |
99 | Converts json string numerals to native python bignums. | 99 | Converts json string numerals to native python bignums. |
100 | """ | 100 | """ |
101 | for key in ('id', 'week', 'in_reply_to_id', 'in_reply_to_account_id', 'logins', 'registrations', 'statuses', 'day', 'last_read_id'): | 101 | for key in ('id', 'week', 'in_reply_to_id', 'in_reply_to_account_id', 'logins', 'registrations', 'statuses', |
102 | 'day', 'last_read_id', 'value', 'frequency', 'rate', 'invited_by_account_id', 'count'): | ||
102 | if (key in json_object and isinstance(json_object[key], six.text_type)): | 103 | if (key in json_object and isinstance(json_object[key], six.text_type)): |
103 | try: | 104 | try: |
104 | json_object[key] = int(json_object[key]) | 105 | json_object[key] = int(json_object[key]) |