Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit f4655bc

Browse files
committed
Update max_api.py
1 parent 77d9576 commit f4655bc

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

MaxBridge/max_api.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,25 @@ def get_contact_details(self, contact_ids: list):
270270
"""
271271
payload = {"contactIds": contact_ids}
272272
return self._send_command(32, payload)
273+
274+
def send_generic_command(self, command_name: str, payload: dict, wait_for_response: bool = True, timeout: int = 10):
275+
"""
276+
Sends a command to the server using its human-readable name.
277+
278+
Args:
279+
command_name (str): The name of the command. Must be a key in MaxAPI.OPCODE_MAP.
280+
payload (dict): The data payload for the command.
281+
wait_for_response (bool, optional): Whether to wait for a server response. Defaults to True.
282+
timeout (int, optional): How long to wait for a response in seconds. Defaults to 10.
283+
284+
Returns:
285+
dict or None: The response payload from the server, or None if wait_for_response is False.
286+
287+
Raises:
288+
ValueError: If the command_name is not found in the OPCODE_MAP.
289+
"""
290+
if command_name not in self.OPCODE_MAP:
291+
raise ValueError(f"Unknown command name '{command_name}'. Valid names are: {list(self.OPCODE_MAP.keys())}")
292+
293+
opcode = self.OPCODE_MAP[command_name]
294+
return self._send_command(opcode, payload, wait_for_response, timeout)

0 commit comments

Comments
 (0)