Skip to content

Commit 44e21e0

Browse files
authored
Merge pull request #200 from GetStream/feature/uni-114-implement-polls-api
Feature/uni 114 implement polls api
2 parents 4406a17 + 3246e60 commit 44e21e0

File tree

130 files changed

+4455
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+4455
-28
lines changed

Assets/Plugins/StreamChat/Core/IStreamChatClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public interface IStreamChatClient : IDisposable, IStreamChatClientEventsListene
108108
/// </summary>
109109
IStreamChatLowLevelClient LowLevelClient { get; }
110110

111+
/// <summary>
112+
/// Polls API for creating, retrieving, and querying polls
113+
/// </summary>
114+
IStreamPollsApi Polls { get; }
115+
111116
/// <summary>
112117
/// Connect user to Stream Chat server.
113118
/// User authentication credentials:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using StreamChat.Core.Requests;
4+
using StreamChat.Core.StatefulModels;
5+
6+
namespace StreamChat.Core
7+
{
8+
/// <summary>
9+
/// Polls API for creating, retrieving, and querying polls
10+
/// </summary>
11+
public interface IStreamPollsApi
12+
{
13+
/// <summary>
14+
/// Create a new poll
15+
/// </summary>
16+
/// <param name="createRequest">Request with poll creation data</param>
17+
/// <returns>The created poll</returns>
18+
Task<IStreamPoll> CreatePollAsync(StreamCreatePollRequest createRequest);
19+
20+
/// <summary>
21+
/// Get a poll by ID
22+
/// </summary>
23+
/// <param name="pollId">The poll ID</param>
24+
/// <returns>The poll with the specified ID</returns>
25+
Task<IStreamPoll> GetPollAsync(string pollId);
26+
27+
/// <summary>
28+
/// Query polls based on filters
29+
/// </summary>
30+
/// <param name="queryRequest">Request with query filters and parameters</param>
31+
/// <returns>List of polls matching the query</returns>
32+
Task<IEnumerable<IStreamPoll>> QueryPollsAsync(StreamQueryPollsRequest queryRequest);
33+
34+
/// <summary>
35+
/// Delete a poll by ID
36+
/// </summary>
37+
/// <param name="pollId">The poll ID to delete</param>
38+
Task DeletePollAsync(string pollId);
39+
}
40+
}
41+

Assets/Plugins/StreamChat/Core/IStreamPollsApi.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollClosedEventInternalDTO.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,48 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a poll is closed.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollClosedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object which was closed
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

2852
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2953
public System.DateTimeOffset? ReceivedAt { get; set; }
3054

55+
/// <summary>
56+
/// The type of event: "poll.closed" in this case
57+
/// </summary>
3158
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public string Type { get; set; } = "poll.closed";
3360

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollDeletedEventInternalDTO.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,48 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a poll is deleted.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollDeletedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object which was deleted
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

2852
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2953
public System.DateTimeOffset? ReceivedAt { get; set; }
3054

55+
/// <summary>
56+
/// The type of event: "poll.deleted" in this case
57+
/// </summary>
3158
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public string Type { get; set; } = "poll.deleted";
3360

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollUpdatedEventInternalDTO.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,48 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a poll is updated.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollUpdatedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object which was updated
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

2852
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2953
public System.DateTimeOffset? ReceivedAt { get; set; }
3054

55+
/// <summary>
56+
/// The type of event: "poll.updated" in this case
57+
/// </summary>
3158
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public string Type { get; set; } = "poll.updated";
3360

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollVoteCastedEventInternalDTO.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,54 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a vote is cast on a poll.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollVoteCastedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

52+
/// <summary>
53+
/// The vote that was cast
54+
/// </summary>
2855
[Newtonsoft.Json.JsonProperty("poll_vote", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2956
public PollVoteResponseDataInternalDTO PollVote { get; set; }
3057

3158
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public System.DateTimeOffset? ReceivedAt { get; set; }
3360

61+
/// <summary>
62+
/// The type of event: "poll.vote_casted" in this case
63+
/// </summary>
3464
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3565
public string Type { get; set; } = "poll.vote_casted";
3666

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollVoteChangedEventInternalDTO.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,54 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a vote on a poll is changed.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollVoteChangedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

52+
/// <summary>
53+
/// The updated vote
54+
/// </summary>
2855
[Newtonsoft.Json.JsonProperty("poll_vote", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2956
public PollVoteResponseDataInternalDTO PollVote { get; set; }
3057

3158
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public System.DateTimeOffset? ReceivedAt { get; set; }
3360

61+
/// <summary>
62+
/// The type of event: "poll.vote_changed" in this case
63+
/// </summary>
3464
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3565
public string Type { get; set; } = "poll.vote_changed";
3666

Assets/Plugins/StreamChat/Core/InternalDTO/Events/PollVoteRemovedEventInternalDTO.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,54 @@ namespace StreamChat.Core.InternalDTO.Events
1313
{
1414
using System = global::System;
1515

16+
/// <summary>
17+
/// Emitted when a vote is removed from a poll.
18+
/// </summary>
1619
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1720
internal partial class PollVoteRemovedEventInternalDTO
1821
{
22+
[Newtonsoft.Json.JsonProperty("activity_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23+
public string ActivityId { get; set; }
24+
25+
/// <summary>
26+
/// The CID of the channel containing the poll
27+
/// </summary>
1928
[Newtonsoft.Json.JsonProperty("cid", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2029
public string Cid { get; set; }
2130

31+
/// <summary>
32+
/// Date/time of creation
33+
/// </summary>
2234
[Newtonsoft.Json.JsonProperty("created_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2335
public System.DateTimeOffset CreatedAt { get; set; }
2436

37+
[Newtonsoft.Json.JsonProperty("custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
38+
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; } = new System.Collections.Generic.Dictionary<string, object>();
39+
40+
/// <summary>
41+
/// The ID of the message containing the poll
42+
/// </summary>
43+
[Newtonsoft.Json.JsonProperty("message_id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
44+
public string MessageId { get; set; }
45+
46+
/// <summary>
47+
/// The poll object
48+
/// </summary>
2549
[Newtonsoft.Json.JsonProperty("poll", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2650
public PollResponseDataInternalDTO Poll { get; set; } = new PollResponseDataInternalDTO();
2751

52+
/// <summary>
53+
/// The vote that was removed
54+
/// </summary>
2855
[Newtonsoft.Json.JsonProperty("poll_vote", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2956
public PollVoteResponseDataInternalDTO PollVote { get; set; }
3057

3158
[Newtonsoft.Json.JsonProperty("received_at", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3259
public System.DateTimeOffset? ReceivedAt { get; set; }
3360

61+
/// <summary>
62+
/// The type of event: "poll.vote_removed" in this case
63+
/// </summary>
3464
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3565
public string Type { get; set; } = "poll.vote_removed";
3666

Assets/Plugins/StreamChat/Core/InternalDTO/Requests/CreatePollOptionRequestInternalDTO.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ internal partial class CreatePollOptionRequestInternalDTO
1919
[Newtonsoft.Json.JsonProperty("Custom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2020
public System.Collections.Generic.Dictionary<string, object> Custom { get; set; }
2121

22-
[Newtonsoft.Json.JsonProperty("position", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23-
public int? Position { get; set; }
24-
2522
/// <summary>
2623
/// Option text
2724
/// </summary>

0 commit comments

Comments
 (0)