From 358d4123877b80e57705c7f5d7ebf707e64b53c2 Mon Sep 17 00:00:00 2001 From: kanat Date: Tue, 9 Apr 2024 11:26:50 -0700 Subject: [PATCH] (polls) support closePoll, add/fix missing fields --- src/client.ts | 47 ++++++++++++++++++++++++++++++++++++++--------- src/types.ts | 11 ++++++++--- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/client.ts b/src/client.ts index 14a8c707d5..ab1b216069 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3430,7 +3430,7 @@ export class StreamChat(this.baseURL + `/polls`, poll); @@ -3439,9 +3439,9 @@ export class StreamChat { return await this.get(this.baseURL + `/polls/${id}`, { ...(userId ? { user_id: userId } : {}), }); @@ -3457,13 +3457,16 @@ export class StreamChat} partialPollObject which should contain id and any of "set" or "unset" params; * example: {id: "44f26af5-f2be-4fa7-9dac-71cf893781de", set:{field: value}, unset:["field2"]} - * @returns {APIResponse & PollResponse} The poll + * @returns {APIResponse & UpdatePollAPIResponse} The poll */ - async partialUpdatePoll(id: string, partialPollObject: PartialPollUpdate) { + async partialUpdatePoll( + id: string, + partialPollObject: PartialPollUpdate, + ): Promise { return await this.patch(this.baseURL + `/polls/${id}`, partialPollObject); } @@ -3479,6 +3482,19 @@ export class StreamChat { + return this.partialUpdatePoll(id, { + set: { + is_closed: true, + } + }); + } + /** * Creates a poll option * @param pollId string The poll id @@ -3525,10 +3541,11 @@ export class StreamChat( @@ -3537,6 +3554,18 @@ export class StreamChat( this.baseURL + `/messages/${messageId}/polls/${pollId}/vote/${voteId}`, diff --git a/src/types.ts b/src/types.ts index 9700cc9527..f391fcd967 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1417,7 +1417,7 @@ export type ChannelFilters, '$eq'>> | PrimitiveFilter; + } & { + allow_user_suggested_options?: + | RequireOnlyOne, '$eq'>> + | PrimitiveFilter; } & { voting_visibility?: | RequireOnlyOne, '$eq'>> @@ -1477,8 +1481,8 @@ export type QueryVotesFilters = QueryFilters< | PrimitiveFilter; } & { is_answer?: - | RequireOnlyOne, '$eq'>> - | PrimitiveFilter; + | RequireOnlyOne, '$eq'>> + | PrimitiveFilter; } & { user_id?: | RequireOnlyOne, '$eq' | '$in'>> @@ -2900,6 +2904,7 @@ export type UpdatePollAPIResponse = StreamChatGenerics['pollType'] & { + answers_count: number; created_at: string; created_by: UserResponse | null; created_by_id: string;