From 7ca93a4c079f39e552d775c2f3c953fb257d74f8 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 12:23:08 -0500 Subject: [PATCH] Update and improve documentation for API.friends_ids Automatically use docstring for documentation Improve method and documentation order Add stringify_ids and count parameters to documentation Remove id parameter from documentation Improve parameter order in documentation Improve return type reference --- docs/api.rst | 14 ++------------ tweepy/api.py | 35 ++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 5197a18..9ff1448 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -115,6 +115,8 @@ Follow, search, and get users .. automethod:: API.followers +.. automethod:: API.friends_ids + User methods ------------ @@ -299,18 +301,6 @@ Friendship Methods :rtype: :class:`Relationship` object -.. method:: API.friends_ids(id/screen_name/user_id, [cursor]) - - Returns an array containing the IDs of users being followed by the specified - user. - - :param id: |uid| - :param screen_name: |screen_name| - :param user_id: |user_id| - :param cursor: |cursor| - :rtype: list of Integers - - Account Methods --------------- diff --git a/tweepy/api.py b/tweepy/api.py index 6b29132..5cb0413 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1434,6 +1434,30 @@ class API: ), **kwargs ) + @pagination(mode='cursor') + @payload('ids') + def friends_ids(self, **kwargs): + """friends_ids(*, user_id, screen_name, cursor, stringify_ids, count) + + Returns an array containing the IDs of users being followed by the + specified user. + + :param user_id: |user_id| + :param screen_name: |screen_name| + :param cursor: |cursor| + :param stringify_ids: Have IDs returned as strings instead + :param count: |count| + + :rtype: list of :class:`int` + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids + """ + return self.request( + 'GET', 'friends/ids', endpoint_parameters=( + 'user_id', 'screen_name', 'cursor', 'stringify_ids', 'count' + ), **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -1741,17 +1765,6 @@ class API: user_id=list_to_csv(user_id), **kwargs ) - @pagination(mode='cursor') - @payload('ids') - def friends_ids(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids - """ - return self.request( - 'GET', 'friends/ids', endpoint_parameters=( - 'user_id', 'screen_name', 'cursor', 'stringify_ids', 'count' - ), **kwargs - ) - @pagination(mode='cursor') @payload('user', list=True) def friends(self, **kwargs): -- 2.25.1