stream-chat-ruby 2.22.0 → 2.22.1

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: 0bfc513b8901c9efe810c00bb59d9aa23b3e12e0816af1896c31a54b69614053
4
+ data.tar.gz: ad8e9b4f3b2e4f1a4515226382e8fbf243acfdb46bbab93ba0c9a5c27d8208de
5
5
  SHA512:
6
- metadata.gz: f2cb64ead68735919747ca939dbd4185440d44a5f52164524d874ec98765a37207b3126a63afa30a6de0eb3faadac0f93561c4ecd246add31eb69e6bab6add52
7
- data.tar.gz: f6bdf47417e6ed4af0d2a0ed2eb9c775bdb7a4ea5bff3b89bff69c7b702edf892d4009e8e521e067c3a65eb9251e3728e76cbbf9f72e6a90e169907920e65bc0
6
+ metadata.gz: 8189c936e8c1df17285a51e5410be20f1c6852f92f688a8b1292a971550399404848739772099cfd6e506c89fa5911063793ba46859d757160aa7fe000c8ed8d
7
+ data.tar.gz: 47de88506b215de1098ae643e7f08cd3636a71709470057a7d672849479f28351f66851e22508e31a59e888bb10b71cf1af99521f15884e1bf385f6b1b760d72
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
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.22.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.0...v2.22.1) (2022-04-20)
6
+
7
+ ### Features
8
+
9
+ * 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))
10
+
5
11
  ## [2.22.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.21.0...v2.22.0) (2022-04-01)
6
12
 
7
13
 
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
@@ -43,29 +43,34 @@ module StreamChat
43
43
  "channels/#{@channel_type}/#{@id}"
44
44
  end
45
45
 
