Skip to content

Commit 4e0f862

Browse files
committed
Add public_channel type support for admin.analytics.getFile API
1 parent 57716b7 commit 4e0f862

4 files changed

Lines changed: 97 additions & 13 deletions

File tree

integration_tests/web/test_admin_analytics.py

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ def setUp(self):
2727
def tearDown(self):
2828
pass
2929

30-
def test_legacy(self):
31-
client = self.legacy_client
32-
33-
response = client.admin_analytics_getFile(date="2020-10-20", type="member")
34-
self.assertTrue(isinstance(response.data, bytes))
35-
self.assertIsNotNone(response.data)
36-
3730
def test_sync(self):
3831
client = self.sync_client
3932

@@ -50,6 +43,24 @@ def test_sync_error(self):
5043
self.assertFalse(e.response["ok"])
5144
self.assertEqual("file_not_yet_available", e.response["error"])
5245

46+
def test_sync_public_channel(self):
47+
client = self.sync_client
48+
49+
response = client.admin_analytics_getFile(
50+
date="2020-10-20", type="public_channel"
51+
)
52+
self.assertTrue(isinstance(response.data, bytes))
53+
self.assertIsNotNone(response.data)
54+
55+
def test_sync_public_channel_medata_only(self):
56+
client = self.sync_client
57+
58+
response = client.admin_analytics_getFile(
59+
type="public_channel", metadata_only=True
60+
)
61+
self.assertTrue(isinstance(response.data, bytes))
62+
self.assertIsNotNone(response.data)
63+
5364
@async_test
5465
async def test_async(self):
5566
client = self.async_client
@@ -69,3 +80,49 @@ async def test_async_error(self):
6980
except SlackApiError as e:
7081
self.assertFalse(e.response["ok"])
7182
self.assertEqual("file_not_yet_available", e.response["error"])
83+
84+
@async_test
85+
async def test_async_public_channel(self):
86+
client = self.async_client
87+
88+
response = await client.admin_analytics_getFile(
89+
date="2020-10-20", type="public_channel"
90+
)
91+
self.assertTrue(isinstance(response.data, bytes))
92+
self.assertIsNotNone(response.data)
93+
94+
@async_test
95+
async def test_async_public_channel_metadata_only(self):
96+
client = self.async_client
97+
98+
response = await client.admin_analytics_getFile(
99+
type="public_channel",
100+
metadata_only=True,
101+
)
102+
self.assertTrue(isinstance(response.data, bytes))
103+
self.assertIsNotNone(response.data)
104+
105+
def test_legacy(self):
106+
client = self.legacy_client
107+
108+
response = client.admin_analytics_getFile(date="2020-10-20", type="member")
109+
self.assertTrue(isinstance(response.data, bytes))
110+
self.assertIsNotNone(response.data)
111+
112+
def test_legacy_public_channel(self):
113+
client = self.legacy_client
114+
115+
response = client.admin_analytics_getFile(
116+
date="2020-10-20", type="public_channel"
117+
)
118+
self.assertTrue(isinstance(response.data, bytes))
119+
self.assertIsNotNone(response.data)
120+
121+
def test_legacy_public_channel_metadata_only(self):
122+
client = self.legacy_client
123+
124+
response = client.admin_analytics_getFile(
125+
type="public_channel", metadata_only=True
126+
)
127+
self.assertTrue(isinstance(response.data, bytes))
128+
self.assertIsNotNone(response.data)

slack_sdk/web/async_client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ class AsyncWebClient(AsyncBaseClient):
7676
"""
7777

7878
async def admin_analytics_getFile(
79-
self, *, date: str, type: str, **kwargs
79+
self,
80+
*,
81+
type: str,
82+
date: Optional[str] = None,
83+
metadata_only: Optional[bool] = None,
84+
**kwargs
8085
) -> AsyncSlackResponse:
8186
"""Retrieve analytics data for a given date, presented as a compressed JSON file
8287
@@ -86,7 +91,11 @@ async def admin_analytics_getFile(
8691
type (str): The type of analytics to retrieve.
8792
The options are currently limited to member.
8893
"""
89-
kwargs.update({"date": date, "type": type})
94+
kwargs.update({"type": type})
95+
if date is not None:
96+
kwargs.update({"date": date})
97+
if metadata_only is not None:
98+
kwargs.update({"metadata_only": metadata_only})
9099
return await self.api_call("admin.analytics.getFile", params=kwargs)
91100

92101
async def admin_apps_approve(

slack_sdk/web/client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ class WebClient(BaseClient):
6767
"""
6868

6969
def admin_analytics_getFile(
70-
self, *, date: str, type: str, **kwargs
70+
self,
71+
*,
72+
type: str,
73+
date: Optional[str] = None,
74+
metadata_only: Optional[bool] = None,
75+
**kwargs
7176
) -> SlackResponse:
7277
"""Retrieve analytics data for a given date, presented as a compressed JSON file
7378
@@ -77,7 +82,11 @@ def admin_analytics_getFile(
7782
type (str): The type of analytics to retrieve.
7883
The options are currently limited to member.
7984
"""
80-
kwargs.update({"date": date, "type": type})
85+
kwargs.update({"type": type})
86+
if date is not None:
87+
kwargs.update({"date": date})
88+
if metadata_only is not None:
89+
kwargs.update({"metadata_only": metadata_only})
8190
return self.api_call("admin.analytics.getFile", params=kwargs)
8291

8392
def admin_apps_approve(

slack_sdk/web/legacy_client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ class LegacyWebClient(LegacyBaseClient):
7878
"""
7979

8080
def admin_analytics_getFile(
81-
self, *, date: str, type: str, **kwargs
81+
self,
82+
*,
83+
type: str,
84+
date: Optional[str] = None,
85+
metadata_only: Optional[bool] = None,
86+
**kwargs
8287
) -> Union[Future, SlackResponse]:
8388
"""Retrieve analytics data for a given date, presented as a compressed JSON file
8489
@@ -88,7 +93,11 @@ def admin_analytics_getFile(
8893
type (str): The type of analytics to retrieve.
8994
The options are currently limited to member.
9095
"""
91-
kwargs.update({"date": date, "type": type})
96+
kwargs.update({"type": type})
97+
if date is not None:
98+
kwargs.update({"date": date})
99+
if metadata_only is not None:
100+
kwargs.update({"metadata_only": metadata_only})
92101
return self.api_call("admin.analytics.getFile", params=kwargs)
93102

94103
def admin_apps_approve(

0 commit comments

Comments
 (0)