-
Notifications
You must be signed in to change notification settings - Fork 6
[cards]: additional actions #111
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c09d555
setup cards structure
43575e2
merge w main
ffd1a57
resolve init file
55a9149
add additional card actions
f65d63c
undo move of SerializableObject from core.py
b7304d5
Merge branch 'main' into lilyydu/cards
lilyydu 5a1db40
removed serializable_obj
8e2d906
Merge branch 'main' into lilyydu/cards
lilyydu 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
packages/cards/src/microsoft/teams/cards/actions/__init__.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from .im_back_action import IMBackAction | ||
| from .invoke_action import InvokeAction | ||
| from .message_back_action import MessageBackAction | ||
| from .sign_in_action import SignInAction | ||
| from .task_fetch_action import TaskFetchAction | ||
|
|
||
| __all__ = ["IMBackAction", "MessageBackAction", "SignInAction", "InvokeAction", "TaskFetchAction"] |
15 changes: 15 additions & 0 deletions
15
packages/cards/src/microsoft/teams/cards/actions/im_back_action.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from ..core import ImBackSubmitActionData, SubmitAction, SubmitActionData | ||
|
|
||
|
|
||
| class IMBackAction(SubmitAction): | ||
| """Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.""" | ||
|
|
||
| def __init__(self, value: str): | ||
| super().__init__() | ||
| action_data = ImBackSubmitActionData().with_value(value) | ||
| self.data = SubmitActionData(ms_teams=action_data.model_dump()) | ||
15 changes: 15 additions & 0 deletions
15
packages/cards/src/microsoft/teams/cards/actions/invoke_action.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from typing import Any, Dict | ||
|
|
||
| from ..core import InvokeSubmitActionData, SubmitAction, SubmitActionData | ||
|
|
||
|
|
||
| class InvokeAction(SubmitAction): | ||
| def __init__(self, value: Dict[str, Any]): | ||
| super().__init__() | ||
| action_data = InvokeSubmitActionData().with_value(value) | ||
| self.data = SubmitActionData(ms_teams=action_data.model_dump()) |
19 changes: 19 additions & 0 deletions
19
packages/cards/src/microsoft/teams/cards/actions/message_back_action.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from typing import Optional | ||
|
|
||
| from ..core import MessageBackSubmitActionData, SubmitAction, SubmitActionData | ||
|
|
||
|
|
||
| class MessageBackAction(SubmitAction): | ||
| def __init__(self, text: str, value: str, display_text: Optional[str] = None): | ||
| super().__init__() | ||
| action_data = MessageBackSubmitActionData().with_value(value).with_text(text) | ||
|
|
||
| if display_text: | ||
| action_data = action_data.with_display_text(display_text) | ||
|
|
||
| self.data = SubmitActionData(ms_teams=action_data.model_dump()) |
13 changes: 13 additions & 0 deletions
13
packages/cards/src/microsoft/teams/cards/actions/sign_in_action.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from ..core import SigninSubmitActionData, SubmitAction, SubmitActionData | ||
|
|
||
|
|
||
| class SignInAction(SubmitAction): | ||
| def __init__(self, value: str): | ||
| super().__init__() | ||
| action_data = SigninSubmitActionData().with_value(value) | ||
| self.data = SubmitActionData(ms_teams=action_data.model_dump()) |
15 changes: 15 additions & 0 deletions
15
packages/cards/src/microsoft/teams/cards/actions/task_fetch_action.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from typing import Any, Dict | ||
|
|
||
| from ..core import SubmitAction, SubmitActionData, TaskFetchSubmitActionData | ||
|
|
||
|
|
||
| class TaskFetchAction(SubmitAction): | ||
| def __init__(self, value: Dict[str, Any]): | ||
| super().__init__() | ||
| action_data = TaskFetchSubmitActionData().with_value(value) | ||
| self.data = SubmitActionData(ms_teams=action_data.model_dump()) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from microsoft.teams.cards import IMBackAction, SubmitActionData | ||
|
|
||
|
|
||
| def test_im_back_action_initialization(): | ||
| action = IMBackAction(value="Test Value") | ||
| assert isinstance(action.data, SubmitActionData) | ||
| assert action.data.ms_teams is not None | ||
| assert action.data.ms_teams["value"] == "Test Value" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from microsoft.teams.cards import InvokeAction, SubmitActionData | ||
|
|
||
|
|
||
| def test_invoke_action_initialization(): | ||
| action = InvokeAction({"test": "Test Value"}) | ||
| assert isinstance(action.data, SubmitActionData) | ||
| assert action.data.ms_teams is not None | ||
| assert action.data.ms_teams["value"]["test"] == "Test Value" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from microsoft.teams.cards import MessageBackAction, SubmitActionData | ||
|
|
||
|
|
||
| def test_message_back_action_initialization(): | ||
| action = MessageBackAction(text="Message Back Test", value="Test Value", display_text="Test Text") | ||
| assert isinstance(action.data, SubmitActionData) | ||
| assert action.data.ms_teams is not None | ||
| assert action.data.ms_teams["value"] == "Test Value" | ||
| assert action.data.ms_teams["text"] == "Message Back Test" | ||
| assert action.data.ms_teams["displayText"] == "Test Text" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from microsoft.teams.cards import SignInAction, SubmitActionData | ||
|
|
||
|
|
||
| def test_sign_in_action_initialization(): | ||
| action = SignInAction(value="Test Value") | ||
| assert isinstance(action.data, SubmitActionData) | ||
| assert action.data.ms_teams is not None | ||
| assert action.data.ms_teams["value"] == "Test Value" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| from microsoft.teams.cards import SubmitActionData, TaskFetchAction | ||
|
|
||
|
|
||
| def test_invoke_action_initialization(): | ||
| action = TaskFetchAction({"test": "Test Value"}) | ||
| assert isinstance(action.data, SubmitActionData) | ||
| assert action.data.ms_teams is not None | ||
| assert action.data.ms_teams["value"]["test"] == "Test Value" |
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.
Uh oh!
There was an error while loading. Please reload this page.