From abdfc871d0ce9c96fffb189333d0a5bef570c475 Mon Sep 17 00:00:00 2001 From: Andrei Kostakov Date: Mon, 10 Jun 2024 22:15:22 +0300 Subject: [PATCH] Fix base url according to official documentation (#1485) Co-authored-by: William Bergamin --- slack/web/async_base_client.py | 2 +- slack/web/async_internal_utils.py | 2 +- slack/web/base_client.py | 2 +- slack_sdk/rtm/__init__.py | 2 +- slack_sdk/web/async_base_client.py | 4 ++-- slack_sdk/web/async_client.py | 2 +- slack_sdk/web/base_client.py | 8 ++++---- slack_sdk/web/client.py | 2 +- slack_sdk/web/internal_utils.py | 2 +- slack_sdk/web/legacy_base_client.py | 8 ++++---- slack_sdk/web/legacy_client.py | 2 +- tests/rtm/test_rtm_client_v2.py | 2 +- tests/slack_sdk/rtm_v2/test_rtm_v2.py | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/slack/web/async_base_client.py b/slack/web/async_base_client.py index 9347bac71..c0cc3f962 100644 --- a/slack/web/async_base_client.py +++ b/slack/web/async_base_client.py @@ -17,7 +17,7 @@ class AsyncBaseClient: - BASE_URL = "https://www.slack.com/api/" + BASE_URL = "https://slack.com/api/" def __init__( self, diff --git a/slack/web/async_internal_utils.py b/slack/web/async_internal_utils.py index 79291571e..10c6c2fdf 100644 --- a/slack/web/async_internal_utils.py +++ b/slack/web/async_internal_utils.py @@ -32,7 +32,7 @@ def _get_url(base_url: str, api_method: str) -> str: Returns: The absolute API URL. - e.g. 'https://www.slack.com/api/chat.postMessage' + e.g. 'https://slack.com/api/chat.postMessage' """ return urljoin(base_url, api_method) diff --git a/slack/web/base_client.py b/slack/web/base_client.py index a5b435669..dc52a9915 100644 --- a/slack/web/base_client.py +++ b/slack/web/base_client.py @@ -37,7 +37,7 @@ class BaseClient: - BASE_URL = "https://www.slack.com/api/" + BASE_URL = "https://slack.com/api/" def __init__( self, diff --git a/slack_sdk/rtm/__init__.py b/slack_sdk/rtm/__init__.py index dcfb1100d..36430533d 100644 --- a/slack_sdk/rtm/__init__.py +++ b/slack_sdk/rtm/__init__.py @@ -48,7 +48,7 @@ class RTMClient(object): # skipcq: PYL-R0205 Default is 30. base_url (str): The base url for all HTTP requests. Note: This is only used in the WebClient. - Default is "https://www.slack.com/api/". + Default is "https://slack.com/api/". connect_method (str): An string specifying if the client will connect with `rtm.connect` or `rtm.start`. Default is `rtm.connect`. diff --git a/slack_sdk/web/async_base_client.py b/slack_sdk/web/async_base_client.py index a33f287ce..2418b08c3 100644 --- a/slack_sdk/web/async_base_client.py +++ b/slack_sdk/web/async_base_client.py @@ -25,7 +25,7 @@ class AsyncBaseClient: - BASE_URL = "https://www.slack.com/api/" + BASE_URL = "https://slack.com/api/" def __init__( self, @@ -48,7 +48,7 @@ def __init__( """A string specifying an `xoxp-*` or `xoxb-*` token.""" self.base_url = base_url """A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'`.""" + Default is `'https://slack.com/api/'`.""" self.timeout = timeout """The maximum number of seconds the client will wait to connect and receive a response from Slack. diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py index 4fcf7bb94..bd2b3a71b 100644 --- a/slack_sdk/web/async_client.py +++ b/slack_sdk/web/async_client.py @@ -45,7 +45,7 @@ class AsyncWebClient(AsyncBaseClient): Attributes: token (str): A string specifying an `xoxp-*` or `xoxb-*` token. base_url (str): A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'` + Default is `'https://slack.com/api/'` timeout (int): The maximum number of seconds the client will wait to connect and receive a response from Slack. Default is 30 seconds. diff --git a/slack_sdk/web/base_client.py b/slack_sdk/web/base_client.py index 4c24fa3f6..e112d35c8 100644 --- a/slack_sdk/web/base_client.py +++ b/slack_sdk/web/base_client.py @@ -40,7 +40,7 @@ class BaseClient: - BASE_URL = "https://www.slack.com/api/" + BASE_URL = "https://slack.com/api/" def __init__( self, @@ -61,7 +61,7 @@ def __init__( """A string specifying an `xoxp-*` or `xoxb-*` token.""" self.base_url = base_url """A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'`.""" + Default is `'https://slack.com/api/'`.""" self.timeout = timeout """The maximum number of seconds the client will wait to connect and receive a response from Slack. @@ -225,7 +225,7 @@ def _urllib_api_call( Args: token: Slack API Token (either bot token or user token) - url: Complete URL (e.g., https://www.slack.com/api/chat.postMessage) + url: Complete URL (e.g., https://slack.com/api/chat.postMessage) query_params: Query string json_body: JSON data structure (it's still a dict at this point), if you give this argument, body_params and files will be skipped @@ -326,7 +326,7 @@ def _perform_urllib_http_request(self, *, url: str, args: Dict[str, Dict[str, An """Performs an HTTP request and parses the response. Args: - url: Complete URL (e.g., https://www.slack.com/api/chat.postMessage) + url: Complete URL (e.g., https://slack.com/api/chat.postMessage) args: args has "headers", "data", "params", and "json" "headers": Dict[str, str] "data": Dict[str, Any] diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py index 074dca035..c8fddf238 100644 --- a/slack_sdk/web/client.py +++ b/slack_sdk/web/client.py @@ -36,7 +36,7 @@ class WebClient(BaseClient): Attributes: token (str): A string specifying an `xoxp-*` or `xoxb-*` token. base_url (str): A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'` + Default is `'https://slack.com/api/'` timeout (int): The maximum number of seconds the client will wait to connect and receive a response from Slack. Default is 30 seconds. diff --git a/slack_sdk/web/internal_utils.py b/slack_sdk/web/internal_utils.py index 98cad3cc9..56604041c 100644 --- a/slack_sdk/web/internal_utils.py +++ b/slack_sdk/web/internal_utils.py @@ -65,7 +65,7 @@ def _get_url(base_url: str, api_method: str) -> str: Returns: The absolute API URL. - e.g. 'https://www.slack.com/api/chat.postMessage' + e.g. 'https://slack.com/api/chat.postMessage' """ return urljoin(base_url, api_method) diff --git a/slack_sdk/web/legacy_base_client.py b/slack_sdk/web/legacy_base_client.py index 1efd26440..c58e062a1 100644 --- a/slack_sdk/web/legacy_base_client.py +++ b/slack_sdk/web/legacy_base_client.py @@ -40,7 +40,7 @@ class LegacyBaseClient: - BASE_URL = "https://www.slack.com/api/" + BASE_URL = "https://slack.com/api/" def __init__( self, @@ -64,7 +64,7 @@ def __init__( """A string specifying an `xoxp-*` or `xoxb-*` token.""" self.base_url = base_url """A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'`.""" + Default is `'https://slack.com/api/'`.""" self.timeout = timeout """The maximum number of seconds the client will wait to connect and receive a response from Slack. @@ -300,7 +300,7 @@ def _urllib_api_call( Args: token: Slack API Token (either bot token or user token) - url: Complete URL (e.g., https://www.slack.com/api/chat.postMessage) + url: Complete URL (e.g., https://slack.com/api/chat.postMessage) query_params: Query string json_body: JSON data structure (it's still a dict at this point), if you give this argument, body_params and files will be skipped @@ -400,7 +400,7 @@ def _perform_urllib_http_request(self, *, url: str, args: Dict[str, Dict[str, An """Performs an HTTP request and parses the response. Args: - url: Complete URL (e.g., https://www.slack.com/api/chat.postMessage) + url: Complete URL (e.g., https://slack.com/api/chat.postMessage) args: args has "headers", "data", "params", and "json" "headers": Dict[str, str] "data": Dict[str, Any] diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py index 78c5d0fd9..e77f57e1a 100644 --- a/slack_sdk/web/legacy_client.py +++ b/slack_sdk/web/legacy_client.py @@ -47,7 +47,7 @@ class LegacyWebClient(LegacyBaseClient): Attributes: token (str): A string specifying an `xoxp-*` or `xoxb-*` token. base_url (str): A string representing the Slack API base URL. - Default is `'https://www.slack.com/api/'` + Default is `'https://slack.com/api/'` timeout (int): The maximum number of seconds the client will wait to connect and receive a response from Slack. Default is 30 seconds. diff --git a/tests/rtm/test_rtm_client_v2.py b/tests/rtm/test_rtm_client_v2.py index a402ea269..5f1a34bf5 100644 --- a/tests/rtm/test_rtm_client_v2.py +++ b/tests/rtm/test_rtm_client_v2.py @@ -93,7 +93,7 @@ def test_start_raises_an_error_if_rtm_ws_url_is_not_returned(self): RTMClient(token="xoxp-1234", auto_reconnect_enabled=False).start() expected_error = ( - "The request to the Slack API failed. (url: https://www.slack.com/api/auth.test)\n" + "The request to the Slack API failed. (url: https://slack.com/api/auth.test)\n" "The server responded with: {'ok': False, 'error': 'invalid_auth'}" ) self.assertIn(expected_error, str(context.exception)) diff --git a/tests/slack_sdk/rtm_v2/test_rtm_v2.py b/tests/slack_sdk/rtm_v2/test_rtm_v2.py index 0fc970ec4..e2d290fd4 100644 --- a/tests/slack_sdk/rtm_v2/test_rtm_v2.py +++ b/tests/slack_sdk/rtm_v2/test_rtm_v2.py @@ -93,7 +93,7 @@ def test_start_raises_an_error_if_rtm_ws_url_is_not_returned(self): RTMClient(token="xoxp-1234", auto_reconnect_enabled=False).start() expected_error = ( - "The request to the Slack API failed. (url: https://www.slack.com/api/auth.test)\n" + "The request to the Slack API failed. (url: https://slack.com/api/auth.test)\n" "The server responded with: {'ok': False, 'error': 'invalid_auth'}" ) self.assertIn(expected_error, str(context.exception))