diff --git a/src/monday_sdk/modules/updates.py b/src/monday_sdk/modules/updates.py index 043e7a9..55982eb 100644 --- a/src/monday_sdk/modules/updates.py +++ b/src/monday_sdk/modules/updates.py @@ -8,8 +8,9 @@ class UpdateModule: def __init__(self, graphql_client: MondayGraphQL): self.client = graphql_client - def create_update(self, item_id, update_value) -> MondayApiResponse: - query = create_update_query(item_id, update_value) + def create_update(self, item_id, update_value, mentions_list: Optional[List[UpdateMentions]]) -> MondayApiResponse: + mentions_str = self._convert_mentions_to_graphql(mentions_list) + query = create_update_query(item_id, update_value, mentions_str) return self.client.execute(query) def delete_update(self, item_id) -> MondayApiResponse: @@ -106,4 +107,25 @@ def fetch_board_updates_incremental( If using an older API version, use fetch_board_updates() instead which provides client-side date filtering. """ - return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date) \ No newline at end of file + return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date) + + def _convert_mentions_to_graphql(self, mentions_list: Optional[List[UpdateMentions]]): + """Convert a Python list of mention dictionaries to GraphQL format string. + + Args: + mentions_list: Optional[List[UpdateMentions]] + Example: [{"id": 60875578, "type": "User"}] + + Returns: + GraphQL formatted string: "[{id: 60875578, type: User}]" + """ + if not mentions_list or not isinstance(mentions_list, list): + return "[]" + + mention_strings = [] + for mention in mentions_list: + # Build the mention string with unquoted keys and enum type + mention_str = f"{{id: {mention['id']}, type: {mention['type']}}}" + mention_strings.append(mention_str) + + return f"[{', '.join(mention_strings)}]" \ No newline at end of file diff --git a/src/monday_sdk/query_templates.py b/src/monday_sdk/query_templates.py index a4a2b94..74dc556 100644 --- a/src/monday_sdk/query_templates.py +++ b/src/monday_sdk/query_templates.py @@ -473,18 +473,20 @@ def update_multiple_column_values_query(board_id, item_id, column_values, create # UPDATE RESOURCE QUERIES -def create_update_query(item_id, update_value): +def create_update_query(item_id, update_value, mentions: str): query = """mutation { create_update( item_id: %s, - body: %s + body: %s, + mentions_list: %s ) { id } }""" % ( item_id, json.dumps(update_value, ensure_ascii=False), + mentions ) return query diff --git a/src/monday_sdk/types/__init__.py b/src/monday_sdk/types/__init__.py index 7c16bdf..ec61a31 100644 --- a/src/monday_sdk/types/__init__.py +++ b/src/monday_sdk/types/__init__.py @@ -16,3 +16,4 @@ Document, ) from .monday_enums import BoardKind, BoardState, BoardsOrderBy, Operator +from .utils import UpdateMentions diff --git a/src/monday_sdk/types/utils.py b/src/monday_sdk/types/utils.py new file mode 100644 index 0000000..85a2567 --- /dev/null +++ b/src/monday_sdk/types/utils.py @@ -0,0 +1,6 @@ +from typing import TypedDict + +class UpdateMentions(TypedDict): + """TypedDict for updating mentions in a Monday.com column.""" + id: int + type: str \ No newline at end of file