Skip to content

Commit b5fb0d3

Browse files
committed
Minor card attachements updates
1 parent 45597ff commit b5fb0d3

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

webexteamssdk/api/messages.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ def list(self, roomId, mentionedPeople=None, before=None,
135135
yield self._object_factory(OBJECT_TYPE, item)
136136

137137
def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
138-
text=None, markdown=None, files=None, attachments=None, **request_parameters):
139-
"""Post a message, and optionally a attachment, to a room.
138+
text=None, markdown=None, files=None, attachments=None,
139+
**request_parameters):
140+
"""Post a message to a room.
140141
141142
The files parameter is a list, which accepts multiple values to allow
142143
for future expansion, but currently only one file may be included with
@@ -152,11 +153,10 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
152153
specified this parameter may be optionally used to provide
153154
alternate text for UI clients that do not support rich text.
154155
markdown(basestring): The message, in markdown format.
155-
files(`list`): A list of public URL(s) or local path(s) to files to
156+
files(list): A list of public URL(s) or local path(s) to files to
156157
be posted into the room. Only one file is allowed per message.
157-
attachments(`list`): A list comprised of properly formatted button
158-
and card data structure. This can be found at
159-
https://docs.microsoft.com/en-us/adaptive-cards/sdk/designer
158+
attachments(list): Content attachments to attach to the message.
159+
See the Cards Guide for more information.
160160
**request_parameters: Additional request parameters (provides
161161
support for parameters that may be added in the future).
162162
@@ -178,23 +178,24 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
178178
check_type(markdown, basestring, optional=True)
179179
check_type(files, list, optional=True)
180180
check_type(attachments, list, optional=True)
181+
181182
if files:
182-
if len(files) != 1:
183-
raise ValueError("The length of the `files` list is greater "
184-
"than one (1). The files parameter is a "
185-
"list, which accepts multiple values to "
183+
if len(files) > 1:
184+
raise ValueError("The `files` parameter should be a list with "
185+
"exactly one (1) item. The files parameter "
186+
"is a list, which accepts multiple values to "
186187
"allow for future expansion, but currently "
187188
"only one file may be included with the "
188189
"message.")
189190
check_type(files[0], basestring)
191+
else:
192+
files = None
190193

191194
if attachments:
192195
for attachment in attachments:
193-
try:
194-
content_type_exists = attachment['contentType']
195-
except Exception as e:
196-
# ensure a valid header is loaded for cards
197-
attachment['contentType'] = 'application/vnd.microsoft.card.adaptive'
196+
check_type(attachment, dict)
197+
else:
198+
attachments = None
198199

199200
post_data = dict_from_items_with_values(
200201
request_parameters,

0 commit comments

Comments
 (0)