Skip to content

Commit

Permalink
feat: add partialUpdateMember endpoint (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziine committed Sep 10, 2024
1 parent a612bc3 commit b9b0393
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
MuteChannelAPIResponse,
PartialUpdateChannel,
PartialUpdateChannelAPIResponse,
PartialUpdateMember,
PinnedMessagePaginationOptions,
PinnedMessagesSort,
QueryMembersOptions,
Expand Down Expand Up @@ -299,6 +300,25 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
);
}

/**
* partialUpdateMember - Partial update a member
*
* @param {string} user_id member user id
* @param {PartialUpdateMember<StreamChatGenerics>} updates
*
* @return {Promise<ChannelMemberResponse<StreamChatGenerics>>} Updated member
*/
async partialUpdateMember(user_id: string, updates: PartialUpdateMember<StreamChatGenerics>) {
if (!user_id) {
throw Error('Please specify the user id');
}

return await this.getClient().patch<ChannelMemberResponse<StreamChatGenerics>>(
this._channelURL() + `/member/${encodeURIComponent(user_id)}`,
updates,
);
}

/**
* sendReaction - Send a reaction about a message
*
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,11 @@ export type PartialUpdateChannel<StreamChatGenerics extends ExtendableGenerics =
unset?: Array<keyof ChannelResponse<StreamChatGenerics>>;
};

export type PartialUpdateMember<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
set?: Partial<ChannelMemberResponse<StreamChatGenerics>>;
unset?: Array<keyof ChannelMemberResponse<StreamChatGenerics>>;
};

export type PartialUserUpdate<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
id: string;
set?: Partial<UserResponse<StreamChatGenerics>>;
Expand Down

0 comments on commit b9b0393

Please sign in to comment.