@@ -135,7 +135,7 @@ 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 , ** request_parameters ):
138+ text = None , markdown = None , files = None , attachments = None , ** request_parameters ):
139139 """Post a message, and optionally a attachment, to a room.
140140
141141 The files parameter is a list, which accepts multiple values to allow
@@ -154,6 +154,9 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
154154 markdown(basestring): The message, in markdown format.
155155 files(`list`): A list of public URL(s) or local path(s) to files to
156156 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
157160 **request_parameters: Additional request parameters (provides
158161 support for parameters that may be added in the future).
159162
@@ -174,6 +177,7 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
174177 check_type (text , basestring )
175178 check_type (markdown , basestring )
176179 check_type (files , list )
180+ check_type (attachments , list )
177181 if files :
178182 if len (files ) != 1 :
179183 raise ValueError ("The length of the `files` list is greater "
@@ -184,6 +188,14 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
184188 "message." )
185189 check_type (files [0 ], basestring )
186190
191+ if attachments :
192+ 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'
198+
187199 post_data = dict_from_items_with_values (
188200 request_parameters ,
189201 roomId = roomId ,
@@ -192,6 +204,7 @@ def create(self, roomId=None, toPersonId=None, toPersonEmail=None,
192204 text = text ,
193205 markdown = markdown ,
194206 files = files ,
207+ attachments = attachments ,
195208 )
196209
197210 # API request
0 commit comments