46
+ # Gets multiple messages from the channel.
46
47
  sig { params(message_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
47
48
  def get_messages(message_ids)
48
49
  @client.get("#{url}/messages", params: { 'ids' => message_ids.join(',') })
49
50
  end
50
51
 
52
+ # Sends a message to this channel.
51
53
  sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
52
54
  def send_message(message, user_id)
53
55
  payload = { message: add_user_id(message, user_id) }
54
56
  @client.post("#{url}/message", data: payload)
55
57
  end
56
58
 
59
+ # Sends an event on this channel.
57
60
  sig { params(event: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
58
61
  def send_event(event, user_id)
59
62
  payload = { 'event' => add_user_id(event, user_id) }
60
63
  @client.post("#{url}/event", data: payload)
61
64
  end
62
65
 
66
+ # Sends a new reaction to a given message.
63
67
  sig { params(message_id: String, reaction: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
64
68
  def send_reaction(message_id, reaction, user_id)
65
69
  payload = { reaction: add_user_id(reaction, user_id) }
66
70
  @client.post("messages/#{message_id}/reaction", data: payload)
67
71
  end
68
72
 
73
+ # Delete a reaction from a message.
69
74
  sig { params(message_id: String, reaction_type: String, user_id: String).returns(StreamChat::StreamResponse) }
70
75
  def delete_reaction(message_id, reaction_type, user_id)
71
76
  @client.delete(
@@ -74,12 +79,14 @@ module StreamChat
74
79
  )
75
80
  end
76
81
 
82
+ # Creates a channel with the given creator user.
77
83
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
78
84
  def create(user_id)
79
85
  @custom_data['created_by'] = { id: user_id }
80
86
  query(watch: false, state: false, presence: false)
81
87
  end
82
88
 
89
+ # Creates or returns a channel.
83
90
  sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
84
91
  def query(**options)
85
92
  payload = { state: true, data: @custom_data }.merge(options)
@@ -91,6 +98,12 @@ module StreamChat
91
98
  state
92
99
  end
93
100
 
101
+ # Queries members of a channel.
102
+ #
103
+ # The queryMembers endpoint allows you to list and paginate members from a channel. The
104
+ # endpoint supports filtering on numerous criteria to efficiently return members information.
105
+ # This endpoint is useful for channels that have large lists of members and
106
+ # you want to search members or if you want to display the full list of members for a channel.
94
107
  sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
95
108
  def query_members(filter_conditions = {}, sort: nil, **options)
96
109
  params = {}.merge(options).merge({
@@ -110,12 +123,14 @@ module StreamChat
110
123
  @client.get('members', params: { payload: params.to_json })
111
124
  end
112
125
 
126
+ # Updates a channel.
113
127
  sig { params(channel_data: T.nilable(StringKeyHash), update_message: T.nilable(StringKeyHash), options: T.untyped).returns(StreamChat::StreamResponse) }
114
128
  def update(channel_data, update_message = nil, **options)
115
129
  payload = { data: channel_data, message: update_message }.merge(options)
116
130
  @client.post(url, data: payload)
117
131
  end
118
132
 
133
+ # Updates a channel partially.
119
134
  sig { params(set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
120
135
  def update_partial(set = nil, unset = nil)
121
136
  raise StreamChannelException, 'set or unset is needed' if set.nil? && unset.nil?
@@ -124,16 +139,24 @@ module StreamChat
124
139
  @client.patch(url, data: payload)
125
140
  end
126
141
 
142
+ # Deletes a channel.
127
143
  sig { returns(StreamChat::StreamResponse) }
128
144
  def delete
129
145
  @client.delete(url)
130
146
  end
131
147
 
148
+ # Removes all messages from the channel.
132
149
  sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
133
150
  def truncate(**options)
134
151
  @client.post("#{url}/truncate", data: options)
135
152
  end
136
153
 
154
+ # Mutes a channel.
155
+ #
156
+ # Messages added to a muted channel will not trigger push notifications, nor change the
157
+ # unread count for the users that muted it. By default, mutes stay in place indefinitely
158
+ # until the user removes it; however, you can optionally set an expiration time. The list
159
+ # of muted channels and their expiration time is returned when the user connects.
137
160
  sig { params(user_id: String, expiration: T.nilable(Integer)).returns(StreamChat::StreamResponse) }
138
161
  def mute(user_id, expiration = nil)
139
162
  data = { user_id: user_id, channel_cid: @cid }
@@ -141,106 +164,136 @@ module StreamChat
141
164
  @client.post('moderation/mute/channel', data: data)
142
165
  end
143
166
 
167
+ # Unmutes a channel.
144
168
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
145
169
  def unmute(user_id)
146
170
  @client.post('moderation/unmute/channel', data: { 'user_id' => user_id, 'channel_cid' => @cid })
147
171
  end
148
172
 
173
+ # Adds members to the channel.
149
174
  sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
150
175
  def add_members(user_ids, **options)
151
176
  payload = options.merge({ add_members: user_ids })
152
177
  update(nil, nil, **payload)
153
178
  end
154
179
 
180
+ # Invites users to the channel.
155
181
  sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
156
182
  def invite_members(user_ids, **options)
157
183
  payload = options.merge({ invites: user_ids })
158
184
  update(nil, nil, **payload)
159
185
  end
160
186
 
187
+ # Accepts an invitation to the channel.
161
188
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
162
189
  def accept_invite(user_id, **options)
163
190
  payload = options.merge({ user_id: user_id, accept_invite: true })
164
191
  update(nil, nil, **payload)
165
192
  end
166
193
 
194
+ # Rejects an invitation to the channel.
167
195
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
168
196
  def reject_invite(user_id, **options)
169
197
  payload = options.merge({ user_id: user_id, reject_invite: true })
170
198
  update(nil, nil, **payload)
171
199
  end
172
200
 
201
+ # Adds moderators to the channel.
173
202
  sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
174
203
  def add_moderators(user_ids)
175
204
  update(nil, nil, add_moderators: user_ids)
176
205
  end
177
206
 
207
+ # Removes members from the channel.
178
208
  sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
179
209
  def remove_members(user_ids)
180
210
  update(nil, nil, remove_members: user_ids)
181
211
  end
182
212
 
213
+ # Assigns roles to members in the channel.
183
214
  sig { params(members: T::Array[StringKeyHash], message: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
184
215
  def assign_roles(members, message = nil)
185
216
  update(nil, message, assign_roles: members)
186
217
  end
187
218
 
219
+ # Demotes moderators in the channel.
188
220
  sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
189
221
  def demote_moderators(user_ids)
190
222
  update(nil, nil, demote_moderators: user_ids)
191
223
  end
192
224
 
225
+ # Sends the mark read event for this user, only works if the `read_events` setting is enabled.
193
226
  sig { params(user_id: String, options: StringKeyHash).returns(StreamChat::StreamResponse) }
194
227
  def mark_read(user_id, **options)
195
228
  payload = add_user_id(options, user_id)
196
229
  @client.post("#{url}/read", data: payload)
197
230
  end
198
231
 
232
+ # List the message replies for a parent message.
199
233
  sig { params(parent_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
200
234
  def get_replies(parent_id, **options)
201
235
  @client.get("messages/#{parent_id}/replies", params: options)
202
236
  end
203
237
 
238
+ # List the reactions, supports pagination.
204
239
  sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
205
240
  def get_reactions(message_id, **options)
206
241
  @client.get("messages/#{message_id}/reactions", params: options)
207
242
  end
208
243
 
244
+ # Bans a user from this channel.
209
245
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
210
246
  def ban_user(user_id, **options)
211
247
  @client.ban_user(user_id, type: @channel_type, id: @id, **options)
212
248
  end
213
249
 
250
+ # Removes the ban for a user on this channel.
214
251
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
215
252
  def unban_user(user_id)
216
253
  @client.unban_user(user_id, type: @channel_type, id: @id)
217
254
  end
218
255
 
256
+ # Removes a channel from query channel requests for that user until a new message is added.
257
+ # Use `show` to cancel this operation.
219
258
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
220
259
  def hide(user_id)
221
260
  @client.post("#{url}/hide", data: { user_id: user_id })
222
261
  end
223
262
 
263
+ # Shows a previously hidden channel.
264
+ # Use `hide` to hide a channel.
224
265
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
225
266
  def show(user_id)
226
267
  @client.post("#{url}/show", data: { user_id: user_id })
227
268
  end
228
269
 
270
+ # Uploads a file.
271
+ #
272
+ # This functionality defaults to using the Stream CDN. If you would like, you can
273
+ # easily change the logic to upload to your own CDN of choice.
229
274
  sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
230
275
  def send_file(url, user, content_type = nil)
231
276
  @client.send_file("#{self.url}/file", url, user, content_type)
232
277
  end
233
278
 
279
+ # Uploads an image.
280
+ #
281
+ # Stream supported image types are: image/bmp, image/gif, image/jpeg, image/png, image/webp,
282
+ # image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
283
+ # You can set a more restrictive list for your application if needed.
284
+ # The maximum file size is 100MB.
234
285
  sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
235
286
  def send_image(url, user, content_type = nil)
236
287
  @client.send_file("#{self.url}/image", url, user, content_type)
237
288
  end
238
289
 
290
+ # Deletes a file by file url.
239
291
  sig { params(url: String).returns(StreamChat::StreamResponse) }
240
292
  def delete_file(url)
241
293
  @client.delete("#{self.url}/file", params: { url: url })
242
294
  end
243
295
 
296
+ # Deletes an image by image url.
244
297
  sig { params(url: String).returns(StreamChat::StreamResponse) }
245
298
  def delete_image(url)
246
299
  @client.delete("#{self.url}/image", params: { url: url })
@@ -90,6 +90,12 @@ module StreamChat
90
90
  @conn = client
91
91
  end
92
92
 
93
+ # Creates a JWT for a user.
94
+ #
95
+ # Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to login.
96
+ # Knowing whether a user is authorized to perform certain actions is managed
97
+ # separately via a role based permissions system.
98
+ # You can set an `exp` (expires at) or `iat` (issued at) claim as well.
93
99
  sig { params(user_id: String, exp: T.nilable(Integer), iat: T.nilable(Integer)).returns(String) }
94
100
  def create_token(user_id, exp = nil, iat = nil)
95
101
  payload = { user_id: user_id }
@@ -98,28 +104,41 @@ module StreamChat
98
104
  JWT.encode(payload, @api_secret, 'HS256')
99
105
  end
100
106
 
107
+ # Updates application settings.
101
108
  sig { params(settings: T.untyped).returns(StreamChat::StreamResponse) }
102
109
  def update_app_settings(**settings)
103
110
  patch('app', data: settings)
104
111
  end
105
112
 
113
+ # Returns application settings.
106
114
  sig { returns(StreamChat::StreamResponse) }
107
115
  def get_app_settings
108
116
  get('app')
109
117
  end
110
118
 
119
+ # Flags a message.
120
+ #
121
+ # Any user is allowed to flag a message. This triggers the message.flagged
122
+ # webhook event and adds the message to the inbox of your
123
+ # Stream Dashboard Chat Moderation view.
111
124
  sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
112
125
  def flag_message(id, **options)
113
126
  payload = { target_message_id: id }.merge(options)
114
127
  post('moderation/flag', data: payload)
115
128
  end
116
129
 
130
+ # Unflags a message.
117
131
  sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
118
132
  def unflag_message(id, **options)
119
133
  payload = { target_message_id: id }.merge(options)
120
134
  post('moderation/unflag', data: payload)
121
135
  end
122
136
 
137
+ # Queries message flags.
138
+ #
139
+ # If you prefer to build your own in app moderation dashboard, rather than use the Stream
140
+ # dashboard, then the query message flags endpoint lets you get flagged messages. Similar
141
+ # to other queries in Stream Chat, you can filter the flags using query operators.
123
142
  sig { params(filter_conditions: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
124
143
  def query_message_flags(filter_conditions, **options)
125
144
  params = options.merge({
@@ -128,24 +147,28 @@ module StreamChat
128
147
  get('moderation/flags/message', params: { payload: params.to_json })
129
148
  end
130
149
 
150
+ # Flags a user.
131
151
  sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
132
152
  def flag_user(id, **options)
133
153
  payload = { target_user_id: id }.merge(options)
134
154
  post('moderation/flag', data: payload)
135
155
  end
136
156
 
157
+ # Unflags a user.
137
158
  sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
138
159
  def unflag_user(id, **options)
139
160
  payload = { target_user_id: id }.merge(options)
140
161
  post('moderation/unflag', data: payload)
141
162
  end
142
163
 
164
+ # Queries flag reports.
143
165
  sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
144
166
  def query_flag_reports(**options)
145
167
  data = { filter_conditions: options }
146
168
  post('moderation/reports', data: data)
147
169
  end
148
170
 
171
+ # Sends a flag report review.
149
172
  sig { params(report_id: String, review_result: String, user_id: String, details: T.untyped).returns(StreamChat::StreamResponse) }
150
173
  def review_flag_report(report_id, review_result, user_id, **details)
151
174
  data = {
@@ -156,11 +179,16 @@ module StreamChat
156
179
  patch("moderation/reports/#{report_id}", data: data)
157
180
  end
158
181
 
182
+ # Returns a message.
159
183
  sig { params(id: String).returns(StreamChat::StreamResponse) }
160
184
  def get_message(id)
161
185
  get("messages/#{id}")
162
186
  end
163
187
 
188
+ # Searches for messages.
189
+ #
190
+ # You can enable and/or disable the search indexing on a per channel basis
191
+ # type through the Stream Dashboard.
164
192
  sig { params(filter_conditions: StringKeyHash, query: T.any(String, StringKeyHash), sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
165
193
  def search(filter_conditions, query, sort: nil, **options)
166
194
  offset = T.cast(options[:offset], T.nilable(Integer))
@@ -193,6 +221,7 @@ module StreamChat
193
221
  upsert_user(user)
194
222
  end
195
223
 
224
+ # Creates or updates users.
196
225
  sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
197
226
  def upsert_users(users)
198
227
  payload = {}
@@ -205,83 +234,115 @@ module StreamChat
205
234
  post('users', data: { users: payload })
206
235
  end
207
236
 
237
+ # Creates or updates a user.
208
238
  sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
209
239
  def upsert_user(user)
210
240
  upsert_users([user])
211
241
  end
212
242
 
243
+ # Updates multiple users partially.
213
244
  sig { params(updates: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
214
245
  def update_users_partial(updates)
215
246
  patch('users', data: { users: updates })
216
247
  end
217
248
 
249
+ # Updates a single user partially.
218
250
  sig { params(update: StringKeyHash).returns(StreamChat::StreamResponse) }
219
251
  def update_user_partial(update)
220
252
  update_users_partial([update])
221
253
  end
222
254
 
255
+ # Deletes a user synchronously.
223
256
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
224
257
  def delete_user(user_id, **options)
225
258
  delete("users/#{user_id}", params: options)
226
259
  end
227
260
 
261
+ # Deactivates a user.
262
+ # Deactivated users cannot connect to Stream Chat, and can't send or receive messages.
263
+ # To reactivate a user, use `reactivate_user` method.
228
264
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
229
265
  def deactivate_user(user_id, **options)
230
266
  post("users/#{user_id}/deactivate", params: options)
231
267
  end
232
268
 
269
+ # Reactivates a deactivated user. Use deactivate_user to deactivate a user.
233
270
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
234
271
  def reactivate_user(user_id, **options)
235
272
  post("users/#{user_id}/reactivate", params: options)
236
273
  end
237
274
 
275
+ # Exports a user. It exports a user and returns an object
276
+ # containing all of it's data.
238
277
  sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
239
278
  def export_user(user_id, **options)
240
279
  get("users/#{user_id}/export", params: options)
241
280
  end
242
281
 
282
+ # Bans a user. Users can be banned from an app entirely or from a channel.
283
+ # When a user is banned, they will not be allowed to post messages until the
284
+ # ban is removed or expired but will be able to connect to Chat and to channels as before.
285
+ # To unban a user, use `unban_user` method.
243
286
  sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
244
287
  def ban_user(target_id, **options)
245
288
  payload = { target_user_id: target_id }.merge(options)
246
289
  post('moderation/ban', data: payload)
247
290
  end
248
291
 
292
+ # Unbans a user.
293
+ # To ban a user, use `ban_user` method.
249
294
  sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
250
295
  def unban_user(target_id, **options)
251
296
  params = { target_user_id: target_id }.merge(options)
252
297
  delete('moderation/ban', params: params)
253
298
  end
254
299
 
300
+ # Shadow ban a user.
301
+ # When a user is shadow banned, they will still be allowed to post messages,
302
+ # but any message sent during the will only be visible to the messages author
303
+ # and invisible to other users of the App.
304
+ # To remove a shadow ban, use `remove_shadow_ban` method.
255
305
  sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
256
306
  def shadow_ban(target_id, **options)
257
307
  payload = { target_user_id: target_id, shadow: true }.merge(options)
258
308
  post('moderation/ban', data: payload)
259
309
  end
260
310
 
311
+ # Removes a shadow ban of a user.
312
+ # To shadow ban a user, use `shadow_ban` method.
261
313
  sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
262
314
  def remove_shadow_ban(target_id, **options)
263
315
  params = { target_user_id: target_id, shadow: true }.merge(options)
264
316
  delete('moderation/ban', params: params)
265
317
  end
266
318
 
319
+ # Mutes a user.
267
320
  sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
268
321
  def mute_user(target_id, user_id)
269
322
  payload = { target_id: target_id, user_id: user_id }
270
323
  post('moderation/mute', data: payload)
271
324
  end
272
325
 
326
+ # Unmutes a user.
273
327
  sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
274
328
  def unmute_user(target_id, user_id)
275
329
  payload = { target_id: target_id, user_id: user_id }
276
330
  post('moderation/unmute', data: payload)
277
331
  end
278
332
 
333
+ # Marks all messages as read for a user.
279
334
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
280
335
  def mark_all_read(user_id)
281
336
  payload = { user: { id: user_id } }
282
337
  post('channels/read', data: payload)
283
338
  end
284
339
 
340
+ # Pins a message.
341
+ #
342
+ # Pinned messages allow users to highlight important messages, make announcements, or temporarily
343
+ # promote content. Pinning a message is, by default, restricted to certain user roles,
344
+ # but this is flexible. Each channel can have multiple pinned messages and these can be created
345
+ # or updated with or without an expiration.
285
346
  sig { params(message_id: String, user_id: String, expiration: T.nilable(String)).returns(StreamChat::StreamResponse) }
286
347
  def pin_message(message_id, user_id, expiration: nil)
287
348
  updates = {
@@ -293,6 +354,7 @@ module StreamChat
293
354
  update_message_partial(message_id, updates, user_id: user_id)
294
355
  end
295
356
 
357
+ # Unpins a message.
296
358
  sig { params(message_id: String, user_id: String).returns(StreamChat::StreamResponse) }
297
359
  def unpin_message(message_id, user_id)
298
360
  updates = {
@@ -303,6 +365,8 @@ module StreamChat
303
365
  update_message_partial(message_id, updates, user_id: user_id)
304
366
  end
305
367
 
368
+ # Updates a message. Fully overwrites a message.
369
+ # For partial update, use `update_message_partial` method.
306
370
  sig { params(message: StringKeyHash).returns(StreamChat::StreamResponse) }
307
371
  def update_message(message)
308
372
  raise ArgumentError, 'message must have an id' unless message.key? 'id'
@@ -310,6 +374,9 @@ module StreamChat
310
374
  post("messages/#{message['id']}", data: { message: message })
311
375
  end
312
376
 
377
+ # Updates a message partially.
378
+ # A partial update can be used to set and unset specific fields when
379
+ # it is necessary to retain additional data fields on the object. AKA a patch style update.
313
380
  sig { params(message_id: String, updates: StringKeyHash, user_id: T.nilable(String), options: T.untyped).returns(StreamChat::StreamResponse) }
314
381
  def update_message_partial(message_id, updates, user_id: nil, **options)
315
382
  params = updates.merge(options)
@@ -317,11 +384,19 @@ module StreamChat
317
384
  put("messages/#{message_id}", data: params)
318
385
  end
319
386
 
387
+ # Deletes a message.
320
388
  sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
321
389
  def delete_message(message_id, **options)
322
390
  delete("messages/#{message_id}", params: options)
323
391
  end
324
392
 
393
+ # Queries banned users.
394
+ #
395
+ # Banned users can be retrieved in different ways:
396
+ # 1) Using the dedicated query bans endpoint
397
+ # 2) User Search: you can add the banned:true condition to your search. Please note that
398
+ # this will only return users that were banned at the app-level and not the ones
399
+ # that were banned only on channels.
325
400
  sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
326
401
  def query_banned_users(filter_conditions, sort: nil, **options)
327
402
  params = options.merge({
@@ -331,6 +406,8 @@ module StreamChat
331
406
  get('query_banned_users', params: { payload: params.to_json })
332
407
  end
333
408
 
409
+ # Allows you to search for users and see if they are online/offline.
410
+ # You can filter and sort on the custom fields you've set for your user, the user id, and when the user was last active.
334
411
  sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
335
412
  def query_users(filter_conditions, sort: nil, **options)
336
413
  params = options.merge({
@@ -340,6 +417,12 @@ module StreamChat
340
417
  get('users', params: { payload: params.to_json })
341
418
  end
342
419
 
420
+ # Queries channels.
421
+ #
422
+ # You can query channels based on built-in fields as well as any custom field you add to channels.
423
+ # Multiple filters can be combined using AND, OR logical operators, each filter can use its
424
+ # comparison (equality, inequality, greater than, greater or equal, etc.).
425
+ # You can find the complete list of supported operators in the query syntax section of the docs.
343
426
  sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
344
427
  def query_channels(filter_conditions, sort: nil, **options)
345
428
  data = { state: true, watch: false, presence: false }
@@ -350,27 +433,32 @@ module StreamChat
350
433
  post('channels', data: data)
351
434
  end
352
435
 
436
+ # Creates a new channel type.
353
437
  sig { params(data: StringKeyHash).returns(StreamChat::StreamResponse) }
354
438
  def create_channel_type(data)
355
439
  data['commands'] = ['all'] unless data.key?('commands') || data['commands'].nil? || data['commands'].empty?
356
440
  post('channeltypes', data: data)
357
441
  end
358
442
 
443
+ # Returns a channel types.
359
444
  sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
360
445
  def get_channel_type(channel_type)
361
446
  get("channeltypes/#{channel_type}")
362
447
  end
363
448
 
449
+ # Returns a list of channel types.
364
450
  sig { returns(StreamChat::StreamResponse) }
365
451
  def list_channel_types
366
452
  get('channeltypes')
367
453
  end
368
454
 
455
+ # Updates a channel type.
369
456
  sig { params(channel_type: String, options: T.untyped).returns(StreamChat::StreamResponse) }
370
457
  def update_channel_type(channel_type, **options)
371
458
  put("channeltypes/#{channel_type}", data: options)
372
459
  end
373
460
 
461
+ # Deletes a channel type.
374
462
  sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
375
463
  def delete_channel_type(channel_type)
376
464
  delete("channeltypes/#{channel_type}")
@@ -389,6 +477,7 @@ module StreamChat
389
477
  StreamChat::Channel.new(self, channel_type, channel_id, data)
390
478
  end
391
479
 
480
+ # Adds a device to a user.
392
481
  sig { params(device_id: String, push_provider: String, user_id: String, push_provider_name: T.nilable(String)).returns(StreamChat::StreamResponse) }
393
482
  def add_device(device_id, push_provider, user_id, push_provider_name = nil)
394
483
  post('devices', data: {
@@ -399,16 +488,20 @@ module StreamChat
399
488
  })
400
489
  end
401
490
 
491
+ # Delete a device.
402
492
  sig { params(device_id: String, user_id: String).returns(StreamChat::StreamResponse) }
403
493
  def delete_device(device_id, user_id)
404
494
  delete('devices', params: { id: device_id, user_id: user_id })
405
495
  end
406
496
 
497
+ # Returns a list of devices.
407
498
  sig { params(user_id: String).returns(StreamChat::StreamResponse) }
408
499
  def get_devices(user_id)
409
500
  get('devices', params: { user_id: user_id })
410
501
  end
411
502
 
503
+ # Get rate limit quotas and usage.
504
+ # If no params are toggled, all limits for all endpoints are returned.
412
505
  sig { params(server_side: T::Boolean, android: T::Boolean, ios: T::Boolean, web: T::Boolean, endpoints: T::Array[String]).returns(StreamChat::StreamResponse) }
413
506
  def get_rate_limits(server_side: false, android: false, ios: false, web: false, endpoints: [])
414
507
  params = {}
@@ -421,93 +514,153 @@ module StreamChat
421
514
  get('rate_limits', params: params)
422
515
  end
423
516
 
517
+ # Verify the signature added to a webhook event.
424
518
  sig { params(request_body: String, x_signature: String).returns(T::Boolean) }
425
519
  def verify_webhook(request_body, x_signature)
426
520
  signature = OpenSSL::HMAC.hexdigest('SHA256', @api_secret, request_body)
427
521
  signature == x_signature
428
522
  end
429
523
 
524
+ # Allows you to send custom events to a connected user.
430
525
  sig { params(user_id: String, event: StringKeyHash).returns(StreamChat::StreamResponse) }
431
526
  def send_user_event(user_id, event)
432
527
  post("users/#{user_id}/event", data: event)
433
528
  end
434
529
 
530
+ # Translates an existing message to another language. The source language
531
+ # is inferred from the user language or detected automatically by analyzing its text.
532
+ # If possible it is recommended to store the user language. See the documentation.
435
533
  sig { params(message_id: String, language: String).returns(StreamChat::StreamResponse) }
436
534
  def translate_message(message_id, language)
437
535
  post("messages/#{message_id}/translate", data: { language: language })
438
536
  end
439
537
 
538
+ # Runs a message command action.
440
539
  sig { params(message_id: String, data: StringKeyHash).returns(StreamChat::StreamResponse) }
441
540
  def run_message_action(message_id, data)
442
541
  post("messages/#{message_id}/action", data: data)
443
542
  end
444
543
 
544
+ # Creates a guest user.
545
+ #
546
+ # Guest sessions can be created client-side and do not require any server-side authentication.
547
+ # Support and livestreams are common use cases for guests users because really
548
+ # often you want a visitor to be able to use chat on your application without (or before)
549
+ # they have a regular user account.
445
550
  sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
446
551
  def create_guest(user)
447
552
  post('guests', data: user)
448
553
  end
449
554
 
555
+ # Returns all blocklists.
556
+ #
557
+ # A Block List is a list of words that you can use to moderate chat messages. Stream Chat
558
+ # comes with a built-in Block List called profanity_en_2020_v1 which contains over a thousand
559
+ # of the most common profane words.
560
+ # You can manage your own block lists via the Stream dashboard or APIs to a manage
561
+ # blocklists and configure your channel types to use them.
450
562
  sig { returns(StreamChat::StreamResponse) }
451
563
  def list_blocklists
452
564
  get('blocklists')
453
565
  end
454
566
 
567
+ # Returns a blocklist.
568
+ #
569
+ # A Block List is a list of words that you can use to moderate chat messages. Stream Chat
570
+ # comes with a built-in Block List called profanity_en_2020_v1 which contains over a thousand
571
+ # of the most common profane words.
572
+ # You can manage your own block lists via the Stream dashboard or APIs to a manage
573
+ # blocklists and configure your channel types to use them.
455
574
  sig { params(name: String).returns(StreamChat::StreamResponse) }
456
575
  def get_blocklist(name)
457
576
  get("blocklists/#{name}")
458
577
  end
459
578
 
579
+ # Creates a blocklist.
580
+ #
581
+ # A Block List is a list of words that you can use to moderate chat messages. Stream Chat
582
+ # comes with a built-in Block List called profanity_en_2020_v1 which contains over a thousand
583
+ # of the most common profane words.
584
+ # You can manage your own block lists via the Stream dashboard or APIs to a manage
585
+ # blocklists and configure your channel types to use them.
460
586
  sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
461
587
  def create_blocklist(name, words)
462
588
  post('blocklists', data: { name: name, words: words })
463
589
  end
464
590
 
591
+ # Updates a blocklist.
592
+ #
593
+ # A Block List is a list of words that you can use to moderate chat messages. Stream Chat
594
+ # comes with a built-in Block List called profanity_en_2020_v1 which contains over a thousand
595
+ # of the most common profane words.
596
+ # You can manage your own block lists via the Stream dashboard or APIs to a manage
597
+ # blocklists and configure your channel types to use them.
465
598
  sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
466
599
  def update_blocklist(name, words)
467
600
  put("blocklists/#{name}", data: { words: words })
468
601
  end
469
602
 
603
+ # Deletes a blocklist.
604
+ #
605
+ # A Block List is a list of words that you can use to moderate chat messages. Stream Chat
606
+ # comes with a built-in Block List called profanity_en_2020_v1 which contains over a thousand
607
+ # of the most common profane words.
608
+ # You can manage your own block lists via the Stream dashboard or APIs to a manage
609
+ # blocklists and configure your channel types to use them.
470
610
  sig { params(name: String).returns(StreamChat::StreamResponse) }
471
611
  def delete_blocklist(name)
472
612
  delete("blocklists/#{name}")
473
613
  end
474
614
 
615
+ # Requests a channel export.
616
+ #
617
+ # Channel exports are created asynchronously, you can use the Task ID returned by
618
+ # the APIs to keep track of the status and to download the final result when it is ready.
619
+ # Use `get_task` to check the status of the export.
475
620
  sig { params(channels: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
476
621
  def export_channels(*channels, **options)
477
622
  post('export_channels', data: { channels: channels, **options })
478
623
  end
479
624
 
625
+ # Returns the status of a channel export. It contains the URL to the JSON file.
480
626
  sig { params(task_id: String).returns(StreamChat::StreamResponse) }
481
627
  def get_export_channel_status(task_id)
482
628
  get("export_channels/#{task_id}")
483
629
  end
484
630
 
631
+ # Returns the status of a task.
485
632
  sig { params(task_id: String).returns(StreamChat::StreamResponse) }
486
633
  def get_task(task_id)
487
634
  get("tasks/#{task_id}")
488
635
  end
489
636
 
637
+ # Delete users asynchronously. Use `get_task` to check the status of the task.
490
638
  sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(StringKeyHash), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
491
639
  def delete_users(user_ids, user: SOFT_DELETE, messages: nil, conversations: nil)
492
640
  post('users/delete', data: { user_ids: user_ids, user: user, messages: messages, conversations: conversations })
493
641
  end
494
642
 
643
+ # Deletes multiple channels. This is an asynchronous operation and the returned value is a task Id.
644
+ # You can use `get_task` method to check the status of the task.
495
645
  sig { params(cids: T::Array[String], hard_delete: T::Boolean).returns(StreamChat::StreamResponse) }
496
646
  def delete_channels(cids, hard_delete: false)
497
647
  post('channels/delete', data: { cids: cids, hard_delete: hard_delete })
498
648
  end
499
649
 
650
+ # Revoke tokens for an application issued since the given date.
500
651
  sig { params(before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
501
652
  def revoke_tokens(before)
502
653
  before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
503
654
  update_app_settings({ 'revoke_tokens_issued_before' => before })
504
655
  end
505
656
 
657
+ # Revoke tokens for a user issued since the given date.
506
658
  sig { params(user_id: String, before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
507
659
  def revoke_user_token(user_id, before)
508
660
  revoke_users_token([user_id], before)
509
661
  end
510
662
 
663
+ # Revoke tokens for users issued since.
511
664
  sig { params(user_ids: T::Array[String], before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
512
665
  def revoke_users_token(user_ids, before)
513
666
  before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
@@ -549,6 +702,10 @@ module StreamChat
549
702
  make_http_request(:patch, relative_url, params: params, data: data)
550
703
  end
551
704
 
705
+ # Uploads a file.
706
+ #
707
+ # This functionality defaults to using the Stream CDN. If you would like, you can
708
+ # easily change the logic to upload to your own CDN of choice.
552
709
  sig { params(relative_url: String, file_url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
553
710
  def send_file(relative_url, file_url, user, content_type = nil)
554
711
  url = [@base_url, relative_url].join('/')
@@ -568,91 +725,111 @@ module StreamChat
568
725
  parse_response(response)
569
726
  end
570
727
 
728
+ # Check push notification settings.
571
729
  sig { params(push_data: StringKeyHash).returns(StreamChat::StreamResponse) }
572
730
  def check_push(push_data)
573
731
  post('check_push', data: push_data)
574
732
  end
575
733
 
734
+ # Check SQS Push settings
735
+ #
736
+ # When no parameters are given, the current SQS app settings are used.
576
737
  sig { params(sqs_key: T.nilable(String), sqs_secret: T.nilable(String), sqs_url: T.nilable(String)).returns(StreamChat::StreamResponse) }
577
738
  def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
578
739
  post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
579
740
  end
580
741
 
742
+ # Creates a new command.
581
743
  sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
582
744
  def create_command(command)
583
745
  post('commands', data: command)
584
746
  end
585
747
 
748
+ # Gets a comamnd.
586
749
  sig { params(name: String).returns(StreamChat::StreamResponse) }
587
750
  def get_command(name)
588
751
  get("commands/#{name}")
589
752
  end
590
753
 
754
+ # Updates a command.
591
755
  sig { params(name: String, command: StringKeyHash).returns(StreamChat::StreamResponse) }
592
756
  def update_command(name, command)
593
757
  put("commands/#{name}", data: command)
594
758
  end
595
759
 
760
+ # Deletes a command.
596
761
  sig { params(name: String).returns(StreamChat::StreamResponse) }
597
762
  def delete_command(name)
598
763
  delete("commands/#{name}")
599
764
  end
600
765
 
766
+ # Lists all commands.
601
767
  sig { returns(StreamChat::StreamResponse) }
602
768
  def list_commands
603
769
  get('commands')
604
770
  end
605
771
 
772
+ # Lists all permissions.
606
773
  sig { returns(StreamChat::StreamResponse) }
607
774
  def list_permissions
608
775
  get('permissions')
609
776
  end
610
777
 
778
+ # Gets a permission.
611
779
  sig { params(id: String).returns(StreamChat::StreamResponse) }
612
780
  def get_permission(id)
613
781
  get("permissions/#{id}")
614
782
  end
615
783
 
784
+ # Creates a new permission.
616
785
  sig { params(permission: StringKeyHash).returns(StreamChat::StreamResponse) }
617
786
  def create_permission(permission)
618
787
  post('permissions', data: permission)
619
788
  end
620
789
 
790
+ # Updates a permission.
621
791
  sig { params(id: String, permission: StringKeyHash).returns(StreamChat::StreamResponse) }
622
792
  def update_permission(id, permission)
623
793
  put("permissions/#{id}", data: permission)
624
794
  end
625
795
 
796
+ # Deletes a permission by id.
626
797
  sig { params(id: String).returns(StreamChat::StreamResponse) }
627
798
  def delete_permission(id)
628
799
  delete("permissions/#{id}")
629
800
  end
630
801
 
802
+ # Create a new role.
631
803
  sig { params(name: String).returns(StreamChat::StreamResponse) }
632
804
  def create_role(name)
633
805
  post('roles', data: { name: name })
634
806
  end
635
807
 
808
+ # Delete a role by name.
636
809
  sig { params(name: String).returns(StreamChat::StreamResponse) }
637
810
  def delete_role(name)
638
811
  delete("roles/#{name}")
639
812
  end
640
813
 
814
+ # List all roles.
641
815
  sig { returns(StreamChat::StreamResponse) }
642
816
  def list_roles
643
817
  get('roles')
644
818
  end
645
819
 
820
+ # Create or update a push provider.
646
821
  sig { params(push_provider: StringKeyHash).returns(StreamChat::StreamResponse) }
647
822
  def upsert_push_provider(push_provider)
648
823
  post('push_providers', data: { push_provider: push_provider })
649
824
  end
650
825
 
826
+ # Delete a push provider by type and name.
651
827
  sig { params(type: String, name: String).returns(StreamChat::StreamResponse) }
652
828
  def delete_push_provider(type, name)
653
829
  delete("push_providers/#{type}/#{name}")
654
830
  end
655
831
 
832
+ # Lists all push providers.
656
833
  sig { returns(StreamChat::StreamResponse) }
657
834
  def list_push_providers
658
835
  get('push_providers')
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module StreamChat
5
- VERSION = '2.22.0'
5
+ VERSION = '2.22.1'
6
6
  end
data/stream-chat.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |gem|
35
35
  gem.add_development_dependency 'rake'
36
36
  gem.add_development_dependency 'rspec'
37
37
  gem.add_development_dependency 'simplecov'
38
+ gem.add_development_dependency 'simplecov-console'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.22.0
4
+ version: 2.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - getstream.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-11 00:00:00.000000000 Z
11
+ date: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-console
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Ruby client for Stream Chat.
140
154
  email: support@getstream.io
141
155
  executables: []