From: Harmon Date: Mon, 25 Oct 2021 06:07:32 +0000 (-0500) Subject: Change state to optional parameter for Client.search_spaces X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e61d5d6f017db7f28871331b515fcfd87666f352;p=tweepy.git Change state to optional parameter for Client.search_spaces https://twitter.com/i_am_daniele/status/1443210956541100033 --- diff --git a/cassettes/test_search_spaces.yaml b/cassettes/test_search_spaces.yaml index e529a27..e449240 100644 --- a/cassettes/test_search_spaces.yaml +++ b/cassettes/test_search_spaces.yaml @@ -9,16 +9,18 @@ interactions: Connection: - keep-alive User-Agent: - - Python/3.9.7 Requests/2.25.1 Tweepy/4.0.1 + - Python/3.10.0 Requests/2.26.0 Tweepy/4.1.0 method: GET - uri: https://api.twitter.com/2/spaces/search?query=Twitter&state=live + uri: https://api.twitter.com/2/spaces/search?query=Twitter response: body: string: !!binary | - H4sIAAAAAAAAAHzQTwuCMBzG8ffyO3vpmDdHYzD/5Q5RRsRsY6jTdE7RxPdeHTqFXh8+8MB3BsEt - B/c6Qy7AhZ1qx0GXE1INQeBAZ7mVn13ng4TF+SnJaRZlBiUnel5XsfANwugQtv6GKgfaeKZqmmTE - 66oIqZIq0JXnB+uqqokUE6sjvPU41TROMT+yF2EbKiL8wiMtBSnWlWB+qouwbQ3973VzoJLfvDMY - 2fXa3h/Pvrbg7pflDQAA//8DAO2i+Rp6AQAA + H4sIAAAAAAAAAITTzY6CMBQF4Hfp2o3LYUcDIWmlFBYWmEwmYBtHoAUKCNX47vNjJtFE7fbmy1mc + e+8Z8GIsgPN+BgcOHLDOOlTnqd+7VVCBFRjGYhQ/8+ZwFOCy+lemxSEjdU8jFD9XoQpUDcWmJSiy + ZYUmm19labnQfS5VskfkuYIJqlSp3Yqh+blSLvazo3RphDc3ath9CT41gt/QrEdez1xD/WVroabD + 3E9k6x0DZqERRxpS08IGpRYq9SKLTsZlvRgLpQ2OC3aCucK+hV7bjDRRd20+omG2EFWWsKPLbKHX + XpkXl9Ze/6j0ibavwJCgyNom5f3dRT6ipx5voTHMmzG0UF4FKYUw92CQP6YfKyDF72+cgRbD1Iyf + u3ZSI3DWb5fLNwAAAP//AwD4ilhQOAMAAA== headers: api-version: - '2.27' @@ -29,24 +31,24 @@ interactions: content-encoding: - gzip content-length: - - '198' + - '310' content-type: - application/json; charset=utf-8 date: - - Mon, 04 Oct 2021 16:23:43 UTC + - Mon, 25 Oct 2021 06:05:06 UTC server: - tsa_b set-cookie: - - personalization_id="v1_Q5Y420A90rTxiUPNvjznYg=="; Max-Age=63072000; Expires=Wed, - 04 Oct 2023 16:23:43 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None - - guest_id=v1%3A163336462208298649; Max-Age=63072000; Expires=Wed, 04 Oct 2023 - 16:23:43 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - personalization_id="v1_ey7gLjGT35U1dYcYBdXMlA=="; Max-Age=63072000; Expires=Wed, + 25 Oct 2023 06:05:06 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + - guest_id=v1%3A163514190635179076; Max-Age=63072000; Expires=Wed, 25 Oct 2023 + 06:05:06 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None strict-transport-security: - max-age=631138519 x-access-level: - read x-connection-hash: - - ba8571db95a98d39f2a2ddeac9236e3648f62c3a289efe13ccf35ea85b5de519 + - 9727b9f1bb2444ec291fcfc73818fc175a3fa18685062c17dcc34db12f559700 x-content-type-options: - nosniff x-frame-options: @@ -54,9 +56,11 @@ interactions: x-rate-limit-limit: - '300' x-rate-limit-remaining: - - '289' + - '296' x-rate-limit-reset: - - '1633364956' + - '1635142463' + x-response-time: + - '336' x-xss-protection: - '0' status: diff --git a/tests/test_client.py b/tests/test_client.py index 9cdb390..4d6f99c 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -126,7 +126,7 @@ class TweepyTestCase(unittest.TestCase): @tape.use_cassette("test_search_spaces.yaml", serializer="yaml") def test_search_spaces(self): - self.client.search_spaces("Twitter", "live") + self.client.search_spaces("Twitter") @tape.use_cassette("test_get_spaces.yaml", serializer="yaml") def test_get_spaces(self): diff --git a/tweepy/client.py b/tweepy/client.py index d215c1d..1f2fda9 100644 --- a/tweepy/client.py +++ b/tweepy/client.py @@ -1549,9 +1549,9 @@ class Client: # Search Spaces - def search_spaces(self, query, state, **params): - """search_spaces(query, state, *, expansions, max_results, \ - space_fields, user_fields) + def search_spaces(self, query, **params): + """search_spaces(query, *, expansions, max_results, space_fields, \ + state, user_fields) Return live or scheduled Spaces matching your specified search terms @@ -1560,9 +1560,6 @@ class Client: query : str Your search term. This can be any text (including mentions and Hashtags) present in the title of the Space. - state : str - Determines the type of results to return. Use ``live`` to return - live Spaces or ``scheduled`` to return upcoming Spaces. expansions : Union[List[str], str] :ref:`expansions_parameter` max_results : int @@ -1570,6 +1567,10 @@ class Client: value between 1 and 100. space_fields : Union[List[str], str] :ref:`space_fields_parameter` + state : str + Determines the type of results to return. This endpoint returns all + Spaces by default. Use ``live`` to only return live Spaces or + ``scheduled`` to only return upcoming Spaces. user_fields : Union[List[str], str] :ref:`user_fields_parameter` @@ -1582,11 +1583,10 @@ class Client: https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search """ params["query"] = query - params["state"] = state return self._make_request( "GET", "/2/spaces/search", params=params, endpoint_parameters=( - "query", "state", "expansions", "max_results", "space.fields", + "query", "expansions", "max_results", "space.fields", "state", "user.fields" ), data_type=Space )