stream-chat-ruby 2.22.0 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0493f781c7cda5a16174cd56949d41ebf9234a9903d94dfcaf8826e90778d1c4'
4
- data.tar.gz: 0b81431fb6fce8e3d230ad0838d5b666696c1368ec00c7417f37789218d20847
3
+ metadata.gz: 06e555a899a1f327f6ab64ae55a383c84bf76991df3530d67b8c29a84a27e0b4
4
+ data.tar.gz: 93df6034f3d3f76d735f3a023ef0e160b1c74930509b52c80df3e9436b28780d
5
5
  SHA512:
6
- metadata.gz: f2cb64ead68735919747ca939dbd4185440d44a5f52164524d874ec98765a37207b3126a63afa30a6de0eb3faadac0f93561c4ecd246add31eb69e6bab6add52
7
- data.tar.gz: f6bdf47417e6ed4af0d2a0ed2eb9c775bdb7a4ea5bff3b89bff69c7b702edf892d4009e8e521e067c3a65eb9251e3728e76cbbf9f72e6a90e169907920e65bc0
6
+ metadata.gz: 668c718c2dc5b9c75db14601a3c8d2ebf6eaf3f7a53d14b654c05236304b8bc46fd8c76f6790cde9c16453911bc07bc6f4efb6c7be5547a036b2f98d33c58b35
7
+ data.tar.gz: e5b37cf05fedfe43a6d5b512dd36a0443010c7261070d40aa3455448c98a47842cbe2dbdd4b03cd83c315851aa810e66fda1e7cba4c358da1d015bde6f484484
data/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.23.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.2...v2.23.0) (2022-05-19)
6
+
7
+
8
+ ### Features
9
+
10
+ * **campaign:** add campaign endpoints ([c8c698b](https://github.com/GetStream/stream-chat-ruby/commit/c8c698b51ee2c9f54819c2b9407a3fff7808efd5))
11
+ * **import:** add import endpoints ([#102](https://github.com/GetStream/stream-chat-ruby/issues/102)) ([4d7358d](https://github.com/GetStream/stream-chat-ruby/commit/4d7358d39615c5346f9fdcb2b0dfbffa3c2ae79c))
12
+
13
+ ### [2.22.2](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.1...v2.22.2) (2022-04-21)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **sorbet:** turn off runtime checks properly ([#98](https://github.com/GetStream/stream-chat-ruby/issues/98)) ([29e9e73](https://github.com/GetStream/stream-chat-ruby/commit/29e9e73ac07d163e8c1ca7b24516cb7ac61e93cd))
19
+
20
+ ### [2.22.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.0...v2.22.1) (2022-04-20)
21
+
22
+ ### Features
23
+
24
+ * added comments to public methods ([#93](https://github.com/GetStream/stream-chat-ruby/issues/93)) ([3843fe4](https://github.com/GetStream/stream-chat-ruby/commit/3843fe41ea7716d2b6a787d695bbe54981b2b35e))
25
+
5
26
  ## [2.22.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.21.0...v2.22.0) (2022-04-01)
6
27
 
7
28
 
data/Gemfile CHANGED
@@ -15,4 +15,5 @@ end
15
15
  group :test do
16
16
  gem 'rack'
17
17
  gem 'simplecov'
18
+ gem 'simplecov-console'
18
19
  end
@@ -9,24 +9,23 @@ require 'stream-chat/types'
9
9
  module StreamChat
10
10
  class Channel
11
11
  extend T::Sig
12
- T::Configuration.default_checked_level = :never
13
12
  # For now we disable runtime type checks.
14
13
  # We will enable it with a major bump in the future,
15
14
  # but for now, let's just run a static type check.
16
15
 
17
- sig { returns(T.nilable(String)) }
16
+ T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
18
17
  attr_reader :id
19
18
 
20
- sig { returns(String) }
19
+ T::Sig::WithoutRuntime.sig { returns(String) }
21
20
  attr_reader :channel_type
22
21
 
23
- sig { returns(StringKeyHash) }
22
+ T::Sig::WithoutRuntime.sig { returns(StringKeyHash) }
24
23
  attr_reader :custom_data
25
24
 
26
- sig { returns(T::Array[StringKeyHash]) }
25
+ T::Sig::WithoutRuntime.sig { returns(T::Array[StringKeyHash]) }
27
26
  attr_reader :members
28
27
 
29
- sig { params(client: StreamChat::Client, channel_type: String, channel_id: T.nilable(String), custom_data: T.nilable(StringKeyHash)).void }
28
+ T::Sig::WithoutRuntime.sig { params(client: StreamChat::Client, channel_type: String, channel_id: T.nilable(String), custom_data: T.nilable(StringKeyHash)).void }
30
29
  def initialize(client, channel_type, channel_id = nil, custom_data = nil)
31
30
  @channel_type = channel_type
32
31
  @id = channel_id
@@ -36,37 +35,42 @@ module StreamChat
36
35
  @members = T.let([], T::Array[StringKeyHash])
37
36
  end
38
37
 
39
- sig { returns(String) }
38
+ T::Sig::WithoutRuntime.sig { returns(String) }
40
39
  def url
41
40
  raise StreamChannelException, 'channel does not have an id' if @id.nil?
42
41
 
43
42
  "channels/#{@channel_type}/#{@id}"
44
43
  end
45
44
 
46
- sig { params(message_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
45
+ # Gets multiple messages from the channel.
46
+ T::Sig::WithoutRuntime.sig { params(message_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
47
47
  def get_messages(message_ids)
48
48
  @client.get("#{url}/messages", params: { 'ids' => message_ids.join(',') })
49
49
  end
50
50
 
51
- sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
51
+ # Sends a message to this channel.
52
+ T::Sig::WithoutRuntime.sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
52
53
  def send_message(message, user_id)
53
54
  payload = { message: add_user_id(message, user_id) }
54
55
  @client.post("#{url}/message", data: payload)
55
56
  end
56
57
 
57
- sig { params(event: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
58
+ # Sends an event on this channel.
59
+ T::Sig::WithoutRuntime.sig { params(event: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
58
60
  def send_event(event, user_id)
59
61
  payload = { 'event' => add_user_id(event, user_id) }
60
62
  @client.post("#{url}/event", data: payload)
61
63
  end
62
64
 
63
- sig { params(message_id: String, reaction: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
65
+ # Sends a new reaction to a given message.
66
+ T::Sig::WithoutRuntime.sig { params(message_id: String, reaction: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
64
67
  def send_reaction(message_id, reaction, user_id)
65
68
  payload = { reaction: add_user_id(reaction, user_id) }
66
69
  @client.post("messages/#{message_id}/reaction", data: payload)
67
70
  end
68
71
 
69
- sig { params(message_id: String, reaction_type: String, user_id: String).returns(StreamChat::StreamResponse) }
72
+ # Delete a reaction from a message.
73
+ T::Sig::WithoutRuntime.sig { params(message_id: String, reaction_type: String, user_id: String).returns(StreamChat::StreamResponse) }
70
74
  def delete_reaction(message_id, reaction_type, user_id)
71
75
  @client.delete(
72
76
  "messages/#{message_id}/reaction/#{reaction_type}",
@@ -74,13 +78,15 @@ module StreamChat
74
78
  )
75
79
  end
76
80
 
77
- sig { params(user_id: String).returns(StreamChat::StreamResponse) }
81
+ # Creates a channel with the given creator user.
82
+ T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
78
83
  def create(user_id)
79
84
  @custom_data['created_by'] = { id: user_id }
80
85
  query(watch: false, state: false, presence: false)
81
86
  end
82
87
 
83
- sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
88
+ # Creates or returns a channel.
89
+ T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
84
90
  def query(**options)
85
91
  payload = { state: true, data: @custom_data }.merge(options)
86
92
  url = "channels/#{@channel_type}"
@@ -91,7 +97,13 @@ module StreamChat
91
97
  state
92
98
  end
93
99
 
94
- sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
100
+ # Queries members of a channel.
101
+ #
102
+ # The queryMembers endpoint allows you to list and paginate members from a channel. The
103
+ # endpoint supports filtering on numerous criteria to efficiently return members information.
104
+ # This endpoint is useful for channels that have large lists of members and
105
+ # you want to search members or if you want to display the full list of members for a channel.
106
+ T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
95
107
  def query_members(filter_conditions = {}, sort: nil, **options)
96
108
  params = {}.merge(options).merge({
97
109
  id: @id,
@@ -110,13 +122,15 @@ module StreamChat
110
122
  @client.get('members', params: { payload: params.to_json })
111
123
  end
112
124
 
113
- sig { params(channel_data: T.nilable(StringKeyHash), update_message: T.nilable(StringKeyHash), options: T.untyped).returns(StreamChat::StreamResponse) }
125
+ # Updates a channel.
126
+ T::Sig::WithoutRuntime.sig { params(channel_data: T.nilable(StringKeyHash), update_message: T.nilable(StringKeyHash), options: T.untyped).returns(StreamChat::StreamResponse) }
114
127
  def update(channel_data, update_message = nil, **options)
115
128
  payload = { data: channel_data, message: update_message }.merge(options)
116
129
  @client.post(url, data: payload)
117
130
  end
118
131
 
119
- sig { params(set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
132
+ # Updates a channel partially.
133
+ T::Sig::WithoutRuntime.sig { params(set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
120
134
  def update_partial(set = nil, unset = nil)
121
135
  raise StreamChannelException, 'set or unset is needed' if set.nil? && unset.nil?
122
136
 
@@ -124,131 +138,169 @@ module StreamChat
124
138
  @client.patch(url, data: payload)
125
139
  end
126
140
 
127
- sig { returns(StreamChat::StreamResponse) }
141
+ # Deletes a channel.
142
+ T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
128
143
  def delete
129
144
  @client.delete(url)
130
145
  end
131
146
 
132
- sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
147
+ # Removes all messages from the channel.
148
+ T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
133
149
  def truncate(**options)
134
150
  @client.post("#{url}/truncate", data: options)
135
151
  end
136
152
 
137
- sig { params(user_id: String, expiration: T.nilable(Integer)).returns(StreamChat::StreamResponse) }
153
+ # Mutes a channel.
154
+ #
155
+ # Messages added to a muted channel will not trigger push notifications, nor change the
156
+ # unread count for the users that muted it. By default, mutes stay in place indefinitely
157
+ # until the user removes it; however, you can optionally set an expiration time. The list
158
+ # of muted channels and their expiration time is returned when the user connects.
159
+ T::Sig::WithoutRuntime.sig { params(user_id: String, expiration: T.nilable(Integer)).returns(StreamChat::StreamResponse) }
138
160
  def mute(user_id, expiration = nil)
139
161
  data = { user_id: user_id, channel_cid: @cid }
140
162
  data['expiration'] = expiration if expiration
141
163
  @client.post('moderation/mute/channel', data: data)
142
164
  end
143
165
 
144
- sig { params(user_id: String).returns(StreamChat::StreamResponse) }
166
+ # Unmutes a channel.
167
+ T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
145
168
  def unmute(user_id)
146
169
  @client.post('moderation/unmute/channel', data: { 'user_id' => user_id, 'channel_cid' => @cid })
147
170
  end
148
171
 
149
- sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
172
+ # Adds members to the channel.
173
+ T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
150
174
  def add_members(user_ids, **options)
151
175
  payload = options.merge({ add_members: user_ids })
152
176
  update(nil, nil, **payload)
153
177
  end
154
178
 
155
- sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
179
+ # Invites users to the channel.
180
+ T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
156
181
  def invite_members(user_ids, **options)
157
182
  payload = options.merge({ invites: user_ids })
158
183
  update(nil, nil, **payload)
159
184
  end
160
185
 
161
- sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
186
+ # Accepts an invitation to the channel.
187
+ T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
162
188
  def accept_invite(user_id, **options)
163
189
  payload = options.merge({ user_id: user_id, accept_invite: true })
164
190
  update(nil, nil, **payload)
165
191
  end
166
192
 
167
- sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
193
+ # Rejects an invitation to the channel.
194
+ T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
168
195
  def reject_invite(user_id, **options)
169
196
  payload = options.merge({ user_id: user_id, reject_invite: true })
170
197
  update(nil, nil, **payload)
171
198
  end
172
199
 
173
- sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
200
+ # Adds moderators to the channel.
201
+ T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
174
202
  def add_moderators(user_ids)
175
203
  update(nil, nil, add_moderators: user_ids)
176
204
  end
177
205
 
178
- sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
206
+ # Removes members from the channel.
207
+ T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
179
208
  def remove_members(user_ids)
180
209
  update(nil, nil, remove_members: user_ids)
181
210
  end
182
211
 
183
- sig { params(members: T::Array[StringKeyHash], message: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
212
+ # Assigns roles to members in the channel.
213
+ T::Sig::WithoutRuntime.sig { params(members: T::Array[StringKeyHash], message: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
184
214
  def assign_roles(members, message = nil)
185
215
  update(nil, message, assign_roles: members)
186
216
  end
187
217
 
188
- sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
218
+ # Demotes moderators in the channel.
219
+ T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
189
220
  def demote_moderators(user_ids)
190
221
  update(nil, nil, demote_moderators: user_ids)
191
222
  end
192
223
 
193
- sig { params(user_id: String, options: StringKeyHash).returns(StreamChat::StreamResponse) }
224
+ # Sends the mark read event for this user, only works if the `read_events` setting is enabled.
225
+ T::Sig::WithoutRuntime.sig { params(user_id: String, options: StringKeyHash).returns(StreamChat::StreamResponse) }
194
226
  def mark_read(user_id, **options)
195
227
  payload = add_user_id(options, user_id)
196
228
  @client.post("#{url}/read", data: payload)
197
229
  end
198
230
 
199
- sig { params(parent_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
231
+ # List the message replies for a parent message.
232
+ T::Sig::WithoutRuntime.sig { params(parent_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
200
233
  def get_replies(parent_id, **options)
201
234
  @client.get("messages/#{parent_id}/replies", params: options)
202
235
  end
203
236
 
204
- sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
237
+ # List the reactions, supports pagination.
238
+ T::Sig::WithoutRuntime.sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
205
239
  def get_reactions(message_id, **options)
206
240
  @client.get("messages/#{message_id}/reactions", params: options)
207
241
  end
208
242
 
209
- sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
243
+ # Bans a user from this channel.
244
+ T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
210
245
  def ban_user(user_id, **options)
211
246
  @client.ban_user(user_id, type: @channel_type, id: @id, **options)
212
247
  end
213
248
 
214
- sig { params(user_id: String).returns(StreamChat::StreamResponse) }
249
+ # Removes the ban for a user on this channel.
250
+ T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
215
251
  def unban_user(user_id)
216
252
  @client.unban_user(user_id, type: @channel_type, id: @id)
217
253
  end
218
254
 
219
- sig { params(user_id: String).returns(StreamChat::StreamResponse) }
255
+ # Removes a channel from query channel requests for that user until a new message is added.
256
+ # Use `show` to cancel this operation.
257
+ T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
220
258
  def hide(user_id)
221
259
  @client.post("#{url}/hide", data: { user_id: user_id })
222
260
  end
223
261
 
224
- sig { params(user_id: String).returns(StreamChat::StreamResponse) }
262
+ # Shows a previously hidden channel.
263
+ # Use `hide` to hide a channel.
264
+ T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
225
265
  def show(user_id)
226
266
  @client.post("#{url}/show", data: { user_id: user_id })
227
267
  end
228
268
 
229
- sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
269
+ # Uploads a file.
270
+ #
271
+ # This functionality defaults to using the Stream CDN. If you would like, you can
272
+ # easily change the logic to upload to your own CDN of choice.
273
+ T::Sig::WithoutRuntime.sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
230
274
  def send_file(url, user, content_type = nil)
231
275
  @client.send_file("#{self.url}/file", url, user, content_type)
232
276
  end
233
277
 
234
- sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
278
+ # Uploads an image.
279
+ #
280
+ # Stream supported image types are: image/bmp, image/gif, image/jpeg, image/png, image/webp,
281
+ # image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
282
+ # You can set a more restrictive list for your application if needed.
283
+ # The maximum file size is 100MB.
284
+ T::Sig::WithoutRuntime.sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
235
285
  def send_image(url, user, content_type = nil)
236
286
  @client.send_file("#{self.url}/image", url, user, content_type)
237
287
  end
238
288
 
239
- sig { params(url: String).returns(StreamChat::StreamResponse) }
289
+ # Deletes a file by file url.
290
+ T::Sig::WithoutRuntime.sig { params(url: String).returns(StreamChat::StreamResponse) }
240
291
  def delete_file(url)
241
292
  @client.delete("#{self.url}/file", params: { url: url })
242
293
  end
243
294
 
244
- sig { params(url: String).returns(StreamChat::StreamResponse) }
295
+ # Deletes an image by image url.
296
+ T::Sig::WithoutRuntime.sig { params(url: String).returns(StreamChat::StreamResponse) }
245
297
  def delete_image(url)
246
298
  @client.delete("#{self.url}/image", params: { url: url })
247
299
  end
248
300
 
249
301
  private
250
302
 
251
- sig { params(payload: StringKeyHash, user_id: String).returns(StringKeyHash) }
303
+ T::Sig::WithoutRuntime.sig { params(payload: StringKeyHash, user_id: String).returns(StringKeyHash) }
252
304
  def add_user_id(payload, user_id)
253
305
  payload.merge({ user: { id: user_id } })
254
306
  end