-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for conversations.requestShared
approve
, deny
& list
#1530
Merged
WilliamBergamin
merged 7 commits into
slackapi:main
from
WilliamBergamin:slack-connect-invite-automation
Sep 6, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a5f8cd4
feat: add support for `conversations.requestShared` `approve` and `de…
WilliamBergamin 03e0441
Update the optional message type for approve
WilliamBergamin f4c26f4
Merge branch 'main' into slack-connect-invite-automation
WilliamBergamin 29a26e2
Add missing methods
WilliamBergamin bdf9795
Fix duplicate message field setting
WilliamBergamin 38443ce
Merge branch 'main' into slack-connect-invite-automation
WilliamBergamin 4568864
Merge branch 'main' into slack-connect-invite-automation
WilliamBergamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
"""A Python module for interacting with Slack's Web API.""" | ||
|
||
import json | ||
import os | ||
import warnings | ||
|
@@ -3191,6 +3192,74 @@ | |
) | ||
return await self.api_call("conversations.replies", http_verb="GET", params=kwargs) | ||
|
||
async def conversations_requestSharedInvite_approve( | ||
self, | ||
*, | ||
invite_id: str, | ||
channel_id: Optional[str] = None, | ||
is_external_limited: Optional[str] = None, | ||
message: Optional[Dict[str, Any]] = None, | ||
**kwargs, | ||
) -> AsyncSlackResponse: | ||
"""Approve a request to add an external user to a channel. This also sends them a Slack Connect invite. | ||
https://api.slack.com/methods/conversations.requestSharedInvite.approve | ||
""" | ||
kwargs.update( | ||
{ | ||
"invite_id": invite_id, | ||
"channel_id": channel_id, | ||
"is_external_limited": is_external_limited, | ||
} | ||
) | ||
if message is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you have these lines of code, the above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch 💯 |
||
kwargs.update({"message": json.dumps(message)}) | ||
return await self.api_call("conversations.requestSharedInvite.approve", params=kwargs) | ||
|
||
async def conversations_requestSharedInvite_deny( | ||
self, | ||
*, | ||
invite_id: str, | ||
message: Optional[str] = None, | ||
**kwargs, | ||
) -> AsyncSlackResponse: | ||
"""Deny a request to invite an external user to a channel. | ||
https://api.slack.com/methods/conversations.requestSharedInvite.deny | ||
""" | ||
kwargs.update({"invite_id": invite_id, "message": message}) | ||
return await self.api_call("conversations.requestSharedInvite.deny", params=kwargs) | ||
|
||
async def conversations_requestSharedInvite_list( | ||
self, | ||
*, | ||
cursor: Optional[str] = None, | ||
include_approved: Optional[bool] = None, | ||
include_denied: Optional[bool] = None, | ||
include_expired: Optional[bool] = None, | ||
invite_ids: Optional[Union[str, Sequence[str]]] = None, | ||
limit: Optional[int] = None, | ||
user_id: Optional[str] = None, | ||
**kwargs, | ||
) -> AsyncSlackResponse: | ||
"""Lists requests to add external users to channels with ability to filter. | ||
https://api.slack.com/methods/conversations.requestSharedInvite.list | ||
""" | ||
kwargs.update( | ||
{ | ||
"cursor": cursor, | ||
"include_approved": include_approved, | ||
"include_denied": include_denied, | ||
"include_expired": include_expired, | ||
"limit": limit, | ||
"user_id": user_id, | ||
} | ||
) | ||
if invite_ids is not None: | ||
if isinstance(invite_ids, (list, Tuple)): | ||
kwargs.update({"invite_ids": ",".join(invite_ids)}) | ||
else: | ||
kwargs.update({"invite_ids": invite_ids}) | ||
return await self.api_call("conversations.requestSharedInvite.list", params=kwargs) | ||
|
||
async def conversations_setPurpose( | ||
self, | ||
*, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one note about
message
here is that if it is provided,text
inside ofmessage
is required. not sure if that is possible to model in Python but figured I'd mention itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to describe such in Python's type hints. The only approaches we can think of would be 1) accept both dict and custom class that has "text" property, 2) add runtime validation that checks if the key is not missing. That said, as long as the server-side returns a clear error code/message for the pattern, I don't think we should do extra on the client code side.