@@ -73,8 +73,8 @@ def __init__(self, session, object_factory):
73
73
self ._object_factory = object_factory
74
74
75
75
@generator_container
76
- def list (self , roomId , mentionedPeople = None , before = None ,
77
- beforeMessage = None , max = None , ** request_parameters ):
76
+ def list (self , roomId , parentId = None , mentionedPeople = None , before = None ,
77
+ beforeMessage = None , max = 50 , ** request_parameters ):
78
78
"""Lists messages in a room.
79
79
80
80
Each message will include content attachments if present.
@@ -93,6 +93,7 @@ def list(self, roomId, mentionedPeople=None, before=None,
93
93
94
94
Args:
95
95
roomId(basestring): List messages for a room, by ID.
96
+ parentId(basestring): List messages with a parent, by ID.
96
97
mentionedPeople(basestring): List messages where the caller is
97
98
mentioned by specifying "me" or the caller `personId`.
98
99
before(basestring): List messages sent before a date and time, in
@@ -114,6 +115,7 @@ def list(self, roomId, mentionedPeople=None, before=None,
114
115
115
116
"""
116
117
check_type (roomId , basestring )
118
+ check_type (parentId , basestring , optional = True )
117
119
check_type (mentionedPeople , basestring , optional = True )
118
120
check_type (before , basestring , optional = True )
119
121
check_type (beforeMessage , basestring , optional = True )
@@ -122,6 +124,7 @@ def list(self, roomId, mentionedPeople=None, before=None,
122
124
params = dict_from_items_with_values (
123
125
request_parameters ,
124
126
roomId = roomId ,
127
+ parentId = parentId ,
125
128
mentionedPeople = mentionedPeople ,
126
129
before = before ,
127
130
beforeMessage = beforeMessage ,
@@ -135,9 +138,67 @@ def list(self, roomId, mentionedPeople=None, before=None,
135
138
for item in items :
136
139
yield self ._object_factory (OBJECT_TYPE , item )
137
140
138
- def create (self , roomId = None , toPersonId = None , toPersonEmail = None ,
139
- text = None , markdown = None , files = None , attachments = None ,
140
- parentId = None , ** request_parameters ):
141
+ @generator_container
142
+ def list_direct (self , personId = None , personEmail = None , parentId = None ,
143
+ ** request_parameters ):
144
+ """List all messages in a 1:1 (direct) room.
145
+
146
+ Use the `personId` or `personEmail` query parameter to specify the
147
+ room.
148
+
149
+ The list API sorts the messages in descending order by creation date.
150
+
151
+ This method supports Webex Teams's implementation of RFC5988 Web
152
+ Linking to provide pagination support. It returns a generator
153
+ container that incrementally yields all messages returned by the
154
+ query. The generator will automatically request additional 'pages' of
155
+ responses from Webex as needed until all responses have been returned.
156
+ The container makes the generator safe for reuse. A new API call will
157
+ be made, using the same parameters that were specified when the
158
+ generator was created, every time a new iterator is requested from the
159
+ container.
160
+
161
+ Args:
162
+ personId(basestring): List messages in a 1:1 room, by person ID.
163
+ personEmail(basestring): List messages in a 1:1 room, by person
164
+ email.
165
+ parentId(basestring): List messages with a parent, by ID.
166
+ **request_parameters: Additional request parameters (provides
167
+ support for parameters that may be added in the future).
168
+
169
+ Returns:
170
+ GeneratorContainer: A GeneratorContainer which, when iterated,
171
+ yields the messages returned by the Webex Teams query.
172
+
173
+ Raises:
174
+ TypeError: If the parameter types are incorrect.
175
+ ApiError: If the Webex Teams cloud returns an error.
176
+
177
+ """
178
+ check_type (personId , basestring , optional = True )
179
+ check_type (personEmail , basestring , optional = True )
180
+ check_type (parentId , basestring , optional = True )
181
+
182
+ params = dict_from_items_with_values (
183
+ request_parameters ,
184
+ personId = personId ,
185
+ personEmail = personEmail ,
186
+ parentId = parentId ,
187
+ )
188
+
189
+ # API request - get items
190
+ items = self ._session .get_items (
191
+ API_ENDPOINT + "/direct" ,
192
+ params = params ,
193
+ )
194
+
195
+ # Yield message objects created from the returned items JSON objects
196
+ for item in items :
197
+ yield self ._object_factory (OBJECT_TYPE , item )
198
+
199
+ def create (self , roomId = None , parentId = None , toPersonId = None ,
200
+ toPersonEmail = None , text = None , markdown = None , files = None ,
201
+ attachments = None , ** request_parameters ):
141
202
"""Post a message to a room.
142
203
143
204
The files parameter is a list, which accepts multiple values to allow
0 commit comments