From: Harmon Date: Wed, 17 Nov 2021 13:38:45 +0000 (-0600) Subject: Add Client.get_space_buyers X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8bf58ca5754f72292d1d86367a02778af7a44f20;p=tweepy.git Add Client.get_space_buyers --- diff --git a/docs/client.rst b/docs/client.rst index c93b25c..bf0bc4b 100644 --- a/docs/client.rst +++ b/docs/client.rst @@ -118,10 +118,12 @@ +--------------------------------------------------------------+----------------------------------------+ | `GET /2/spaces`_ | :meth:`Client.get_spaces` | +--------------------------------------------------------------+----------------------------------------+ - | `GET /2/spaces/by/creator_ids`_ | :meth:`Client.get_spaces` | - +--------------------------------------------------------------+----------------------------------------+ | `GET /2/spaces/:id`_ | :meth:`Client.get_space` | +--------------------------------------------------------------+----------------------------------------+ + | `GET /2/spaces/:id/buyers`_ | :meth:`Client.get_space_buyers` | + +--------------------------------------------------------------+----------------------------------------+ + | `GET /2/spaces/by/creator_ids`_ | :meth:`Client.get_spaces` | + +--------------------------------------------------------------+----------------------------------------+ | .. centered:: :ref:`Lists` | +-------------------------------------------------------------------------------------------------------+ | .. centered:: |List Tweets lookup|_ | @@ -229,8 +231,9 @@ .. _GET /2/spaces/search: https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search .. |Spaces lookup| replace:: *Spaces lookup* .. _GET /2/spaces: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces -.. _GET /2/spaces/by/creator_ids: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids .. _GET /2/spaces/:id: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id +.. _GET /2/spaces/:id/buyers: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers +.. _GET /2/spaces/by/creator_ids: https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-by-creator-ids .. |List Tweets lookup| replace:: *List Tweets lookup* .. _GET /2/lists/:id/tweets: https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets .. |List follows| replace:: *List follows* @@ -382,6 +385,8 @@ Spaces lookup .. automethod:: Client.get_space +.. automethod:: Client.get_space_buyers + Lists ===== diff --git a/tests/test_client.py b/tests/test_client.py index eb3aa58..02ebed8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -154,6 +154,8 @@ class TweepyTestCase(unittest.TestCase): # https://twitter.com/TwitterSpaces/status/1436382283347283969 self.client.get_space(space_id) + # TODO: Test Client.get_space_buyers + @tape.use_cassette("test_get_list_tweets.yaml", serializer="yaml") def test_get_list_tweets(self): list_id = 84839422 # List ID for Official Twitter Accounts (@Twitter) diff --git a/tweepy/client.py b/tweepy/client.py index 1a05640..de689a6 100644 --- a/tweepy/client.py +++ b/tweepy/client.py @@ -1865,6 +1865,48 @@ class Client: ), data_type=Space ) + def get_space_buyers(self, id, **params): + """get_space_buyers(id, *, expansions, media_fields, place_fields, \ + poll_fields, tweet_fields, user_fields) + + Returns a list of user who purchased a ticket to the requested Space. + You must authenticate the request using the Access Token of the creator + of the requested Space. + + Parameters + ---------- + id : str + Unique identifier of the Space for which you want to request + Tweets. + expansions : Union[List[str], str] + :ref:`expansions_parameter` + media_fields : Union[List[str], str] + :ref:`media_fields_parameter` + place_fields : Union[List[str], str] + :ref:`place_fields_parameter` + poll_fields : Union[List[str], str] + :ref:`poll_fields_parameter` + tweet_fields : Union[List[str], str] + :ref:`tweet_fields_parameter` + user_fields : Union[List[str], str] + :ref:`user_fields_parameter` + + Returns + ------- + Union[dict, requests.Response, Response] + + References + ---------- + https://developer.twitter.com/en/docs/twitter-api/spaces/lookup/api-reference/get-spaces-id-buyers + """ + return self._make_request( + "GET", f"/2/spaces/{id}/buyers", params=params, + endpoint_parameters=( + "expansions", "media.fields", "place.fields", "poll.fields", + "tweet.fields", "user.fields" + ), data_type=User + ) + # List Tweets lookup def get_list_tweets(self, id, *, user_auth=False, **params):