stream-chat-ruby 2.23.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,20 +22,17 @@ module StreamChat
22
22
 
23
23
  class Client
24
24
  extend T::Sig
25
- # For now we disable runtime type checks.
26
- # We will enable it with a major bump in the future,
27
- # but for now, let's just run a static type check.
28
25
 
29
26
  DEFAULT_BASE_URL = 'https://chat.stream-io-api.com'
30
27
  DEFAULT_TIMEOUT = 6.0
31
28
 
32
- T::Sig::WithoutRuntime.sig { returns(String) }
29
+ sig { returns(String) }
33
30
  attr_reader :api_key
34
31
 
35
- T::Sig::WithoutRuntime.sig { returns(String) }
32
+ sig { returns(String) }
36
33
  attr_reader :api_secret
37
34
 
38
- T::Sig::WithoutRuntime.sig { returns(Faraday::Connection) }
35
+ sig { returns(Faraday::Connection) }
39
36
  attr_reader :conn
40
37
 
41
38
  # initializes a Stream Chat API Client
@@ -48,7 +45,7 @@ module StreamChat
48
45
  # @example initialized the client with a timeout setting
49
46
  # StreamChat::Client.new('my_key', 'my_secret', 3.0)
50
47
  #
51
- T::Sig::WithoutRuntime.sig { params(api_key: String, api_secret: String, timeout: T.nilable(T.any(Float, String)), options: T.untyped).void }
48
+ sig { params(api_key: String, api_secret: String, timeout: T.nilable(T.any(Float, String)), options: T.untyped).void }
52
49
  def initialize(api_key, api_secret, timeout = nil, **options)
53
50
  raise ArgumentError, 'api_key and api_secret are required' if api_key.to_s.empty? || api_secret.to_s.empty?
54
51
 
@@ -73,7 +70,7 @@ module StreamChat
73
70
  # environmental variables. STREAM_CHAT_TIMEOUT and STREAM_CHAT_URL
74
71
  # variables are optional.
75
72
  # @param [StringKeyHash] options extra options
76
- T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(Client) }
73
+ sig { params(options: T.untyped).returns(Client) }
77
74
  def self.from_env(**options)
