@@ -231,17 +231,23 @@ public function queryMembers($filterConditions = null, $sort = null, $options =
231231 }
232232
233233 /**
234- * @param array $channelData
235- * @param string $updateMessage
234+ * @param array|null $channelData
235+ * @param array|null $updateMessage
236+ * @param array|null $options
236237 * @return StreamResponse
237238 * @throws StreamException
238239 */
239- public function update ($ channelData , $ updateMessage =null )
240+ public function update ($ channelData , $ updateMessage =null , $ options = null )
240241 {
241242 $ payload = [
242243 "data " => $ channelData ,
243244 "message " => $ updateMessage
244245 ];
246+
247+ if ($ options !== null ) {
248+ $ payload = array_merge ($ payload , $ options );
249+ }
250+
245251 return $ this ->client ->post ($ this ->getUrl (), $ payload );
246252 }
247253
@@ -300,7 +306,7 @@ public function addMembers($userIds, $options=null)
300306 if ($ options !== null ) {
301307 $ payload = array_merge ($ payload , $ options );
302308 }
303- return $ this ->client -> post ( $ this -> getUrl () , $ payload );
309+ return $ this ->update ( null , null , $ payload );
304310 }
305311
306312 /**
@@ -313,7 +319,7 @@ public function addModerators($userIds)
313319 $ payload = [
314320 "add_moderators " => $ userIds
315321 ];
316- return $ this ->client -> post ( $ this -> getUrl () , $ payload );
322+ return $ this ->update ( null , null , $ payload );
317323 }
318324
319325 /**
@@ -326,7 +332,7 @@ public function removeMembers($userIds)
326332 $ payload = [
327333 "remove_members " => $ userIds
328334 ];
329- return $ this ->client -> post ( $ this -> getUrl () , $ payload );
335+ return $ this ->update ( null , null , $ payload );
330336 }
331337
332338 /**
@@ -339,7 +345,7 @@ public function demoteModerators($userIds)
339345 $ payload = [
340346 "demote_moderators " => $ userIds
341347 ];
342- return $ this ->client -> post ( $ this -> getUrl () , $ payload );
348+ return $ this ->update ( null , null , $ payload );
343349 }
344350
345351 /**
@@ -412,33 +418,53 @@ public function unbanUser($targetId, $options=null)
412418 }
413419
414420 /**
421+ * @param array $userIds
422+ * @param array $message
423+ * @return StreamResponse
424+ * @throws StreamException
425+ */
426+ public function inviteMembers ($ userIds , $ message = null )
427+ {
428+ $ payload = [
429+ "invites " => $ userIds ,
430+ "message " => $ message
431+ ];
432+
433+ return $ this ->update (null , $ message , $ payload );
434+ }
435+
436+ /**
437+ * @param string $userId
415438 * @param array $options
416439 * @return StreamResponse
417440 * @throws StreamException
418441 */
419- public function acceptInvite ($ options =null )
442+ public function acceptInvite ($ userId , $ options =null )
420443 {
421444 if ($ options === null ) {
422445 $ options = [];
423446 }
447+ $ options ["user_id " ] = $ userId ;
424448 $ options ['accept_invite ' ] = true ;
425- $ response = $ this ->client -> post ( $ this -> getUrl () , $ options );
449+ $ response = $ this ->update ( null , null , $ options );
426450 $ this ->customData = $ response ['channel ' ];
427451 return $ response ;
428452 }
429453
430454 /**
455+ * @param string $userId
431456 * @param array $options
432457 * @return StreamResponse
433458 * @throws StreamException
434459 */
435- public function rejectInvite ($ options =null )
460+ public function rejectInvite ($ userId , $ options =null )
436461 {
437462 if ($ options === null ) {
438463 $ options = [];
439464 }
465+ $ options ["user_id " ] = $ userId ;
440466 $ options ['reject_invite ' ] = true ;
441- $ response = $ this ->client -> post ( $ this -> getUrl () , $ options );
467+ $ response = $ this ->update ( null , null , $ options );
442468 $ this ->customData = $ response ['channel ' ];
443469 return $ response ;
444470 }
0 commit comments