stream-chat-ruby 2.22.1 → 2.22.2
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/stream-chat/channel.rb +40 -41
- data/lib/stream-chat/client.rb +104 -105
- data/lib/stream-chat/errors.rb +7 -8
- data/lib/stream-chat/stream_rate_limits.rb +4 -5
- data/lib/stream-chat/stream_response.rb +4 -5
- data/lib/stream-chat/types.rb +0 -1
- data/lib/stream-chat/util.rb +1 -2
- data/lib/stream-chat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d1012ba93c094b6a28185368ae809b0c6ef9bd67d9b88fc7731261c53e25b5
|
4
|
+
data.tar.gz: 04113551dd54cbd418e289f024213bfa3d388168711266a40bd8678d5b59284b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15dca07dcf3d295ac549a2f7d7ddc28663d21c24afa1cd9d4fca89d7a129b00f49594da4713757349903e61b1b2c2b5b32c70e0af1d3827dfd42523ad108c765
|
7
|
+
data.tar.gz: 0d1c5dc9a6ccab2ef2db44fc6eeb221ccf62d16c8779554831784525e2ed375b53f7086f27e02dd22d9a57c77fec1b80e3930cad65a19c898dca2591e3699e6b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
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.2](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.1...v2.22.2) (2022-04-21)
|
6
|
+
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* **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))
|
11
|
+
|
5
12
|
### [2.22.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.0...v2.22.1) (2022-04-20)
|
6
13
|
|
7
14
|
### Features
|
data/lib/stream-chat/channel.rb
CHANGED
@@ -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,7 +35,7 @@ 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
|
|
@@ -44,34 +43,34 @@ module StreamChat
|
|
44
43
|
end
|
45
44
|
|
46
45
|
# Gets multiple messages from the channel.
|
47
|
-
sig { params(message_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
46
|
+
T::Sig::WithoutRuntime.sig { params(message_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
48
47
|
def get_messages(message_ids)
|
49
48
|
@client.get("#{url}/messages", params: { 'ids' => message_ids.join(',') })
|
50
49
|
end
|
51
50
|
|
52
51
|
# Sends a message to this channel.
|
53
|
-
sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
52
|
+
T::Sig::WithoutRuntime.sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
54
53
|
def send_message(message, user_id)
|
55
54
|
payload = { message: add_user_id(message, user_id) }
|
56
55
|
@client.post("#{url}/message", data: payload)
|
57
56
|
end
|
58
57
|
|
59
58
|
# Sends an event on this channel.
|
60
|
-
sig { params(event: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
59
|
+
T::Sig::WithoutRuntime.sig { params(event: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
61
60
|
def send_event(event, user_id)
|
62
61
|
payload = { 'event' => add_user_id(event, user_id) }
|
63
62
|
@client.post("#{url}/event", data: payload)
|
64
63
|
end
|
65
64
|
|
66
65
|
# Sends a new reaction to a given message.
|
67
|
-
sig { params(message_id: String, reaction: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
66
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, reaction: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
|
68
67
|
def send_reaction(message_id, reaction, user_id)
|
69
68
|
payload = { reaction: add_user_id(reaction, user_id) }
|
70
69
|
@client.post("messages/#{message_id}/reaction", data: payload)
|
71
70
|
end
|
72
71
|
|
73
72
|
# Delete a reaction from a message.
|
74
|
-
sig { params(message_id: String, reaction_type: String, user_id: String).returns(StreamChat::StreamResponse) }
|
73
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, reaction_type: String, user_id: String).returns(StreamChat::StreamResponse) }
|
75
74
|
def delete_reaction(message_id, reaction_type, user_id)
|
76
75
|
@client.delete(
|
77
76
|
"messages/#{message_id}/reaction/#{reaction_type}",
|
@@ -80,14 +79,14 @@ module StreamChat
|
|
80
79
|
end
|
81
80
|
|
82
81
|
# Creates a channel with the given creator user.
|
83
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
82
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
84
83
|
def create(user_id)
|
85
84
|
@custom_data['created_by'] = { id: user_id }
|
86
85
|
query(watch: false, state: false, presence: false)
|
87
86
|
end
|
88
87
|
|
89
88
|
# Creates or returns a channel.
|
90
|
-
sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
89
|
+
T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
91
90
|
def query(**options)
|
92
91
|
payload = { state: true, data: @custom_data }.merge(options)
|
93
92
|
url = "channels/#{@channel_type}"
|
@@ -104,7 +103,7 @@ module StreamChat
|
|
104
103
|
# endpoint supports filtering on numerous criteria to efficiently return members information.
|
105
104
|
# This endpoint is useful for channels that have large lists of members and
|
106
105
|
# you want to search members or if you want to display the full list of members for a channel.
|
107
|
-
sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
106
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
108
107
|
def query_members(filter_conditions = {}, sort: nil, **options)
|
109
108
|
params = {}.merge(options).merge({
|
110
109
|
id: @id,
|
@@ -124,14 +123,14 @@ module StreamChat
|
|
124
123
|
end
|
125
124
|
|
126
125
|
# Updates a channel.
|
127
|
-
sig { params(channel_data: T.nilable(StringKeyHash), update_message: T.nilable(StringKeyHash), options: T.untyped).returns(StreamChat::StreamResponse) }
|
126
|
+
T::Sig::WithoutRuntime.sig { params(channel_data: T.nilable(StringKeyHash), update_message: T.nilable(StringKeyHash), options: T.untyped).returns(StreamChat::StreamResponse) }
|
128
127
|
def update(channel_data, update_message = nil, **options)
|
129
128
|
payload = { data: channel_data, message: update_message }.merge(options)
|
130
129
|
@client.post(url, data: payload)
|
131
130
|
end
|
132
131
|
|
133
132
|
# Updates a channel partially.
|
134
|
-
sig { params(set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
|
133
|
+
T::Sig::WithoutRuntime.sig { params(set: T.nilable(StringKeyHash), unset: T.nilable(T::Array[String])).returns(StreamChat::StreamResponse) }
|
135
134
|
def update_partial(set = nil, unset = nil)
|
136
135
|
raise StreamChannelException, 'set or unset is needed' if set.nil? && unset.nil?
|
137
136
|
|
@@ -140,13 +139,13 @@ module StreamChat
|
|
140
139
|
end
|
141
140
|
|
142
141
|
# Deletes a channel.
|
143
|
-
sig { returns(StreamChat::StreamResponse) }
|
142
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
144
143
|
def delete
|
145
144
|
@client.delete(url)
|
146
145
|
end
|
147
146
|
|
148
147
|
# Removes all messages from the channel.
|
149
|
-
sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
148
|
+
T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
150
149
|
def truncate(**options)
|
151
150
|
@client.post("#{url}/truncate", data: options)
|
152
151
|
end
|
@@ -157,7 +156,7 @@ module StreamChat
|
|
157
156
|
# unread count for the users that muted it. By default, mutes stay in place indefinitely
|
158
157
|
# until the user removes it; however, you can optionally set an expiration time. The list
|
159
158
|
# of muted channels and their expiration time is returned when the user connects.
|
160
|
-
sig { params(user_id: String, expiration: T.nilable(Integer)).returns(StreamChat::StreamResponse) }
|
159
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, expiration: T.nilable(Integer)).returns(StreamChat::StreamResponse) }
|
161
160
|
def mute(user_id, expiration = nil)
|
162
161
|
data = { user_id: user_id, channel_cid: @cid }
|
163
162
|
data['expiration'] = expiration if expiration
|
@@ -165,104 +164,104 @@ module StreamChat
|
|
165
164
|
end
|
166
165
|
|
167
166
|
# Unmutes a channel.
|
168
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
167
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
169
168
|
def unmute(user_id)
|
170
169
|
@client.post('moderation/unmute/channel', data: { 'user_id' => user_id, 'channel_cid' => @cid })
|
171
170
|
end
|
172
171
|
|
173
172
|
# Adds members to the channel.
|
174
|
-
sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
|
173
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
|
175
174
|
def add_members(user_ids, **options)
|
176
175
|
payload = options.merge({ add_members: user_ids })
|
177
176
|
update(nil, nil, **payload)
|
178
177
|
end
|
179
178
|
|
180
179
|
# Invites users to the channel.
|
181
|
-
sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
|
180
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
|
182
181
|
def invite_members(user_ids, **options)
|
183
182
|
payload = options.merge({ invites: user_ids })
|
184
183
|
update(nil, nil, **payload)
|
185
184
|
end
|
186
185
|
|
187
186
|
# Accepts an invitation to the channel.
|
188
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
187
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
189
188
|
def accept_invite(user_id, **options)
|
190
189
|
payload = options.merge({ user_id: user_id, accept_invite: true })
|
191
190
|
update(nil, nil, **payload)
|
192
191
|
end
|
193
192
|
|
194
193
|
# Rejects an invitation to the channel.
|
195
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
194
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
196
195
|
def reject_invite(user_id, **options)
|
197
196
|
payload = options.merge({ user_id: user_id, reject_invite: true })
|
198
197
|
update(nil, nil, **payload)
|
199
198
|
end
|
200
199
|
|
201
200
|
# Adds moderators to the channel.
|
202
|
-
sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
201
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
203
202
|
def add_moderators(user_ids)
|
204
203
|
update(nil, nil, add_moderators: user_ids)
|
205
204
|
end
|
206
205
|
|
207
206
|
# Removes members from the channel.
|
208
|
-
sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
207
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
209
208
|
def remove_members(user_ids)
|
210
209
|
update(nil, nil, remove_members: user_ids)
|
211
210
|
end
|
212
211
|
|
213
212
|
# Assigns roles to members in the channel.
|
214
|
-
sig { params(members: T::Array[StringKeyHash], message: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
213
|
+
T::Sig::WithoutRuntime.sig { params(members: T::Array[StringKeyHash], message: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
215
214
|
def assign_roles(members, message = nil)
|
216
215
|
update(nil, message, assign_roles: members)
|
217
216
|
end
|
218
217
|
|
219
218
|
# Demotes moderators in the channel.
|
220
|
-
sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
219
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
|
221
220
|
def demote_moderators(user_ids)
|
222
221
|
update(nil, nil, demote_moderators: user_ids)
|
223
222
|
end
|
224
223
|
|
225
224
|
# Sends the mark read event for this user, only works if the `read_events` setting is enabled.
|
226
|
-
sig { params(user_id: String, options: StringKeyHash).returns(StreamChat::StreamResponse) }
|
225
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: StringKeyHash).returns(StreamChat::StreamResponse) }
|
227
226
|
def mark_read(user_id, **options)
|
228
227
|
payload = add_user_id(options, user_id)
|
229
228
|
@client.post("#{url}/read", data: payload)
|
230
229
|
end
|
231
230
|
|
232
231
|
# List the message replies for a parent message.
|
233
|
-
sig { params(parent_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
232
|
+
T::Sig::WithoutRuntime.sig { params(parent_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
234
233
|
def get_replies(parent_id, **options)
|
235
234
|
@client.get("messages/#{parent_id}/replies", params: options)
|
236
235
|
end
|
237
236
|
|
238
237
|
# List the reactions, supports pagination.
|
239
|
-
sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
238
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
240
239
|
def get_reactions(message_id, **options)
|
241
240
|
@client.get("messages/#{message_id}/reactions", params: options)
|
242
241
|
end
|
243
242
|
|
244
243
|
# Bans a user from this channel.
|
245
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
244
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
246
245
|
def ban_user(user_id, **options)
|
247
246
|
@client.ban_user(user_id, type: @channel_type, id: @id, **options)
|
248
247
|
end
|
249
248
|
|
250
249
|
# Removes the ban for a user on this channel.
|
251
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
250
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
252
251
|
def unban_user(user_id)
|
253
252
|
@client.unban_user(user_id, type: @channel_type, id: @id)
|
254
253
|
end
|
255
254
|
|
256
255
|
# Removes a channel from query channel requests for that user until a new message is added.
|
257
256
|
# Use `show` to cancel this operation.
|
258
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
257
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
259
258
|
def hide(user_id)
|
260
259
|
@client.post("#{url}/hide", data: { user_id: user_id })
|
261
260
|
end
|
262
261
|
|
263
262
|
# Shows a previously hidden channel.
|
264
263
|
# Use `hide` to hide a channel.
|
265
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
264
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
266
265
|
def show(user_id)
|
267
266
|
@client.post("#{url}/show", data: { user_id: user_id })
|
268
267
|
end
|
@@ -271,7 +270,7 @@ module StreamChat
|
|
271
270
|
#
|
272
271
|
# This functionality defaults to using the Stream CDN. If you would like, you can
|
273
272
|
# easily change the logic to upload to your own CDN of choice.
|
274
|
-
sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
273
|
+
T::Sig::WithoutRuntime.sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
275
274
|
def send_file(url, user, content_type = nil)
|
276
275
|
@client.send_file("#{self.url}/file", url, user, content_type)
|
277
276
|
end
|
@@ -282,26 +281,26 @@ module StreamChat
|
|
282
281
|
# image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
|
283
282
|
# You can set a more restrictive list for your application if needed.
|
284
283
|
# The maximum file size is 100MB.
|
285
|
-
sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
284
|
+
T::Sig::WithoutRuntime.sig { params(url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
286
285
|
def send_image(url, user, content_type = nil)
|
287
286
|
@client.send_file("#{self.url}/image", url, user, content_type)
|
288
287
|
end
|
289
288
|
|
290
289
|
# Deletes a file by file url.
|
291
|
-
sig { params(url: String).returns(StreamChat::StreamResponse) }
|
290
|
+
T::Sig::WithoutRuntime.sig { params(url: String).returns(StreamChat::StreamResponse) }
|
292
291
|
def delete_file(url)
|
293
292
|
@client.delete("#{self.url}/file", params: { url: url })
|
294
293
|
end
|
295
294
|
|
296
295
|
# Deletes an image by image url.
|
297
|
-
sig { params(url: String).returns(StreamChat::StreamResponse) }
|
296
|
+
T::Sig::WithoutRuntime.sig { params(url: String).returns(StreamChat::StreamResponse) }
|
298
297
|
def delete_image(url)
|
299
298
|
@client.delete("#{self.url}/image", params: { url: url })
|
300
299
|
end
|
301
300
|
|
302
301
|
private
|
303
302
|
|
304
|
-
sig { params(payload: StringKeyHash, user_id: String).returns(StringKeyHash) }
|
303
|
+
T::Sig::WithoutRuntime.sig { params(payload: StringKeyHash, user_id: String).returns(StringKeyHash) }
|
305
304
|
def add_user_id(payload, user_id)
|
306
305
|
payload.merge({ user: { id: user_id } })
|
307
306
|
end
|
data/lib/stream-chat/client.rb
CHANGED
@@ -22,7 +22,6 @@ module StreamChat
|
|
22
22
|
|
23
23
|
class Client
|
24
24
|
extend T::Sig
|
25
|
-
T::Configuration.default_checked_level = :never
|
26
25
|
# For now we disable runtime type checks.
|
27
26
|
# We will enable it with a major bump in the future,
|
28
27
|
# but for now, let's just run a static type check.
|
@@ -30,13 +29,13 @@ module StreamChat
|
|
30
29
|
DEFAULT_BASE_URL = 'https://chat.stream-io-api.com'
|
31
30
|
DEFAULT_TIMEOUT = 6.0
|
32
31
|
|
33
|
-
sig { returns(String) }
|
32
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
34
33
|
attr_reader :api_key
|
35
34
|
|
36
|
-
sig { returns(String) }
|
35
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
37
36
|
attr_reader :api_secret
|
38
37
|
|
39
|
-
sig { returns(Faraday::Connection) }
|
38
|
+
T::Sig::WithoutRuntime.sig { returns(Faraday::Connection) }
|
40
39
|
attr_reader :conn
|
41
40
|
|
42
41
|
# initializes a Stream Chat API Client
|
@@ -49,7 +48,7 @@ module StreamChat
|
|
49
48
|
# @example initialized the client with a timeout setting
|
50
49
|
# StreamChat::Client.new('my_key', 'my_secret', 3.0)
|
51
50
|
#
|
52
|
-
sig { params(api_key: String, api_secret: String, timeout: T.nilable(T.any(Float, String)), options: T.untyped).void }
|
51
|
+
T::Sig::WithoutRuntime.sig { params(api_key: String, api_secret: String, timeout: T.nilable(T.any(Float, String)), options: T.untyped).void }
|
53
52
|
def initialize(api_key, api_secret, timeout = nil, **options)
|
54
53
|
raise ArgumentError, 'api_key and api_secret are required' if api_key.to_s.empty? || api_secret.to_s.empty?
|
55
54
|
|
@@ -74,18 +73,18 @@ module StreamChat
|
|
74
73
|
# environmental variables. STREAM_CHAT_TIMEOUT and STREAM_CHAT_URL
|
75
74
|
# variables are optional.
|
76
75
|
# @param [StringKeyHash] options extra options
|
77
|
-
sig { params(options: T.untyped).returns(Client) }
|
76
|
+
T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(Client) }
|
78
77
|
def self.from_env(**options)
|
79
|
-
Client.new(
|
80
|
-
|
81
|
-
ENV
|
82
|
-
**{ base_url: ENV
|
78
|
+
Client.new(ENV.fetch('STREAM_KEY'),
|
79
|
+
ENV.fetch('STREAM_SECRET'),
|
80
|
+
ENV.fetch('STREAM_CHAT_TIMEOUT', DEFAULT_TIMEOUT),
|
81
|
+
**{ base_url: ENV.fetch('STREAM_CHAT_URL', DEFAULT_BASE_URL) }.merge(options))
|
83
82
|
end
|
84
83
|
|
85
84
|
# Sets the underlying Faraday http client.
|
86
85
|
#
|
87
86
|
# @param [client] an instance of Faraday::Connection
|
88
|
-
sig { params(client: Faraday::Connection).void }
|
87
|
+
T::Sig::WithoutRuntime.sig { params(client: Faraday::Connection).void }
|
89
88
|
def set_http_client(client)
|
90
89
|
@conn = client
|
91
90
|
end
|
@@ -96,7 +95,7 @@ module StreamChat
|
|
96
95
|
# Knowing whether a user is authorized to perform certain actions is managed
|
97
96
|
# separately via a role based permissions system.
|
98
97
|
# You can set an `exp` (expires at) or `iat` (issued at) claim as well.
|
99
|
-
sig { params(user_id: String, exp: T.nilable(Integer), iat: T.nilable(Integer)).returns(String) }
|
98
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, exp: T.nilable(Integer), iat: T.nilable(Integer)).returns(String) }
|
100
99
|
def create_token(user_id, exp = nil, iat = nil)
|
101
100
|
payload = { user_id: user_id }
|
102
101
|
payload['exp'] = exp unless exp.nil?
|
@@ -105,13 +104,13 @@ module StreamChat
|
|
105
104
|
end
|
106
105
|
|
107
106
|
# Updates application settings.
|
108
|
-
sig { params(settings: T.untyped).returns(StreamChat::StreamResponse) }
|
107
|
+
T::Sig::WithoutRuntime.sig { params(settings: T.untyped).returns(StreamChat::StreamResponse) }
|
109
108
|
def update_app_settings(**settings)
|
110
109
|
patch('app', data: settings)
|
111
110
|
end
|
112
111
|
|
113
112
|
# Returns application settings.
|
114
|
-
sig { returns(StreamChat::StreamResponse) }
|
113
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
115
114
|
def get_app_settings
|
116
115
|
get('app')
|
117
116
|
end
|
@@ -121,14 +120,14 @@ module StreamChat
|
|
121
120
|
# Any user is allowed to flag a message. This triggers the message.flagged
|
122
121
|
# webhook event and adds the message to the inbox of your
|
123
122
|
# Stream Dashboard Chat Moderation view.
|
124
|
-
sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
123
|
+
T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
125
124
|
def flag_message(id, **options)
|
126
125
|
payload = { target_message_id: id }.merge(options)
|
127
126
|
post('moderation/flag', data: payload)
|
128
127
|
end
|
129
128
|
|
130
129
|
# Unflags a message.
|
131
|
-
sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
130
|
+
T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
132
131
|
def unflag_message(id, **options)
|
133
132
|
payload = { target_message_id: id }.merge(options)
|
134
133
|
post('moderation/unflag', data: payload)
|
@@ -139,7 +138,7 @@ module StreamChat
|
|
139
138
|
# If you prefer to build your own in app moderation dashboard, rather than use the Stream
|
140
139
|
# dashboard, then the query message flags endpoint lets you get flagged messages. Similar
|
141
140
|
# to other queries in Stream Chat, you can filter the flags using query operators.
|
142
|
-
sig { params(filter_conditions: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
|
141
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
|
143
142
|
def query_message_flags(filter_conditions, **options)
|
144
143
|
params = options.merge({
|
145
144
|
filter_conditions: filter_conditions
|
@@ -148,28 +147,28 @@ module StreamChat
|
|
148
147
|
end
|
149
148
|
|
150
149
|
# Flags a user.
|
151
|
-
sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
150
|
+
T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
152
151
|
def flag_user(id, **options)
|
153
152
|
payload = { target_user_id: id }.merge(options)
|
154
153
|
post('moderation/flag', data: payload)
|
155
154
|
end
|
156
155
|
|
157
156
|
# Unflags a user.
|
158
|
-
sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
157
|
+
T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
159
158
|
def unflag_user(id, **options)
|
160
159
|
payload = { target_user_id: id }.merge(options)
|
161
160
|
post('moderation/unflag', data: payload)
|
162
161
|
end
|
163
162
|
|
164
163
|
# Queries flag reports.
|
165
|
-
sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
164
|
+
T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
166
165
|
def query_flag_reports(**options)
|
167
166
|
data = { filter_conditions: options }
|
168
167
|
post('moderation/reports', data: data)
|
169
168
|
end
|
170
169
|
|
171
170
|
# Sends a flag report review.
|
172
|
-
sig { params(report_id: String, review_result: String, user_id: String, details: T.untyped).returns(StreamChat::StreamResponse) }
|
171
|
+
T::Sig::WithoutRuntime.sig { params(report_id: String, review_result: String, user_id: String, details: T.untyped).returns(StreamChat::StreamResponse) }
|
173
172
|
def review_flag_report(report_id, review_result, user_id, **details)
|
174
173
|
data = {
|
175
174
|
review_result: review_result,
|
@@ -180,7 +179,7 @@ module StreamChat
|
|
180
179
|
end
|
181
180
|
|
182
181
|
# Returns a message.
|
183
|
-
sig { params(id: String).returns(StreamChat::StreamResponse) }
|
182
|
+
T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
|
184
183
|
def get_message(id)
|
185
184
|
get("messages/#{id}")
|
186
185
|
end
|
@@ -189,7 +188,7 @@ module StreamChat
|
|
189
188
|
#
|
190
189
|
# You can enable and/or disable the search indexing on a per channel basis
|
191
190
|
# type through the Stream Dashboard.
|
192
|
-
sig { params(filter_conditions: StringKeyHash, query: T.any(String, StringKeyHash), sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
191
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, query: T.any(String, StringKeyHash), sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
193
192
|
def search(filter_conditions, query, sort: nil, **options)
|
194
193
|
offset = T.cast(options[:offset], T.nilable(Integer))
|
195
194
|
next_value = options[:next]
|
@@ -208,21 +207,21 @@ module StreamChat
|
|
208
207
|
end
|
209
208
|
|
210
209
|
# <b>DEPRECATED:</b> Please use <tt>upsert_users</tt> instead.
|
211
|
-
sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
210
|
+
T::Sig::WithoutRuntime.sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
212
211
|
def update_users(users)
|
213
212
|
warn '[DEPRECATION] `update_users` is deprecated. Please use `upsert_users` instead.'
|
214
213
|
upsert_users(users)
|
215
214
|
end
|
216
215
|
|
217
216
|
# <b>DEPRECATED:</b> Please use <tt>upsert_user</tt> instead.
|
218
|
-
sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
217
|
+
T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
219
218
|
def update_user(user)
|
220
219
|
warn '[DEPRECATION] `update_user` is deprecated. Please use `upsert_user` instead.'
|
221
220
|
upsert_user(user)
|
222
221
|
end
|
223
222
|
|
224
223
|
# Creates or updates users.
|
225
|
-
sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
224
|
+
T::Sig::WithoutRuntime.sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
226
225
|
def upsert_users(users)
|
227
226
|
payload = {}
|
228
227
|
users.each do |user|
|
@@ -235,25 +234,25 @@ module StreamChat
|
|
235
234
|
end
|
236
235
|
|
237
236
|
# Creates or updates a user.
|
238
|
-
sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
237
|
+
T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
239
238
|
def upsert_user(user)
|
240
239
|
upsert_users([user])
|
241
240
|
end
|
242
241
|
|
243
242
|
# Updates multiple users partially.
|
244
|
-
sig { params(updates: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
243
|
+
T::Sig::WithoutRuntime.sig { params(updates: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
245
244
|
def update_users_partial(updates)
|
246
245
|
patch('users', data: { users: updates })
|
247
246
|
end
|
248
247
|
|
249
248
|
# Updates a single user partially.
|
250
|
-
sig { params(update: StringKeyHash).returns(StreamChat::StreamResponse) }
|
249
|
+
T::Sig::WithoutRuntime.sig { params(update: StringKeyHash).returns(StreamChat::StreamResponse) }
|
251
250
|
def update_user_partial(update)
|
252
251
|
update_users_partial([update])
|
253
252
|
end
|
254
253
|
|
255
254
|
# Deletes a user synchronously.
|
256
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
255
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
257
256
|
def delete_user(user_id, **options)
|
258
257
|
delete("users/#{user_id}", params: options)
|
259
258
|
end
|
@@ -261,20 +260,20 @@ module StreamChat
|
|
261
260
|
# Deactivates a user.
|
262
261
|
# Deactivated users cannot connect to Stream Chat, and can't send or receive messages.
|
263
262
|
# To reactivate a user, use `reactivate_user` method.
|
264
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
263
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
265
264
|
def deactivate_user(user_id, **options)
|
266
265
|
post("users/#{user_id}/deactivate", params: options)
|
267
266
|
end
|
268
267
|
|
269
268
|
# Reactivates a deactivated user. Use deactivate_user to deactivate a user.
|
270
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
269
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
271
270
|
def reactivate_user(user_id, **options)
|
272
271
|
post("users/#{user_id}/reactivate", params: options)
|
273
272
|
end
|
274
273
|
|
275
274
|
# Exports a user. It exports a user and returns an object
|
276
275
|
# containing all of it's data.
|
277
|
-
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
276
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
278
277
|
def export_user(user_id, **options)
|
279
278
|
get("users/#{user_id}/export", params: options)
|
280
279
|
end
|
@@ -283,7 +282,7 @@ module StreamChat
|
|
283
282
|
# When a user is banned, they will not be allowed to post messages until the
|
284
283
|
# ban is removed or expired but will be able to connect to Chat and to channels as before.
|
285
284
|
# To unban a user, use `unban_user` method.
|
286
|
-
sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
285
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
287
286
|
def ban_user(target_id, **options)
|
288
287
|
payload = { target_user_id: target_id }.merge(options)
|
289
288
|
post('moderation/ban', data: payload)
|
@@ -291,7 +290,7 @@ module StreamChat
|
|
291
290
|
|
292
291
|
# Unbans a user.
|
293
292
|
# To ban a user, use `ban_user` method.
|
294
|
-
sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
293
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
295
294
|
def unban_user(target_id, **options)
|
296
295
|
params = { target_user_id: target_id }.merge(options)
|
297
296
|
delete('moderation/ban', params: params)
|
@@ -302,7 +301,7 @@ module StreamChat
|
|
302
301
|
# but any message sent during the will only be visible to the messages author
|
303
302
|
# and invisible to other users of the App.
|
304
303
|
# To remove a shadow ban, use `remove_shadow_ban` method.
|
305
|
-
sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
304
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
306
305
|
def shadow_ban(target_id, **options)
|
307
306
|
payload = { target_user_id: target_id, shadow: true }.merge(options)
|
308
307
|
post('moderation/ban', data: payload)
|
@@ -310,28 +309,28 @@ module StreamChat
|
|
310
309
|
|
311
310
|
# Removes a shadow ban of a user.
|
312
311
|
# To shadow ban a user, use `shadow_ban` method.
|
313
|
-
sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
312
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
314
313
|
def remove_shadow_ban(target_id, **options)
|
315
314
|
params = { target_user_id: target_id, shadow: true }.merge(options)
|
316
315
|
delete('moderation/ban', params: params)
|
317
316
|
end
|
318
317
|
|
319
318
|
# Mutes a user.
|
320
|
-
sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
319
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
321
320
|
def mute_user(target_id, user_id)
|
322
321
|
payload = { target_id: target_id, user_id: user_id }
|
323
322
|
post('moderation/mute', data: payload)
|
324
323
|
end
|
325
324
|
|
326
325
|
# Unmutes a user.
|
327
|
-
sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
326
|
+
T::Sig::WithoutRuntime.sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
328
327
|
def unmute_user(target_id, user_id)
|
329
328
|
payload = { target_id: target_id, user_id: user_id }
|
330
329
|
post('moderation/unmute', data: payload)
|
331
330
|
end
|
332
331
|
|
333
332
|
# Marks all messages as read for a user.
|
334
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
333
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
335
334
|
def mark_all_read(user_id)
|
336
335
|
payload = { user: { id: user_id } }
|
337
336
|
post('channels/read', data: payload)
|
@@ -343,7 +342,7 @@ module StreamChat
|
|
343
342
|
# promote content. Pinning a message is, by default, restricted to certain user roles,
|
344
343
|
# but this is flexible. Each channel can have multiple pinned messages and these can be created
|
345
344
|
# or updated with or without an expiration.
|
346
|
-
sig { params(message_id: String, user_id: String, expiration: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
345
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, user_id: String, expiration: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
347
346
|
def pin_message(message_id, user_id, expiration: nil)
|
348
347
|
updates = {
|
349
348
|
set: {
|
@@ -355,7 +354,7 @@ module StreamChat
|
|
355
354
|
end
|
356
355
|
|
357
356
|
# Unpins a message.
|
358
|
-
sig { params(message_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
357
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
359
358
|
def unpin_message(message_id, user_id)
|
360
359
|
updates = {
|
361
360
|
set: {
|
@@ -367,7 +366,7 @@ module StreamChat
|
|
367
366
|
|
368
367
|
# Updates a message. Fully overwrites a message.
|
369
368
|
# For partial update, use `update_message_partial` method.
|
370
|
-
sig { params(message: StringKeyHash).returns(StreamChat::StreamResponse) }
|
369
|
+
T::Sig::WithoutRuntime.sig { params(message: StringKeyHash).returns(StreamChat::StreamResponse) }
|
371
370
|
def update_message(message)
|
372
371
|
raise ArgumentError, 'message must have an id' unless message.key? 'id'
|
373
372
|
|
@@ -377,7 +376,7 @@ module StreamChat
|
|
377
376
|
# Updates a message partially.
|
378
377
|
# A partial update can be used to set and unset specific fields when
|
379
378
|
# it is necessary to retain additional data fields on the object. AKA a patch style update.
|
380
|
-
sig { params(message_id: String, updates: StringKeyHash, user_id: T.nilable(String), options: T.untyped).returns(StreamChat::StreamResponse) }
|
379
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, updates: StringKeyHash, user_id: T.nilable(String), options: T.untyped).returns(StreamChat::StreamResponse) }
|
381
380
|
def update_message_partial(message_id, updates, user_id: nil, **options)
|
382
381
|
params = updates.merge(options)
|
383
382
|
params['user'] = { id: user_id } if user_id
|
@@ -385,7 +384,7 @@ module StreamChat
|
|
385
384
|
end
|
386
385
|
|
387
386
|
# Deletes a message.
|
388
|
-
sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
387
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
389
388
|
def delete_message(message_id, **options)
|
390
389
|
delete("messages/#{message_id}", params: options)
|
391
390
|
end
|
@@ -397,7 +396,7 @@ module StreamChat
|
|
397
396
|
# 2) User Search: you can add the banned:true condition to your search. Please note that
|
398
397
|
# this will only return users that were banned at the app-level and not the ones
|
399
398
|
# that were banned only on channels.
|
400
|
-
sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
399
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
401
400
|
def query_banned_users(filter_conditions, sort: nil, **options)
|
402
401
|
params = options.merge({
|
403
402
|
filter_conditions: filter_conditions,
|
@@ -408,7 +407,7 @@ module StreamChat
|
|
408
407
|
|
409
408
|
# Allows you to search for users and see if they are online/offline.
|
410
409
|
# 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.
|
411
|
-
sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
410
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
412
411
|
def query_users(filter_conditions, sort: nil, **options)
|
413
412
|
params = options.merge({
|
414
413
|
filter_conditions: filter_conditions,
|
@@ -423,7 +422,7 @@ module StreamChat
|
|
423
422
|
# Multiple filters can be combined using AND, OR logical operators, each filter can use its
|
424
423
|
# comparison (equality, inequality, greater than, greater or equal, etc.).
|
425
424
|
# You can find the complete list of supported operators in the query syntax section of the docs.
|
426
|
-
sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
425
|
+
T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
|
427
426
|
def query_channels(filter_conditions, sort: nil, **options)
|
428
427
|
data = { state: true, watch: false, presence: false }
|
429
428
|
data = data.merge(options).merge({
|
@@ -434,32 +433,32 @@ module StreamChat
|
|
434
433
|
end
|
435
434
|
|
436
435
|
# Creates a new channel type.
|
437
|
-
sig { params(data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
436
|
+
T::Sig::WithoutRuntime.sig { params(data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
438
437
|
def create_channel_type(data)
|
439
438
|
data['commands'] = ['all'] unless data.key?('commands') || data['commands'].nil? || data['commands'].empty?
|
440
439
|
post('channeltypes', data: data)
|
441
440
|
end
|
442
441
|
|
443
442
|
# Returns a channel types.
|
444
|
-
sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
|
443
|
+
T::Sig::WithoutRuntime.sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
|
445
444
|
def get_channel_type(channel_type)
|
446
445
|
get("channeltypes/#{channel_type}")
|
447
446
|
end
|
448
447
|
|
449
448
|
# Returns a list of channel types.
|
450
|
-
sig { returns(StreamChat::StreamResponse) }
|
449
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
451
450
|
def list_channel_types
|
452
451
|
get('channeltypes')
|
453
452
|
end
|
454
453
|
|
455
454
|
# Updates a channel type.
|
456
|
-
sig { params(channel_type: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
455
|
+
T::Sig::WithoutRuntime.sig { params(channel_type: String, options: T.untyped).returns(StreamChat::StreamResponse) }
|
457
456
|
def update_channel_type(channel_type, **options)
|
458
457
|
put("channeltypes/#{channel_type}", data: options)
|
459
458
|
end
|
460
459
|
|
461
460
|
# Deletes a channel type.
|
462
|
-
sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
|
461
|
+
T::Sig::WithoutRuntime.sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
|
463
462
|
def delete_channel_type(channel_type)
|
464
463
|
delete("channeltypes/#{channel_type}")
|
465
464
|
end
|
@@ -472,13 +471,13 @@ module StreamChat
|
|
472
471
|
#
|
473
472
|
# @return [StreamChat::Channel]
|
474
473
|
#
|
475
|
-
sig { params(channel_type: String, channel_id: T.nilable(String), data: T.nilable(StringKeyHash)).returns(StreamChat::Channel) }
|
474
|
+
T::Sig::WithoutRuntime.sig { params(channel_type: String, channel_id: T.nilable(String), data: T.nilable(StringKeyHash)).returns(StreamChat::Channel) }
|
476
475
|
def channel(channel_type, channel_id: nil, data: nil)
|
477
476
|
StreamChat::Channel.new(self, channel_type, channel_id, data)
|
478
477
|
end
|
479
478
|
|
480
479
|
# Adds a device to a user.
|
481
|
-
sig { params(device_id: String, push_provider: String, user_id: String, push_provider_name: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
480
|
+
T::Sig::WithoutRuntime.sig { params(device_id: String, push_provider: String, user_id: String, push_provider_name: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
482
481
|
def add_device(device_id, push_provider, user_id, push_provider_name = nil)
|
483
482
|
post('devices', data: {
|
484
483
|
id: device_id,
|
@@ -489,20 +488,20 @@ module StreamChat
|
|
489
488
|
end
|
490
489
|
|
491
490
|
# Delete a device.
|
492
|
-
sig { params(device_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
491
|
+
T::Sig::WithoutRuntime.sig { params(device_id: String, user_id: String).returns(StreamChat::StreamResponse) }
|
493
492
|
def delete_device(device_id, user_id)
|
494
493
|
delete('devices', params: { id: device_id, user_id: user_id })
|
495
494
|
end
|
496
495
|
|
497
496
|
# Returns a list of devices.
|
498
|
-
sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
497
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
|
499
498
|
def get_devices(user_id)
|
500
499
|
get('devices', params: { user_id: user_id })
|
501
500
|
end
|
502
501
|
|
503
502
|
# Get rate limit quotas and usage.
|
504
503
|
# If no params are toggled, all limits for all endpoints are returned.
|
505
|
-
sig { params(server_side: T::Boolean, android: T::Boolean, ios: T::Boolean, web: T::Boolean, endpoints: T::Array[String]).returns(StreamChat::StreamResponse) }
|
504
|
+
T::Sig::WithoutRuntime.sig { params(server_side: T::Boolean, android: T::Boolean, ios: T::Boolean, web: T::Boolean, endpoints: T::Array[String]).returns(StreamChat::StreamResponse) }
|
506
505
|
def get_rate_limits(server_side: false, android: false, ios: false, web: false, endpoints: [])
|
507
506
|
params = {}
|
508
507
|
params['server_side'] = server_side if server_side
|
@@ -515,14 +514,14 @@ module StreamChat
|
|
515
514
|
end
|
516
515
|
|
517
516
|
# Verify the signature added to a webhook event.
|
518
|
-
sig { params(request_body: String, x_signature: String).returns(T::Boolean) }
|
517
|
+
T::Sig::WithoutRuntime.sig { params(request_body: String, x_signature: String).returns(T::Boolean) }
|
519
518
|
def verify_webhook(request_body, x_signature)
|
520
519
|
signature = OpenSSL::HMAC.hexdigest('SHA256', @api_secret, request_body)
|
521
520
|
signature == x_signature
|
522
521
|
end
|
523
522
|
|
524
523
|
# Allows you to send custom events to a connected user.
|
525
|
-
sig { params(user_id: String, event: StringKeyHash).returns(StreamChat::StreamResponse) }
|
524
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, event: StringKeyHash).returns(StreamChat::StreamResponse) }
|
526
525
|
def send_user_event(user_id, event)
|
527
526
|
post("users/#{user_id}/event", data: event)
|
528
527
|
end
|
@@ -530,13 +529,13 @@ module StreamChat
|
|
530
529
|
# Translates an existing message to another language. The source language
|
531
530
|
# is inferred from the user language or detected automatically by analyzing its text.
|
532
531
|
# If possible it is recommended to store the user language. See the documentation.
|
533
|
-
sig { params(message_id: String, language: String).returns(StreamChat::StreamResponse) }
|
532
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, language: String).returns(StreamChat::StreamResponse) }
|
534
533
|
def translate_message(message_id, language)
|
535
534
|
post("messages/#{message_id}/translate", data: { language: language })
|
536
535
|
end
|
537
536
|
|
538
537
|
# Runs a message command action.
|
539
|
-
sig { params(message_id: String, data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
538
|
+
T::Sig::WithoutRuntime.sig { params(message_id: String, data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
540
539
|
def run_message_action(message_id, data)
|
541
540
|
post("messages/#{message_id}/action", data: data)
|
542
541
|
end
|
@@ -547,7 +546,7 @@ module StreamChat
|
|
547
546
|
# Support and livestreams are common use cases for guests users because really
|
548
547
|
# often you want a visitor to be able to use chat on your application without (or before)
|
549
548
|
# they have a regular user account.
|
550
|
-
sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
549
|
+
T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
551
550
|
def create_guest(user)
|
552
551
|
post('guests', data: user)
|
553
552
|
end
|
@@ -559,7 +558,7 @@ module StreamChat
|
|
559
558
|
# of the most common profane words.
|
560
559
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
561
560
|
# blocklists and configure your channel types to use them.
|
562
|
-
sig { returns(StreamChat::StreamResponse) }
|
561
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
563
562
|
def list_blocklists
|
564
563
|
get('blocklists')
|
565
564
|
end
|
@@ -571,7 +570,7 @@ module StreamChat
|
|
571
570
|
# of the most common profane words.
|
572
571
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
573
572
|
# blocklists and configure your channel types to use them.
|
574
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
573
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
575
574
|
def get_blocklist(name)
|
576
575
|
get("blocklists/#{name}")
|
577
576
|
end
|
@@ -583,7 +582,7 @@ module StreamChat
|
|
583
582
|
# of the most common profane words.
|
584
583
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
585
584
|
# blocklists and configure your channel types to use them.
|
586
|
-
sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
|
585
|
+
T::Sig::WithoutRuntime.sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
|
587
586
|
def create_blocklist(name, words)
|
588
587
|
post('blocklists', data: { name: name, words: words })
|
589
588
|
end
|
@@ -595,7 +594,7 @@ module StreamChat
|
|
595
594
|
# of the most common profane words.
|
596
595
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
597
596
|
# blocklists and configure your channel types to use them.
|
598
|
-
sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
|
597
|
+
T::Sig::WithoutRuntime.sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
|
599
598
|
def update_blocklist(name, words)
|
600
599
|
put("blocklists/#{name}", data: { words: words })
|
601
600
|
end
|
@@ -607,7 +606,7 @@ module StreamChat
|
|
607
606
|
# of the most common profane words.
|
608
607
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
609
608
|
# blocklists and configure your channel types to use them.
|
610
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
609
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
611
610
|
def delete_blocklist(name)
|
612
611
|
delete("blocklists/#{name}")
|
613
612
|
end
|
@@ -617,51 +616,51 @@ module StreamChat
|
|
617
616
|
# Channel exports are created asynchronously, you can use the Task ID returned by
|
618
617
|
# the APIs to keep track of the status and to download the final result when it is ready.
|
619
618
|
# Use `get_task` to check the status of the export.
|
620
|
-
sig { params(channels: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
|
619
|
+
T::Sig::WithoutRuntime.sig { params(channels: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
|
621
620
|
def export_channels(*channels, **options)
|
622
621
|
post('export_channels', data: { channels: channels, **options })
|
623
622
|
end
|
624
623
|
|
625
624
|
# Returns the status of a channel export. It contains the URL to the JSON file.
|
626
|
-
sig { params(task_id: String).returns(StreamChat::StreamResponse) }
|
625
|
+
T::Sig::WithoutRuntime.sig { params(task_id: String).returns(StreamChat::StreamResponse) }
|
627
626
|
def get_export_channel_status(task_id)
|
628
627
|
get("export_channels/#{task_id}")
|
629
628
|
end
|
630
629
|
|
631
630
|
# Returns the status of a task.
|
632
|
-
sig { params(task_id: String).returns(StreamChat::StreamResponse) }
|
631
|
+
T::Sig::WithoutRuntime.sig { params(task_id: String).returns(StreamChat::StreamResponse) }
|
633
632
|
def get_task(task_id)
|
634
633
|
get("tasks/#{task_id}")
|
635
634
|
end
|
636
635
|
|
637
636
|
# Delete users asynchronously. Use `get_task` to check the status of the task.
|
638
|
-
sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(StringKeyHash), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
637
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(StringKeyHash), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
639
638
|
def delete_users(user_ids, user: SOFT_DELETE, messages: nil, conversations: nil)
|
640
639
|
post('users/delete', data: { user_ids: user_ids, user: user, messages: messages, conversations: conversations })
|
641
640
|
end
|
642
641
|
|
643
642
|
# Deletes multiple channels. This is an asynchronous operation and the returned value is a task Id.
|
644
643
|
# You can use `get_task` method to check the status of the task.
|
645
|
-
sig { params(cids: T::Array[String], hard_delete: T::Boolean).returns(StreamChat::StreamResponse) }
|
644
|
+
T::Sig::WithoutRuntime.sig { params(cids: T::Array[String], hard_delete: T::Boolean).returns(StreamChat::StreamResponse) }
|
646
645
|
def delete_channels(cids, hard_delete: false)
|
647
646
|
post('channels/delete', data: { cids: cids, hard_delete: hard_delete })
|
648
647
|
end
|
649
648
|
|
650
649
|
# Revoke tokens for an application issued since the given date.
|
651
|
-
sig { params(before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
650
|
+
T::Sig::WithoutRuntime.sig { params(before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
652
651
|
def revoke_tokens(before)
|
653
652
|
before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
|
654
653
|
update_app_settings({ 'revoke_tokens_issued_before' => before })
|
655
654
|
end
|
656
655
|
|
657
656
|
# Revoke tokens for a user issued since the given date.
|
658
|
-
sig { params(user_id: String, before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
657
|
+
T::Sig::WithoutRuntime.sig { params(user_id: String, before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
659
658
|
def revoke_user_token(user_id, before)
|
660
659
|
revoke_users_token([user_id], before)
|
661
660
|
end
|
662
661
|
|
663
662
|
# Revoke tokens for users issued since.
|
664
|
-
sig { params(user_ids: T::Array[String], before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
663
|
+
T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
|
665
664
|
def revoke_users_token(user_ids, before)
|
666
665
|
before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
|
667
666
|
|
@@ -677,27 +676,27 @@ module StreamChat
|
|
677
676
|
update_users_partial(updates)
|
678
677
|
end
|
679
678
|
|
680
|
-
sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
679
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
681
680
|
def put(relative_url, params: nil, data: nil)
|
682
681
|
make_http_request(:put, relative_url, params: params, data: data)
|
683
682
|
end
|
684
683
|
|
685
|
-
sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
684
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
686
685
|
def post(relative_url, params: nil, data: nil)
|
687
686
|
make_http_request(:post, relative_url, params: params, data: data)
|
688
687
|
end
|
689
688
|
|
690
|
-
sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
689
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
691
690
|
def get(relative_url, params: nil)
|
692
691
|
make_http_request(:get, relative_url, params: params)
|
693
692
|
end
|
694
693
|
|
695
|
-
sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
694
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
696
695
|
def delete(relative_url, params: nil)
|
697
696
|
make_http_request(:delete, relative_url, params: params)
|
698
697
|
end
|
699
698
|
|
700
|
-
sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
699
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
701
700
|
def patch(relative_url, params: nil, data: nil)
|
702
701
|
make_http_request(:patch, relative_url, params: params, data: data)
|
703
702
|
end
|
@@ -706,7 +705,7 @@ module StreamChat
|
|
706
705
|
#
|
707
706
|
# This functionality defaults to using the Stream CDN. If you would like, you can
|
708
707
|
# easily change the logic to upload to your own CDN of choice.
|
709
|
-
sig { params(relative_url: String, file_url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
708
|
+
T::Sig::WithoutRuntime.sig { params(relative_url: String, file_url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
710
709
|
def send_file(relative_url, file_url, user, content_type = nil)
|
711
710
|
url = [@base_url, relative_url].join('/')
|
712
711
|
|
@@ -726,7 +725,7 @@ module StreamChat
|
|
726
725
|
end
|
727
726
|
|
728
727
|
# Check push notification settings.
|
729
|
-
sig { params(push_data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
728
|
+
T::Sig::WithoutRuntime.sig { params(push_data: StringKeyHash).returns(StreamChat::StreamResponse) }
|
730
729
|
def check_push(push_data)
|
731
730
|
post('check_push', data: push_data)
|
732
731
|
end
|
@@ -734,120 +733,120 @@ module StreamChat
|
|
734
733
|
# Check SQS Push settings
|
735
734
|
#
|
736
735
|
# When no parameters are given, the current SQS app settings are used.
|
737
|
-
sig { params(sqs_key: T.nilable(String), sqs_secret: T.nilable(String), sqs_url: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
736
|
+
T::Sig::WithoutRuntime.sig { params(sqs_key: T.nilable(String), sqs_secret: T.nilable(String), sqs_url: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
738
737
|
def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
|
739
738
|
post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
|
740
739
|
end
|
741
740
|
|
742
741
|
# Creates a new command.
|
743
|
-
sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
|
742
|
+
T::Sig::WithoutRuntime.sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
|
744
743
|
def create_command(command)
|
745
744
|
post('commands', data: command)
|
746
745
|
end
|
747
746
|
|
748
747
|
# Gets a comamnd.
|
749
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
748
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
750
749
|
def get_command(name)
|
751
750
|
get("commands/#{name}")
|
752
751
|
end
|
753
752
|
|
754
753
|
# Updates a command.
|
755
|
-
sig { params(name: String, command: StringKeyHash).returns(StreamChat::StreamResponse) }
|
754
|
+
T::Sig::WithoutRuntime.sig { params(name: String, command: StringKeyHash).returns(StreamChat::StreamResponse) }
|
756
755
|
def update_command(name, command)
|
757
756
|
put("commands/#{name}", data: command)
|
758
757
|
end
|
759
758
|
|
760
759
|
# Deletes a command.
|
761
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
760
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
762
761
|
def delete_command(name)
|
763
762
|
delete("commands/#{name}")
|
764
763
|
end
|
765
764
|
|
766
765
|
# Lists all commands.
|
767
|
-
sig { returns(StreamChat::StreamResponse) }
|
766
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
768
767
|
def list_commands
|
769
768
|
get('commands')
|
770
769
|
end
|
771
770
|
|
772
771
|
# Lists all permissions.
|
773
|
-
sig { returns(StreamChat::StreamResponse) }
|
772
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
774
773
|
def list_permissions
|
775
774
|
get('permissions')
|
776
775
|
end
|
777
776
|
|
778
777
|
# Gets a permission.
|
779
|
-
sig { params(id: String).returns(StreamChat::StreamResponse) }
|
778
|
+
T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
|
780
779
|
def get_permission(id)
|
781
780
|
get("permissions/#{id}")
|
782
781
|
end
|
783
782
|
|
784
783
|
# Creates a new permission.
|
785
|
-
sig { params(permission: StringKeyHash).returns(StreamChat::StreamResponse) }
|
784
|
+
T::Sig::WithoutRuntime.sig { params(permission: StringKeyHash).returns(StreamChat::StreamResponse) }
|
786
785
|
def create_permission(permission)
|
787
786
|
post('permissions', data: permission)
|
788
787
|
end
|
789
788
|
|
790
789
|
# Updates a permission.
|
791
|
-
sig { params(id: String, permission: StringKeyHash).returns(StreamChat::StreamResponse) }
|
790
|
+
T::Sig::WithoutRuntime.sig { params(id: String, permission: StringKeyHash).returns(StreamChat::StreamResponse) }
|
792
791
|
def update_permission(id, permission)
|
793
792
|
put("permissions/#{id}", data: permission)
|
794
793
|
end
|
795
794
|
|
796
795
|
# Deletes a permission by id.
|
797
|
-
sig { params(id: String).returns(StreamChat::StreamResponse) }
|
796
|
+
T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
|
798
797
|
def delete_permission(id)
|
799
798
|
delete("permissions/#{id}")
|
800
799
|
end
|
801
800
|
|
802
801
|
# Create a new role.
|
803
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
802
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
804
803
|
def create_role(name)
|
805
804
|
post('roles', data: { name: name })
|
806
805
|
end
|
807
806
|
|
808
807
|
# Delete a role by name.
|
809
|
-
sig { params(name: String).returns(StreamChat::StreamResponse) }
|
808
|
+
T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
|
810
809
|
def delete_role(name)
|
811
810
|
delete("roles/#{name}")
|
812
811
|
end
|
813
812
|
|
814
813
|
# List all roles.
|
815
|
-
sig { returns(StreamChat::StreamResponse) }
|
814
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
816
815
|
def list_roles
|
817
816
|
get('roles')
|
818
817
|
end
|
819
818
|
|
820
819
|
# Create or update a push provider.
|
821
|
-
sig { params(push_provider: StringKeyHash).returns(StreamChat::StreamResponse) }
|
820
|
+
T::Sig::WithoutRuntime.sig { params(push_provider: StringKeyHash).returns(StreamChat::StreamResponse) }
|
822
821
|
def upsert_push_provider(push_provider)
|
823
822
|
post('push_providers', data: { push_provider: push_provider })
|
824
823
|
end
|
825
824
|
|
826
825
|
# Delete a push provider by type and name.
|
827
|
-
sig { params(type: String, name: String).returns(StreamChat::StreamResponse) }
|
826
|
+
T::Sig::WithoutRuntime.sig { params(type: String, name: String).returns(StreamChat::StreamResponse) }
|
828
827
|
def delete_push_provider(type, name)
|
829
828
|
delete("push_providers/#{type}/#{name}")
|
830
829
|
end
|
831
830
|
|
832
831
|
# Lists all push providers.
|
833
|
-
sig { returns(StreamChat::StreamResponse) }
|
832
|
+
T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
|
834
833
|
def list_push_providers
|
835
834
|
get('push_providers')
|
836
835
|
end
|
837
836
|
|
838
837
|
private
|
839
838
|
|
840
|
-
sig { returns(T::Hash[String, String]) }
|
839
|
+
T::Sig::WithoutRuntime.sig { returns(T::Hash[String, String]) }
|
841
840
|
def get_default_params
|
842
841
|
{ api_key: @api_key }
|
843
842
|
end
|
844
843
|
|
845
|
-
sig { returns(String) }
|
844
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
846
845
|
def get_user_agent
|
847
846
|
"stream-ruby-client-#{StreamChat::VERSION}"
|
848
847
|
end
|
849
848
|
|
850
|
-
sig { returns(T::Hash[String, String]) }
|
849
|
+
T::Sig::WithoutRuntime.sig { returns(T::Hash[String, String]) }
|
851
850
|
def get_default_headers
|
852
851
|
{
|
853
852
|
'Content-Type': 'application/json',
|
@@ -855,7 +854,7 @@ module StreamChat
|
|
855
854
|
}
|
856
855
|
end
|
857
856
|
|
858
|
-
sig { params(response: Faraday::Response).returns(StreamChat::StreamResponse) }
|
857
|
+
T::Sig::WithoutRuntime.sig { params(response: Faraday::Response).returns(StreamChat::StreamResponse) }
|
859
858
|
def parse_response(response)
|
860
859
|
begin
|
861
860
|
parsed_result = JSON.parse(response.body)
|
@@ -867,7 +866,7 @@ module StreamChat
|
|
867
866
|
StreamResponse.new(parsed_result, response)
|
868
867
|
end
|
869
868
|
|
870
|
-
sig { params(method: Symbol, relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
869
|
+
T::Sig::WithoutRuntime.sig { params(method: Symbol, relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
|
871
870
|
def make_http_request(method, relative_url, params: nil, data: nil)
|
872
871
|
headers = get_default_headers
|
873
872
|
headers['Authorization'] = @auth_token
|
data/lib/stream-chat/errors.rb
CHANGED
@@ -4,24 +4,23 @@
|
|
4
4
|
module StreamChat
|
5
5
|
class StreamAPIException < StandardError
|
6
6
|
extend T::Sig
|
7
|
-
T::Configuration.default_checked_level = :never
|
8
7
|
# For now we disable runtime type checks.
|
9
8
|
# We will enable it with a major bump in the future,
|
10
9
|
# but for now, let's just run a static type check.
|
11
10
|
|
12
|
-
sig { returns(Integer) }
|
11
|
+
T::Sig::WithoutRuntime.sig { returns(Integer) }
|
13
12
|
attr_reader :error_code
|
14
13
|
|
15
|
-
sig { returns(String) }
|
14
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
16
15
|
attr_reader :error_message
|
17
16
|
|
18
|
-
sig { returns(T::Boolean) }
|
17
|
+
T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
|
19
18
|
attr_reader :json_response
|
20
19
|
|
21
|
-
sig { returns(Faraday::Response) }
|
20
|
+
T::Sig::WithoutRuntime.sig { returns(Faraday::Response) }
|
22
21
|
attr_reader :response
|
23
22
|
|
24
|
-
sig { params(response: Faraday::Response).void }
|
23
|
+
T::Sig::WithoutRuntime.sig { params(response: Faraday::Response).void }
|
25
24
|
def initialize(response)
|
26
25
|
super()
|
27
26
|
@response = response
|
@@ -35,7 +34,7 @@ module StreamChat
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
sig { returns(String) }
|
37
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
39
38
|
def message
|
40
39
|
if @json_response
|
41
40
|
"StreamChat error code #{@error_code}: #{@error_message}"
|
@@ -44,7 +43,7 @@ module StreamChat
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
sig { returns(String) }
|
46
|
+
T::Sig::WithoutRuntime.sig { returns(String) }
|
48
47
|
def to_s
|
49
48
|
message
|
50
49
|
end
|
@@ -4,21 +4,20 @@
|
|
4
4
|
module StreamChat
|
5
5
|
class StreamRateLimits
|
6
6
|
extend T::Sig
|
7
|
-
T::Configuration.default_checked_level = :never
|
8
7
|
# For now we disable runtime type checks.
|
9
8
|
# We will enable it with a major bump in the future,
|
10
9
|
# but for now, let's just run a static type check.
|
11
10
|
|
12
|
-
sig { returns(Integer) }
|
11
|
+
T::Sig::WithoutRuntime.sig { returns(Integer) }
|
13
12
|
attr_reader :limit
|
14
13
|
|
15
|
-
sig { returns(Integer) }
|
14
|
+
T::Sig::WithoutRuntime.sig { returns(Integer) }
|
16
15
|
attr_reader :remaining
|
17
16
|
|
18
|
-
sig { returns(Time) }
|
17
|
+
T::Sig::WithoutRuntime.sig { returns(Time) }
|
19
18
|
attr_reader :reset
|
20
19
|
|
21
|
-
sig { params(limit: String, remaining: String, reset: String).void }
|
20
|
+
T::Sig::WithoutRuntime.sig { params(limit: String, remaining: String, reset: String).void }
|
22
21
|
def initialize(limit, remaining, reset)
|
23
22
|
@limit = T.let(limit.to_i, Integer)
|
24
23
|
@remaining = T.let(remaining.to_i, Integer)
|
@@ -7,21 +7,20 @@ require 'stream-chat/types'
|
|
7
7
|
module StreamChat
|
8
8
|
class StreamResponse < Hash
|
9
9
|
extend T::Sig
|
10
|
-
T::Configuration.default_checked_level = :never
|
11
10
|
# For now we disable runtime type checks.
|
12
11
|
# We will enable it with a major bump in the future,
|
13
12
|
# but for now, let's just run a static type check.
|
14
13
|
|
15
|
-
sig { returns(StreamRateLimits) }
|
14
|
+
T::Sig::WithoutRuntime.sig { returns(StreamRateLimits) }
|
16
15
|
attr_reader :rate_limit
|
17
16
|
|
18
|
-
sig { returns(Integer) }
|
17
|
+
T::Sig::WithoutRuntime.sig { returns(Integer) }
|
19
18
|
attr_reader :status_code
|
20
19
|
|
21
|
-
sig { returns(StringKeyHash) }
|
20
|
+
T::Sig::WithoutRuntime.sig { returns(StringKeyHash) }
|
22
21
|
attr_reader :headers
|
23
22
|
|
24
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped], response: Faraday::Response).void }
|
23
|
+
T::Sig::WithoutRuntime.sig { params(hash: T::Hash[T.untyped, T.untyped], response: Faraday::Response).void }
|
25
24
|
def initialize(hash, response)
|
26
25
|
super(nil)
|
27
26
|
merge!(hash)
|
data/lib/stream-chat/types.rb
CHANGED
data/lib/stream-chat/util.rb
CHANGED
@@ -5,12 +5,11 @@ require 'stream-chat/types'
|
|
5
5
|
|
6
6
|
module StreamChat
|
7
7
|
extend T::Sig
|
8
|
-
T::Configuration.default_checked_level = :never
|
9
8
|
# For now we disable runtime type checks.
|
10
9
|
# We will enable it with a major bump in the future,
|
11
10
|
# but for now, let's just run a static type check.
|
12
11
|
|
13
|
-
sig { params(sort: T.nilable(T::Hash[String, Integer])).returns(SortArray) }
|
12
|
+
T::Sig::WithoutRuntime.sig { params(sort: T.nilable(T::Hash[String, Integer])).returns(SortArray) }
|
14
13
|
def self.get_sort_fields(sort)
|
15
14
|
sort_fields = T.let([], SortArray)
|
16
15
|
sort&.each do |k, v|
|
data/lib/stream-chat/version.rb
CHANGED
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.
|
4
|
+
version: 2.22.2
|
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
|
+
date: 2022-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|