78
75
  Client.new(ENV.fetch('STREAM_KEY'),
79
76
  ENV.fetch('STREAM_SECRET'),
@@ -84,7 +81,7 @@ module StreamChat
84
81
  # Sets the underlying Faraday http client.
85
82
  #
86
83
  # @param [client] an instance of Faraday::Connection
87
- T::Sig::WithoutRuntime.sig { params(client: Faraday::Connection).void }
84
+ sig { params(client: Faraday::Connection).void }
88
85
  def set_http_client(client)
89
86
  @conn = client
90
87
  end
@@ -95,7 +92,7 @@ module StreamChat
95
92
  # Knowing whether a user is authorized to perform certain actions is managed
96
93
  # separately via a role based permissions system.
97
94
  # You can set an `exp` (expires at) or `iat` (issued at) claim as well.
98
- T::Sig::WithoutRuntime.sig { params(user_id: String, exp: T.nilable(Integer), iat: T.nilable(Integer)).returns(String) }
95
+ sig { params(user_id: String, exp: T.nilable(Integer), iat: T.nilable(Integer)).returns(String) }
99
96
  def create_token(user_id, exp = nil, iat = nil)
100
97
  payload = { user_id: user_id }
101
98
  payload['exp'] = exp unless exp.nil?
@@ -104,13 +101,13 @@ module StreamChat
104
101
  end
105
102
 
106
103
  # Updates application settings.
107
- T::Sig::WithoutRuntime.sig { params(settings: T.untyped).returns(StreamChat::StreamResponse) }
104
+ sig { params(settings: T.untyped).returns(StreamChat::StreamResponse) }
108
105
  def update_app_settings(**settings)
109
106
  patch('app', data: settings)
110
107
  end
111
108
 
112
109
  # Returns application settings.
113
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
110
+ sig { returns(StreamChat::StreamResponse) }
114
111
  def get_app_settings
115
112
  get('app')
116
113
  end
@@ -120,14 +117,14 @@ module StreamChat
120
117
  # Any user is allowed to flag a message. This triggers the message.flagged
121
118
  # webhook event and adds the message to the inbox of your
122
119
  # Stream Dashboard Chat Moderation view.
123
- T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
120
+ sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
124
121
  def flag_message(id, **options)
125
122
  payload = { target_message_id: id }.merge(options)
126
123
  post('moderation/flag', data: payload)
127
124
  end
128
125
 
129
126
  # Unflags a message.
130
- T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
127
+ sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
131
128
  def unflag_message(id, **options)
132
129
  payload = { target_message_id: id }.merge(options)
133
130
  post('moderation/unflag', data: payload)
@@ -138,7 +135,7 @@ module StreamChat
138
135
  # If you prefer to build your own in app moderation dashboard, rather than use the Stream
139
136
  # dashboard, then the query message flags endpoint lets you get flagged messages. Similar
140
137
  # to other queries in Stream Chat, you can filter the flags using query operators.
141
- T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
138
+ sig { params(filter_conditions: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
142
139
  def query_message_flags(filter_conditions, **options)
143
140
  params = options.merge({
144
141
  filter_conditions: filter_conditions
@@ -147,28 +144,28 @@ module StreamChat
147
144
  end
148
145
 
149
146
  # Flags a user.
150
- T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
147
+ sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
151
148
  def flag_user(id, **options)
152
149
  payload = { target_user_id: id }.merge(options)
153
150
  post('moderation/flag', data: payload)
154
151
  end
155
152
 
156
153
  # Unflags a user.
157
- T::Sig::WithoutRuntime.sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
154
+ sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
158
155
  def unflag_user(id, **options)
159
156
  payload = { target_user_id: id }.merge(options)
160
157
  post('moderation/unflag', data: payload)
161
158
  end
162
159
 
163
160
  # Queries flag reports.
164
- T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
161
+ sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
165
162
  def query_flag_reports(**options)
166
163
  data = { filter_conditions: options }
167
164
  post('moderation/reports', data: data)
168
165
  end
169
166
 
170
167
  # Sends a flag report review.
171
- T::Sig::WithoutRuntime.sig { params(report_id: String, review_result: String, user_id: String, details: T.untyped).returns(StreamChat::StreamResponse) }
168
+ sig { params(report_id: String, review_result: String, user_id: String, details: T.untyped).returns(StreamChat::StreamResponse) }
172
169
  def review_flag_report(report_id, review_result, user_id, **details)
173
170
  data = {
174
171
  review_result: review_result,
@@ -179,7 +176,7 @@ module StreamChat
179
176
  end
180
177
 
181
178
  # Returns a message.
182
- T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
179
+ sig { params(id: String).returns(StreamChat::StreamResponse) }
183
180
  def get_message(id)
184
181
  get("messages/#{id}")
185
182
  end
@@ -188,7 +185,7 @@ module StreamChat
188
185
  #
189
186
  # You can enable and/or disable the search indexing on a per channel basis
190
187
  # type through the Stream Dashboard.
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) }
188
+ sig { params(filter_conditions: StringKeyHash, query: T.any(String, StringKeyHash), sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
192
189
  def search(filter_conditions, query, sort: nil, **options)
193
190
  offset = T.cast(options[:offset], T.nilable(Integer))
194
191
  next_value = options[:next]
@@ -207,21 +204,21 @@ module StreamChat
207
204
  end
208
205
 
209
206
  # @deprecated Use {#upsert_users} instead.
210
- T::Sig::WithoutRuntime.sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
207
+ sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
211
208
  def update_users(users)
212
209
  warn '[DEPRECATION] `update_users` is deprecated. Please use `upsert_users` instead.'
213
210
  upsert_users(users)
214
211
  end
215
212
 
216
213
  # @deprecated Use {#upsert_user} instead.
217
- T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
214
+ sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
218
215
  def update_user(user)
219
216
  warn '[DEPRECATION] `update_user` is deprecated. Please use `upsert_user` instead.'
220
217
  upsert_user(user)
221
218
  end
222
219
 
223
220
  # Creates or updates users.
224
- T::Sig::WithoutRuntime.sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
221
+ sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
225
222
  def upsert_users(users)
226
223
  payload = {}
227
224
  users.each do |user|
@@ -234,25 +231,25 @@ module StreamChat
234
231
  end
235
232
 
236
233
  # Creates or updates a user.
237
- T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
234
+ sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
238
235
  def upsert_user(user)
239
236
  upsert_users([user])
240
237
  end
241
238
 
242
239
  # Updates multiple users partially.
243
- T::Sig::WithoutRuntime.sig { params(updates: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
240
+ sig { params(updates: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
244
241
  def update_users_partial(updates)
245
242
  patch('users', data: { users: updates })
246
243
  end
247
244
 
248
245
  # Updates a single user partially.
249
- T::Sig::WithoutRuntime.sig { params(update: StringKeyHash).returns(StreamChat::StreamResponse) }
246
+ sig { params(update: StringKeyHash).returns(StreamChat::StreamResponse) }
250
247
  def update_user_partial(update)
251
248
  update_users_partial([update])
252
249
  end
253
250
 
254
251
  # Deletes a user synchronously.
255
- T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
252
+ sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
256
253
  def delete_user(user_id, **options)
257
254
  delete("users/#{user_id}", params: options)
258
255
  end
@@ -260,20 +257,20 @@ module StreamChat
260
257
  # Deactivates a user.
261
258
  # Deactivated users cannot connect to Stream Chat, and can't send or receive messages.
262
259
  # To reactivate a user, use `reactivate_user` method.
263
- T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
260
+ sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
264
261
  def deactivate_user(user_id, **options)
265
262
  post("users/#{user_id}/deactivate", params: options)
266
263
  end
267
264
 
268
265
  # Reactivates a deactivated user. Use deactivate_user to deactivate a user.
269
- T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
266
+ sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
270
267
  def reactivate_user(user_id, **options)
271
268
  post("users/#{user_id}/reactivate", params: options)
272
269
  end
273
270
 
274
271
  # Exports a user. It exports a user and returns an object
275
272
  # containing all of it's data.
276
- T::Sig::WithoutRuntime.sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
273
+ sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
277
274
  def export_user(user_id, **options)
278
275
  get("users/#{user_id}/export", params: options)
279
276
  end
@@ -282,7 +279,7 @@ module StreamChat
282
279
  # When a user is banned, they will not be allowed to post messages until the
283
280
  # ban is removed or expired but will be able to connect to Chat and to channels as before.
284
281
  # To unban a user, use `unban_user` method.
285
- T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
282
+ sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
286
283
  def ban_user(target_id, **options)
287
284
  payload = { target_user_id: target_id }.merge(options)
288
285
  post('moderation/ban', data: payload)
@@ -290,7 +287,7 @@ module StreamChat
290
287
 
291
288
  # Unbans a user.
292
289
  # To ban a user, use `ban_user` method.
293
- T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
290
+ sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
294
291
  def unban_user(target_id, **options)
295
292
  params = { target_user_id: target_id }.merge(options)
296
293
  delete('moderation/ban', params: params)
@@ -301,7 +298,7 @@ module StreamChat
301
298
  # but any message sent during the will only be visible to the messages author
302
299
  # and invisible to other users of the App.
303
300
  # To remove a shadow ban, use `remove_shadow_ban` method.
304
- T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
301
+ sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
305
302
  def shadow_ban(target_id, **options)
306
303
  payload = { target_user_id: target_id, shadow: true }.merge(options)
307
304
  post('moderation/ban', data: payload)
@@ -309,28 +306,28 @@ module StreamChat
309
306
 
310
307
  # Removes a shadow ban of a user.
311
308
  # To shadow ban a user, use `shadow_ban` method.
312
- T::Sig::WithoutRuntime.sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
309
+ sig { params(target_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
313
310
  def remove_shadow_ban(target_id, **options)
314
311
  params = { target_user_id: target_id, shadow: true }.merge(options)
315
312
  delete('moderation/ban', params: params)
316
313
  end
317
314
 
318
315
  # Mutes a user.
319
- T::Sig::WithoutRuntime.sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
316
+ sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
320
317
  def mute_user(target_id, user_id)
321
318
  payload = { target_id: target_id, user_id: user_id }
322
319
  post('moderation/mute', data: payload)
323
320
  end
324
321
 
325
322
  # Unmutes a user.
326
- T::Sig::WithoutRuntime.sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
323
+ sig { params(target_id: String, user_id: String).returns(StreamChat::StreamResponse) }
327
324
  def unmute_user(target_id, user_id)
328
325
  payload = { target_id: target_id, user_id: user_id }
329
326
  post('moderation/unmute', data: payload)
330
327
  end
331
328
 
332
329
  # Marks all messages as read for a user.
333
- T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
330
+ sig { params(user_id: String).returns(StreamChat::StreamResponse) }
334
331
  def mark_all_read(user_id)
335
332
  payload = { user: { id: user_id } }
336
333
  post('channels/read', data: payload)
@@ -342,7 +339,7 @@ module StreamChat
342
339
  # promote content. Pinning a message is, by default, restricted to certain user roles,
343
340
  # but this is flexible. Each channel can have multiple pinned messages and these can be created
344
341
  # or updated with or without an expiration.
345
- T::Sig::WithoutRuntime.sig { params(message_id: String, user_id: String, expiration: T.nilable(String)).returns(StreamChat::StreamResponse) }
342
+ sig { params(message_id: String, user_id: String, expiration: T.nilable(String)).returns(StreamChat::StreamResponse) }
346
343
  def pin_message(message_id, user_id, expiration: nil)
347
344
  updates = {
348
345
  set: {
@@ -354,7 +351,7 @@ module StreamChat
354
351
  end
355
352
 
356
353
  # Unpins a message.
357
- T::Sig::WithoutRuntime.sig { params(message_id: String, user_id: String).returns(StreamChat::StreamResponse) }
354
+ sig { params(message_id: String, user_id: String).returns(StreamChat::StreamResponse) }
358
355
  def unpin_message(message_id, user_id)
359
356
  updates = {
360
357
  set: {
@@ -366,7 +363,7 @@ module StreamChat
366
363
 
367
364
  # Updates a message. Fully overwrites a message.
368
365
  # For partial update, use `update_message_partial` method.
369
- T::Sig::WithoutRuntime.sig { params(message: StringKeyHash).returns(StreamChat::StreamResponse) }
366
+ sig { params(message: StringKeyHash).returns(StreamChat::StreamResponse) }
370
367
  def update_message(message)
371
368
  raise ArgumentError, 'message must have an id' unless message.key? 'id'
372
369
 
@@ -376,7 +373,7 @@ module StreamChat
376
373
  # Updates a message partially.
377
374
  # A partial update can be used to set and unset specific fields when
378
375
  # it is necessary to retain additional data fields on the object. AKA a patch style update.
379
- T::Sig::WithoutRuntime.sig { params(message_id: String, updates: StringKeyHash, user_id: T.nilable(String), options: T.untyped).returns(StreamChat::StreamResponse) }
376
+ sig { params(message_id: String, updates: StringKeyHash, user_id: T.nilable(String), options: T.untyped).returns(StreamChat::StreamResponse) }
380
377
  def update_message_partial(message_id, updates, user_id: nil, **options)
381
378
  params = updates.merge(options)
382
379
  params['user'] = { id: user_id } if user_id
@@ -384,7 +381,7 @@ module StreamChat
384
381
  end
385
382
 
386
383
  # Deletes a message.
387
- T::Sig::WithoutRuntime.sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
384
+ sig { params(message_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
388
385
  def delete_message(message_id, **options)
389
386
  delete("messages/#{message_id}", params: options)
390
387
  end
@@ -396,7 +393,7 @@ module StreamChat
396
393
  # 2) User Search: you can add the banned:true condition to your search. Please note that
397
394
  # this will only return users that were banned at the app-level and not the ones
398
395
  # that were banned only on channels.
399
- T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
396
+ sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
400
397
  def query_banned_users(filter_conditions, sort: nil, **options)
401
398
  params = options.merge({
402
399
  filter_conditions: filter_conditions,
@@ -407,7 +404,7 @@ module StreamChat
407
404
 
408
405
  # Allows you to search for users and see if they are online/offline.
409
406
  # 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.
410
- T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
407
+ sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
411
408
  def query_users(filter_conditions, sort: nil, **options)
412
409
  params = options.merge({
413
410
  filter_conditions: filter_conditions,
@@ -422,7 +419,7 @@ module StreamChat
422
419
  # Multiple filters can be combined using AND, OR logical operators, each filter can use its
423
420
  # comparison (equality, inequality, greater than, greater or equal, etc.).
424
421
  # You can find the complete list of supported operators in the query syntax section of the docs.
425
- T::Sig::WithoutRuntime.sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
422
+ sig { params(filter_conditions: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
426
423
  def query_channels(filter_conditions, sort: nil, **options)
427
424
  data = { state: true, watch: false, presence: false }
428
425
  data = data.merge(options).merge({
@@ -433,32 +430,32 @@ module StreamChat
433
430
  end
434
431
 
435
432
  # Creates a new channel type.
436
- T::Sig::WithoutRuntime.sig { params(data: StringKeyHash).returns(StreamChat::StreamResponse) }
433
+ sig { params(data: StringKeyHash).returns(StreamChat::StreamResponse) }
437
434
  def create_channel_type(data)
438
435
  data['commands'] = ['all'] unless data.key?('commands') || data['commands'].nil? || data['commands'].empty?
439
436
  post('channeltypes', data: data)
440
437
  end
441
438
 
442
439
  # Returns a channel types.
443
- T::Sig::WithoutRuntime.sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
440
+ sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
444
441
  def get_channel_type(channel_type)
445
442
  get("channeltypes/#{channel_type}")
446
443
  end
447
444
 
448
445
  # Returns a list of channel types.
449
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
446
+ sig { returns(StreamChat::StreamResponse) }
450
447
  def list_channel_types
451
448
  get('channeltypes')
452
449
  end
453
450
 
454
451
  # Updates a channel type.
455
- T::Sig::WithoutRuntime.sig { params(channel_type: String, options: T.untyped).returns(StreamChat::StreamResponse) }
452
+ sig { params(channel_type: String, options: T.untyped).returns(StreamChat::StreamResponse) }
456
453
  def update_channel_type(channel_type, **options)
457
454
  put("channeltypes/#{channel_type}", data: options)
458
455
  end
459
456
 
460
457
  # Deletes a channel type.
461
- T::Sig::WithoutRuntime.sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
458
+ sig { params(channel_type: String).returns(StreamChat::StreamResponse) }
462
459
  def delete_channel_type(channel_type)
463
460
  delete("channeltypes/#{channel_type}")
464
461
  end
@@ -471,13 +468,13 @@ module StreamChat
471
468
  #
472
469
  # @return [StreamChat::Channel]
473
470
  #
474
- T::Sig::WithoutRuntime.sig { params(channel_type: String, channel_id: T.nilable(String), data: T.nilable(StringKeyHash)).returns(StreamChat::Channel) }
471
+ sig { params(channel_type: String, channel_id: T.nilable(String), data: T.nilable(StringKeyHash)).returns(StreamChat::Channel) }
475
472
  def channel(channel_type, channel_id: nil, data: nil)
476
473
  StreamChat::Channel.new(self, channel_type, channel_id, data)
477
474
  end
478
475
 
479
476
  # Adds a device to a user.
480
- T::Sig::WithoutRuntime.sig { params(device_id: String, push_provider: String, user_id: String, push_provider_name: T.nilable(String)).returns(StreamChat::StreamResponse) }
477
+ sig { params(device_id: String, push_provider: String, user_id: String, push_provider_name: T.nilable(String)).returns(StreamChat::StreamResponse) }
481
478
  def add_device(device_id, push_provider, user_id, push_provider_name = nil)
482
479
  post('devices', data: {
483
480
  id: device_id,
@@ -488,20 +485,20 @@ module StreamChat
488
485
  end
489
486
 
490
487
  # Delete a device.
491
- T::Sig::WithoutRuntime.sig { params(device_id: String, user_id: String).returns(StreamChat::StreamResponse) }
488
+ sig { params(device_id: String, user_id: String).returns(StreamChat::StreamResponse) }
492
489
  def delete_device(device_id, user_id)
493
490
  delete('devices', params: { id: device_id, user_id: user_id })
494
491
  end
495
492
 
496
493
  # Returns a list of devices.
497
- T::Sig::WithoutRuntime.sig { params(user_id: String).returns(StreamChat::StreamResponse) }
494
+ sig { params(user_id: String).returns(StreamChat::StreamResponse) }
498
495
  def get_devices(user_id)
499
496
  get('devices', params: { user_id: user_id })
500
497
  end
501
498
 
502
499
  # Get rate limit quotas and usage.
503
500
  # If no params are toggled, all limits for all endpoints are returned.
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) }
501
+ sig { params(server_side: T::Boolean, android: T::Boolean, ios: T::Boolean, web: T::Boolean, endpoints: T::Array[String]).returns(StreamChat::StreamResponse) }
505
502
  def get_rate_limits(server_side: false, android: false, ios: false, web: false, endpoints: [])
506
503
  params = {}
507
504
  params['server_side'] = server_side if server_side
@@ -514,14 +511,14 @@ module StreamChat
514
511
  end
515
512
 
516
513
  # Verify the signature added to a webhook event.
517
- T::Sig::WithoutRuntime.sig { params(request_body: String, x_signature: String).returns(T::Boolean) }
514
+ sig { params(request_body: String, x_signature: String).returns(T::Boolean) }
518
515
  def verify_webhook(request_body, x_signature)
519
516
  signature = OpenSSL::HMAC.hexdigest('SHA256', @api_secret, request_body)
520
517
  signature == x_signature
521
518
  end
522
519
 
523
520
  # Allows you to send custom events to a connected user.
524
- T::Sig::WithoutRuntime.sig { params(user_id: String, event: StringKeyHash).returns(StreamChat::StreamResponse) }
521
+ sig { params(user_id: String, event: StringKeyHash).returns(StreamChat::StreamResponse) }
525
522
  def send_user_event(user_id, event)
526
523
  post("users/#{user_id}/event", data: event)
527
524
  end
@@ -529,13 +526,13 @@ module StreamChat
529
526
  # Translates an existing message to another language. The source language
530
527
  # is inferred from the user language or detected automatically by analyzing its text.
531
528
  # If possible it is recommended to store the user language. See the documentation.
532
- T::Sig::WithoutRuntime.sig { params(message_id: String, language: String).returns(StreamChat::StreamResponse) }
529
+ sig { params(message_id: String, language: String).returns(StreamChat::StreamResponse) }
533
530
  def translate_message(message_id, language)
534
531
  post("messages/#{message_id}/translate", data: { language: language })
535
532
  end
536
533
 
537
534
  # Runs a message command action.
538
- T::Sig::WithoutRuntime.sig { params(message_id: String, data: StringKeyHash).returns(StreamChat::StreamResponse) }
535
+ sig { params(message_id: String, data: StringKeyHash).returns(StreamChat::StreamResponse) }
539
536
  def run_message_action(message_id, data)
540
537
  post("messages/#{message_id}/action", data: data)
541
538
  end
@@ -546,7 +543,7 @@ module StreamChat
546
543
  # Support and livestreams are common use cases for guests users because really
547
544
  # often you want a visitor to be able to use chat on your application without (or before)
548
545
  # they have a regular user account.
549
- T::Sig::WithoutRuntime.sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
546
+ sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
550
547
  def create_guest(user)
551
548
  post('guests', data: user)
552
549
  end
@@ -558,7 +555,7 @@ module StreamChat
558
555
  # of the most common profane words.
559
556
  # You can manage your own block lists via the Stream dashboard or APIs to a manage
560
557
  # blocklists and configure your channel types to use them.
561
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
558
+ sig { returns(StreamChat::StreamResponse) }
562
559
  def list_blocklists
563
560
  get('blocklists')
564
561
  end
@@ -570,7 +567,7 @@ module StreamChat
570
567
  # of the most common profane words.
571
568
  # You can manage your own block lists via the Stream dashboard or APIs to a manage
572
569
  # blocklists and configure your channel types to use them.
573
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
570
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
574
571
  def get_blocklist(name)
575
572
  get("blocklists/#{name}")
576
573
  end
@@ -582,7 +579,7 @@ module StreamChat
582
579
  # of the most common profane words.
583
580
  # You can manage your own block lists via the Stream dashboard or APIs to a manage
584
581
  # blocklists and configure your channel types to use them.
585
- T::Sig::WithoutRuntime.sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
582
+ sig { params(name: String, words: T::Array[String]).returns(StreamChat::StreamResponse) }
586
583
  def create_blocklist(name, words)
587
584
  post('blocklists', data: { name: name, words: words })
588
585
  end
@@ -594,7 +591,7 @@ module StreamChat
594
591
  # of the most common profane words.
595
592
  # You can manage your own block lists via the Stream dashboard or APIs to a manage
596
593
  # blocklists and configure your channel types to use them.
597
- T::Sig::WithoutRuntime.sig { params(name: String, words: StringKeyHash).returns(StreamChat::StreamResponse) }
594
+ sig { params(name: String, words: T::Array[String]).returns(StreamChat::StreamResponse) }
598
595
  def update_blocklist(name, words)
599
596
  put("blocklists/#{name}", data: { words: words })
600
597
  end
@@ -606,7 +603,7 @@ module StreamChat
606
603
  # of the most common profane words.
607
604
  # You can manage your own block lists via the Stream dashboard or APIs to a manage
608
605
  # blocklists and configure your channel types to use them.
609
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
606
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
610
607
  def delete_blocklist(name)
611
608
  delete("blocklists/#{name}")
612
609
  end
@@ -616,51 +613,51 @@ module StreamChat
616
613
  # Channel exports are created asynchronously, you can use the Task ID returned by
617
614
  # the APIs to keep track of the status and to download the final result when it is ready.
618
615
  # Use `get_task` to check the status of the export.
619
- T::Sig::WithoutRuntime.sig { params(channels: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
616
+ sig { params(channels: StringKeyHash, options: T.untyped).returns(StreamChat::StreamResponse) }
620
617
  def export_channels(*channels, **options)
621
618
  post('export_channels', data: { channels: channels, **options })
622
619
  end
623
620
 
624
621
  # Returns the status of a channel export. It contains the URL to the JSON file.
625
- T::Sig::WithoutRuntime.sig { params(task_id: String).returns(StreamChat::StreamResponse) }
622
+ sig { params(task_id: String).returns(StreamChat::StreamResponse) }
626
623
  def get_export_channel_status(task_id)
627
624
  get("export_channels/#{task_id}")
628
625
  end
629
626
 
630
627
  # Returns the status of a task.
631
- T::Sig::WithoutRuntime.sig { params(task_id: String).returns(StreamChat::StreamResponse) }
628
+ sig { params(task_id: String).returns(StreamChat::StreamResponse) }
632
629
  def get_task(task_id)
633
630
  get("tasks/#{task_id}")
634
631
  end
635
632
 
636
633
  # Delete users asynchronously. Use `get_task` to check the status of the task.
637
- T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(StringKeyHash), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
634
+ sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(String), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
638
635
  def delete_users(user_ids, user: SOFT_DELETE, messages: nil, conversations: nil)
639
636
  post('users/delete', data: { user_ids: user_ids, user: user, messages: messages, conversations: conversations })
640
637
  end
641
638
 
642
639
  # Deletes multiple channels. This is an asynchronous operation and the returned value is a task Id.
643
640
  # You can use `get_task` method to check the status of the task.
644
- T::Sig::WithoutRuntime.sig { params(cids: T::Array[String], hard_delete: T::Boolean).returns(StreamChat::StreamResponse) }
641
+ sig { params(cids: T::Array[String], hard_delete: T::Boolean).returns(StreamChat::StreamResponse) }
645
642
  def delete_channels(cids, hard_delete: false)
646
643
  post('channels/delete', data: { cids: cids, hard_delete: hard_delete })
647
644
  end
648
645
 
649
646
  # Revoke tokens for an application issued since the given date.
650
- T::Sig::WithoutRuntime.sig { params(before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
647
+ sig { params(before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
651
648
  def revoke_tokens(before)
652
649
  before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
653
650
  update_app_settings({ 'revoke_tokens_issued_before' => before })
654
651
  end
655
652
 
656
653
  # Revoke tokens for a user issued since the given date.
657
- T::Sig::WithoutRuntime.sig { params(user_id: String, before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
654
+ sig { params(user_id: String, before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
658
655
  def revoke_user_token(user_id, before)
659
656
  revoke_users_token([user_id], before)
660
657
  end
661
658
 
662
659
  # Revoke tokens for users issued since.
663
- T::Sig::WithoutRuntime.sig { params(user_ids: T::Array[String], before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
660
+ sig { params(user_ids: T::Array[String], before: T.any(DateTime, String)).returns(StreamChat::StreamResponse) }
664
661
  def revoke_users_token(user_ids, before)
665
662
  before = T.cast(before, DateTime).rfc3339 if before.instance_of?(DateTime)
666
663
 
@@ -676,27 +673,27 @@ module StreamChat
676
673
  update_users_partial(updates)
677
674
  end
678
675
 
679
- T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
676
+ sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
680
677
  def put(relative_url, params: nil, data: nil)
681
678
  make_http_request(:put, relative_url, params: params, data: data)
682
679
  end
683
680
 
684
- T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
681
+ sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
685
682
  def post(relative_url, params: nil, data: nil)
686
683
  make_http_request(:post, relative_url, params: params, data: data)
687
684
  end
688
685
 
689
- T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
686
+ sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
690
687
  def get(relative_url, params: nil)
691
688
  make_http_request(:get, relative_url, params: params)
692
689
  end
693
690
 
694
- T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
691
+ sig { params(relative_url: String, params: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
695
692
  def delete(relative_url, params: nil)
696
693
  make_http_request(:delete, relative_url, params: params)
697
694
  end
698
695
 
699
- T::Sig::WithoutRuntime.sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
696
+ sig { params(relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
700
697
  def patch(relative_url, params: nil, data: nil)
701
698
  make_http_request(:patch, relative_url, params: params, data: data)
702
699
  end
@@ -705,7 +702,7 @@ module StreamChat
705
702
  #
706
703
  # This functionality defaults to using the Stream CDN. If you would like, you can
707
704
  # easily change the logic to upload to your own CDN of choice.
708
- T::Sig::WithoutRuntime.sig { params(relative_url: String, file_url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
705
+ sig { params(relative_url: String, file_url: String, user: StringKeyHash, content_type: T.nilable(String)).returns(StreamChat::StreamResponse) }
709
706
  def send_file(relative_url, file_url, user, content_type = nil)
710
707
  url = [@base_url, relative_url].join('/')
711
708
 
@@ -725,7 +722,7 @@ module StreamChat
725
722
  end
726
723
 
727
724
  # Check push notification settings.
728
- T::Sig::WithoutRuntime.sig { params(push_data: StringKeyHash).returns(StreamChat::StreamResponse) }
725
+ sig { params(push_data: StringKeyHash).returns(StreamChat::StreamResponse) }
729
726
  def check_push(push_data)
730
727
  post('check_push', data: push_data)
731
728
  end
@@ -733,103 +730,103 @@ module StreamChat
733
730
  # Check SQS Push settings
734
731
  #
735
732
  # When no parameters are given, the current SQS app settings are used.
736
- T::Sig::WithoutRuntime.sig { params(sqs_key: T.nilable(String), sqs_secret: T.nilable(String), sqs_url: T.nilable(String)).returns(StreamChat::StreamResponse) }
733
+ sig { params(sqs_key: T.nilable(String), sqs_secret: T.nilable(String), sqs_url: T.nilable(String)).returns(StreamChat::StreamResponse) }
737
734
  def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
738
735
  post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
739
736
  end
740
737
 
741
738
  # Creates a new command.
742
- T::Sig::WithoutRuntime.sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
739
+ sig { params(command: StringKeyHash).returns(StreamChat::StreamResponse) }
743
740
  def create_command(command)
744
741
  post('commands', data: command)
745
742
  end
746
743
 
747
744
  # Gets a comamnd.
748
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
745
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
749
746
  def get_command(name)
750
747
  get("commands/#{name}")
751
748
  end
752
749
 
753
750
  # Updates a command.
754
- T::Sig::WithoutRuntime.sig { params(name: String, command: StringKeyHash).returns(StreamChat::StreamResponse) }
751
+ sig { params(name: String, command: StringKeyHash).returns(StreamChat::StreamResponse) }
755
752
  def update_command(name, command)
756
753
  put("commands/#{name}", data: command)
757
754
  end
758
755
 
759
756
  # Deletes a command.
760
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
757
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
761
758
  def delete_command(name)
762
759
  delete("commands/#{name}")
763
760
  end
764
761
 
765
762
  # Lists all commands.
766
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
763
+ sig { returns(StreamChat::StreamResponse) }
767
764
  def list_commands
768
765
  get('commands')
769
766
  end
770
767
 
771
768
  # Lists all permissions.
772
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
769
+ sig { returns(StreamChat::StreamResponse) }
773
770
  def list_permissions
774
771
  get('permissions')
775
772
  end
776
773
 
777
774
  # Gets a permission.
778
- T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
775
+ sig { params(id: String).returns(StreamChat::StreamResponse) }
779
776
  def get_permission(id)
780
777
  get("permissions/#{id}")
781
778
  end
782
779
 
783
780
  # Creates a new permission.
784
- T::Sig::WithoutRuntime.sig { params(permission: StringKeyHash).returns(StreamChat::StreamResponse) }
781
+ sig { params(permission: StringKeyHash).returns(StreamChat::StreamResponse) }
785
782
  def create_permission(permission)
786
783
  post('permissions', data: permission)
787
784
  end
788
785
 
789
786
  # Updates a permission.
790
- T::Sig::WithoutRuntime.sig { params(id: String, permission: StringKeyHash).returns(StreamChat::StreamResponse) }
787
+ sig { params(id: String, permission: StringKeyHash).returns(StreamChat::StreamResponse) }
791
788
  def update_permission(id, permission)
792
789
  put("permissions/#{id}", data: permission)
793
790
  end
794
791
 
795
792
  # Deletes a permission by id.
796
- T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
793
+ sig { params(id: String).returns(StreamChat::StreamResponse) }
797
794
  def delete_permission(id)
798
795
  delete("permissions/#{id}")
799
796
  end
800
797
 
801
798
  # Create a new role.
802
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
799
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
803
800
  def create_role(name)
804
801
  post('roles', data: { name: name })
805
802
  end
806
803
 
807
804
  # Delete a role by name.
808
- T::Sig::WithoutRuntime.sig { params(name: String).returns(StreamChat::StreamResponse) }
805
+ sig { params(name: String).returns(StreamChat::StreamResponse) }
809
806
  def delete_role(name)
810
807
  delete("roles/#{name}")
811
808
  end
812
809
 
813
810
  # List all roles.
814
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
811
+ sig { returns(StreamChat::StreamResponse) }
815
812
  def list_roles
816
813
  get('roles')
817
814
  end
818
815
 
819
816
  # Create or update a push provider.
820
- T::Sig::WithoutRuntime.sig { params(push_provider: StringKeyHash).returns(StreamChat::StreamResponse) }
817
+ sig { params(push_provider: StringKeyHash).returns(StreamChat::StreamResponse) }
821
818
  def upsert_push_provider(push_provider)
822
819
  post('push_providers', data: { push_provider: push_provider })
823
820
  end
824
821
 
825
822
  # Delete a push provider by type and name.
826
- T::Sig::WithoutRuntime.sig { params(type: String, name: String).returns(StreamChat::StreamResponse) }
823
+ sig { params(type: String, name: String).returns(StreamChat::StreamResponse) }
827
824
  def delete_push_provider(type, name)
828
825
  delete("push_providers/#{type}/#{name}")
829
826
  end
830
827
 
831
828
  # Lists all push providers.
832
- T::Sig::WithoutRuntime.sig { returns(StreamChat::StreamResponse) }
829
+ sig { returns(StreamChat::StreamResponse) }
833
830
  def list_push_providers
834
831
  get('push_providers')
835
832
  end
@@ -839,7 +836,7 @@ module StreamChat
839
836
  # url_resp = client.create_import_url('myfile.json')
840
837
  # Faraday.put(url_resp['upload_url'], File.read('myfile.json'), 'Content-Type' => 'application/json')
841
838
  # client.create_import(url_resp['path'], 'upsert')
842
- T::Sig::WithoutRuntime.sig { params(filename: String).returns(StreamChat::StreamResponse) }
839
+ sig { params(filename: String).returns(StreamChat::StreamResponse) }
843
840
  def create_import_url(filename)
844
841
  post('import_urls', data: { filename: filename })
845
842
  end
@@ -849,120 +846,120 @@ module StreamChat
849
846
  # url_resp = client.create_import_url('myfile.json')
850
847
  # Faraday.put(url_resp['upload_url'], File.read('myfile.json'), 'Content-Type' => 'application/json')
851
848
  # client.create_import(url_resp['path'], 'upsert')
852
- T::Sig::WithoutRuntime.sig { params(path: String, mode: String).returns(StreamChat::StreamResponse) }
849
+ sig { params(path: String, mode: String).returns(StreamChat::StreamResponse) }
853
850
  def create_import(path, mode)
854
851
  post('imports', data: { path: path, mode: mode })
855
852
  end
856
853
 
857
854
  # Returns an import by id.
858
- T::Sig::WithoutRuntime.sig { params(id: String).returns(StreamChat::StreamResponse) }
855
+ sig { params(id: String).returns(StreamChat::StreamResponse) }
859
856
  def get_import(id)
860
857
  get("imports/#{id}")
861
858
  end
862
859
 
863
860
  # Lists imports. Options dictionary can contain 'offset' and 'limit' keys for pagination.
864
- T::Sig::WithoutRuntime.sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
861
+ sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
865
862
  def list_imports(options)
866
863
  get('imports', params: options)
867
864
  end
868
865
 
869
866
  # Creates a campaign.
870
- T::Sig::WithoutRuntime.sig { params(campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
867
+ sig { params(campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
871
868
  def create_campaign(campaign)
872
869
  post('campaigns', data: { campaign: campaign })
873
870
  end
874
871
 
875
872
  # Gets a campaign.
876
- T::Sig::WithoutRuntime.sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
873
+ sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
877
874
  def get_campaign(campaign_id)
878
875
  get("campaigns/#{campaign_id}")
879
876
  end
880
877
 
881
878
  # Lists all campaigns. Options dictionary can contain 'offset' and 'limit' keys for pagination.
882
- T::Sig::WithoutRuntime.sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
879
+ sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
883
880
  def list_campaigns(options)
884
881
  get('campaigns', params: options)
885
882
  end
886
883
 
887
884
  # Updates a campaign.
888
- T::Sig::WithoutRuntime.sig { params(campaign_id: String, campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
885
+ sig { params(campaign_id: String, campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
889
886
  def update_campaign(campaign_id, campaign)
890
887
  put("campaigns/#{campaign_id}", data: { campaign: campaign })
891
888
  end
892
889
 
893
890
  # Deletes a campaign.
894
- T::Sig::WithoutRuntime.sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
891
+ sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
895
892
  def delete_campaign(campaign_id)
896
893
  delete("campaigns/#{campaign_id}")
897
894
  end
898
895
 
899
896
  # Schedules a campaign.
900
- T::Sig::WithoutRuntime.sig { params(campaign_id: String, send_at: Integer).returns(StreamChat::StreamResponse) }
897
+ sig { params(campaign_id: String, send_at: Integer).returns(StreamChat::StreamResponse) }
901
898
  def schedule_campaign(campaign_id, send_at)
902
899
  patch("campaigns/#{campaign_id}/schedule", data: { send_at: send_at })
903
900
  end
904
901
 
905
902
  # Stops a campaign.
906
- T::Sig::WithoutRuntime.sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
903
+ sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
907
904
  def stop_campaign(campaign_id)
908
905
  patch("campaigns/#{campaign_id}/stop")
909
906
  end
910
907
 
911
908
  # Resumes a campaign.
912
- T::Sig::WithoutRuntime.sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
909
+ sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
913
910
  def resume_campaign(campaign_id)
914
911
  patch("campaigns/#{campaign_id}/resume")
915
912
  end
916
913
 
917
914
  # Tests a campaign.
918
- T::Sig::WithoutRuntime.sig { params(campaign_id: String, users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
915
+ sig { params(campaign_id: String, users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
919
916
  def test_campaign(campaign_id, users)
920
917
  post("campaigns/#{campaign_id}/test", data: { users: users })
921
918
  end
922
919
 
923
920
  # Creates a campaign segment.
924
- T::Sig::WithoutRuntime.sig { params(segment: StringKeyHash).returns(StreamChat::StreamResponse) }
921
+ sig { params(segment: StringKeyHash).returns(StreamChat::StreamResponse) }
925
922
  def create_segment(segment)
926
923
  post('segments', data: { segment: segment })
927
924
  end
928
925
 
929
926
  # Gets a campaign segment.
930
- T::Sig::WithoutRuntime.sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
927
+ sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
931
928
  def get_segment(segment_id)
932
929
  get("segments/#{segment_id}")
933
930
  end
934
931
 
935
932
  # Lists all campaign segments. Options dictionary can contain 'offset' and 'limit' keys for pagination.
936
- T::Sig::WithoutRuntime.sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
933
+ sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
937
934
  def list_segments(options)
938
935
  get('segments', params: options)
939
936
  end
940
937
 
941
938
  # Updates a campaign segment.
942
- T::Sig::WithoutRuntime.sig { params(segment_id: String, segment: StringKeyHash).returns(StreamChat::StreamResponse) }
939
+ sig { params(segment_id: String, segment: StringKeyHash).returns(StreamChat::StreamResponse) }
943
940
  def update_segment(segment_id, segment)
944
941
  put("segments/#{segment_id}", data: { segment: segment })
945
942
  end
946
943
 
947
944
  # Deletes a campaign segment.
948
- T::Sig::WithoutRuntime.sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
945
+ sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
949
946
  def delete_segment(segment_id)
950
947
  delete("segments/#{segment_id}")
951
948
  end
952
949
 
953
950
  private
954
951
 
955
- T::Sig::WithoutRuntime.sig { returns(T::Hash[String, String]) }
952
+ sig { returns(T::Hash[String, String]) }
956
953
  def get_default_params
957
954
  { api_key: @api_key }
958
955
  end
959
956
 
960
- T::Sig::WithoutRuntime.sig { returns(String) }
957
+ sig { returns(String) }
961
958
  def get_user_agent
962
959
  "stream-ruby-client-#{StreamChat::VERSION}"
963
960
  end
964
961
 
965
- T::Sig::WithoutRuntime.sig { returns(T::Hash[String, String]) }
962
+ sig { returns(T::Hash[String, String]) }
966
963
  def get_default_headers
967
964
  {
968
965
  'Content-Type': 'application/json',
@@ -970,7 +967,7 @@ module StreamChat
970
967
  }
971
968
  end
972
969
 
973
- T::Sig::WithoutRuntime.sig { params(response: Faraday::Response).returns(StreamChat::StreamResponse) }
970
+ sig { params(response: Faraday::Response).returns(StreamChat::StreamResponse) }
974
971
  def parse_response(response)
975
972
  begin
976
973
  parsed_result = JSON.parse(response.body)
@@ -982,7 +979,7 @@ module StreamChat
982
979
  StreamResponse.new(parsed_result, response)
983
980
  end
984
981
 
985
- T::Sig::WithoutRuntime.sig { params(method: Symbol, relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
982
+ sig { params(method: Symbol, relative_url: String, params: T.nilable(StringKeyHash), data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
986
983
  def make_http_request(method, relative_url, params: nil, data: nil)
987
984
  headers = get_default_headers
988
985
  headers['Authorization'] = @auth_token