rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
422 stars 78 forks source link

Add OpenURI functionality #67

Closed AndrewRezy closed 4 years ago

AndrewRezy commented 4 years ago

OpenURI functionality is missing. This is abit of a caveat since it has it's own @type field independent of the @type of ActionCard

I was able to add the functionality with the python 3.6 code snippet below `

def addOpenURI(self, _name: str, _targets: list):
    """
    Creates a OpenURI action

    https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#openuri-action

    :param _name: *Name of the text to appear inside the ActionCard*
    :type _name: str
    :param _targets: *A list of dictionaries, ex: {"os": "default", "uri": "https://www..."}*
    :type _targets: list(dict())
    """
    self.payload["@type"] = "OpenUri"
    self.payload["name"] = _name
    if not isinstance(_targets, list):
        raise TypeError("Target must be of type list(dict())")
    self.payload["targets"] = _targets

`

rveachkc commented 4 years ago

Feel free to make a pull request.