stream-chat-ruby 2.3.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77a57822787deb58ec33e8b6a717e26edba13b3edbcb818abd55bc6bf86ac516
4
- data.tar.gz: 917861d1fafe2b42e7d849643f9a32941ac31039ff7a3de554229d77ca60aae4
3
+ metadata.gz: 31e7de9bf8ce95a2bf565ac99b5a686deb0195bb3ec20f2004ec784f84d00ff0
4
+ data.tar.gz: '0959555927fa04219edc014cac1247cbca8942387360b2099080138ddbd22664'
5
5
  SHA512:
6
- metadata.gz: 03655565e49824a54aa9c27b9621a075ede33b0b063e46aa8bb493a490a776ec8dff273992502668862df8afb0dd23c5574742f83942ad873c2f9832ba7e6d2e
7
- data.tar.gz: 798df127e33162706774f4eb7a6e1e6d4d294b472db0a81c7a657049c2d4505cf089a9208c977aa2b17e9533be05c08764d378db895d05cfb10b5dd663e21af6
6
+ metadata.gz: 70608f85204fb4a1c9451fed4f27281579d23c5e558aea25d752735309b62409cdd15986ad6cb1550e65a5e9072fde29b1792fbf16c2dc5fc1c8b020f1f68b96
7
+ data.tar.gz: 4907cdf3f110e825a47c45f0759684e9bf3ae4449f74ff8546238d60f39e92c611f1f3e8b3fd855dfe2bf06846432968ee7fa56ee46f3cc946b03af63885b121
@@ -6,9 +6,10 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
+ max-parallel: 1
9
10
  matrix:
10
- ruby: [ '2.5', '2.6', '2.7' ]
11
- name: Ruby ${{ matrix.ruby }} sample
11
+ ruby: ['2.5', '2.6', '2.7', '3.0']
12
+ name: Ruby ${{ matrix.ruby }}
12
13
  steps:
13
14
  - uses: actions/checkout@v2
14
15
  - uses: actions/setup-ruby@v1
data/.gitignore CHANGED
@@ -48,3 +48,4 @@ Gemfile.lock
48
48
 
49
49
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
50
  .rvmrc
51
+ .envrc
data/CHANGELOG.md CHANGED
@@ -1,7 +1,38 @@
1
+ ## May 31st, 2021 - 2.9.0
2
+
3
+ - Add support for app and user level token revoke
4
+
5
+ ## May 21st, 2021 - 2.8.0
6
+
7
+ - Add query message flags support
8
+
9
+ ## March 17th, 2021 - 2.7.0
10
+
11
+ - Add Ruby 3.x support
12
+ - Update CI to run all tests for all versions
13
+
14
+ ## March 9th, 2021 - 2.6.0
15
+
16
+ - Add get_rate_limits endpoint
17
+
18
+ ## February 3rd, 2021 - 2.5.0
19
+
20
+ - Add channel partial update
21
+ - Increase convenience in query members
22
+ - Improve internal symbol conversions
23
+
24
+ ## January 20th, 2021 - 2.4.0
25
+
26
+ - Add query_members to channel
27
+ - Use post endpoint for query channels instead of get
28
+ - Extract common code for sorting into a helper for query calls
29
+
1
30
  ## January 5th, 2021 - 2.3.0
31
+
2
32
  - Add check SQS helper
3
33
 
4
34
  ## January 4th, 2021 - 2.2.0
35
+
5
36
  - Add support for export channels
6
37
  - Improve readme for blocklist and export channels
7
38
  - Improve running tests for multiple versions of ruby
@@ -9,27 +40,34 @@
9
40
  - Move to GitHub Actions
10
41
 
11
42
  ## October 5th, 2020 - 2.1.0
43
+
12
44
  - Add support for blocklist
13
45
 
14
46
  ## October 2nd, 2020 - 2.0.0
47
+
15
48
  - Drop EOL Ruby versions: 2.3 && 2.4
16
49
  - Setup Rubocop and mark string literals as frozen
17
50
 
18
51
  ## August 3rd, 2020 - 1.1.3
52
+
19
53
  - Fixed Argument Error on delete_user
20
54
 
21
55
  ## April 23th, 2020 - 1.1.2
56
+
22
57
  - Fixed ArgumentError when no users was passed
23
58
 
24
59
  ## March 30th, 2020 - 1.1.1
60
+
25
61
  - Fixed few minor issues
26
62
 
27
63
  ## Oct 27th, 2019 - 1.1.0
64
+
28
65
  - Mark gems use for testing as development dependencies
29
66
  - Added `send_file`, `send_image`, `delete_file`, `delete_image`
30
67
  - Added `invite_members`
31
68
 
32
69
  ## Oct 19th, 2019 - 1.0.0
70
+
33
71
  - Added `channel.hide` and `channel.show`
34
72
  - Added `client.flag_message` and `client.unflag_message`
35
73
  - Added `client.flag_user` and `client.unflag_user`
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # stream-chat-ruby
2
2
 
3
- [![build](https://github.com/GetStream/stream-chat-ruby/workflows/build/badge.svg)](https://github.com/GetStream/stream-chat-ruby/actions) [![Gem Version](https://badge.fury.io/rb/stream-chat-ruby.svg)](http://badge.fury.io/rb/stream-chat-ruby)
3
+ [![build](https://github.com/GetStream/stream-chat-ruby/workflows/build/badge.svg)](https://github.com/GetStream/stream-chat-ruby/actions) [![Gem Version](https://badge.fury.io/rb/stream-chat-ruby.svg)](http://badge.fury.io/rb/stream-chat-ruby)
4
4
 
5
5
  stream-chat-ruby is the official Ruby client for [Stream chat](https://getstream.io/chat/) a service for building chat applications.
6
6
 
7
7
  You can sign up for a Stream account at https://getstream.io/chat/get_started/.
8
8
 
9
9
  You can use this library to access chat API endpoints server-side. For the
10
- client-side integrations (web and mobile) have a look at the Javascript, iOS and
10
+ client-side integrations (web and mobile) have a look at the JavaScript, iOS and
11
11
  Android SDK libraries (https://getstream.io/chat/).
12
12
 
13
13
  ### Installation
14
14
 
15
15
  stream-chat-ruby supports:
16
16
 
17
- - Ruby (2.7, 2.6, 2.5)
17
+ - Ruby (3.0, 2.7, 2.6, 2.5)
18
18
 
19
19
  #### Install
20
20
 
@@ -28,9 +28,8 @@ gem install stream-chat-ruby
28
28
 
29
29
  ### Supported features
30
30
 
31
- - Chat channels
31
+ - Chat channel type, channels and members
32
32
  - Messages
33
- - Chat channel types
34
33
  - User management
35
34
  - Moderation API
36
35
  - Push configuration
@@ -131,6 +130,17 @@ chan.unban_user('bob-1')
131
130
 
132
131
  # Query channel state
133
132
  chan.query({'messages' => { 'limit' => 10, 'id_lte' => m1['id']}})
133
+
134
+ # Update metadata (overwrite)
135
+ chan.update({'motd' => 'one apple a day....'})
136
+
137
+ # Update partial
138
+ # 1. key-value pairs to set
139
+ # 2. keys to unset (remove)
140
+ chan.update_partial({color: 'blue', age: 30}, ['motd'])
141
+
142
+ # Query channel members
143
+ chan.query_members({name: {'$autocomplete': 'test'}}, sort: {last_created_at: -1}, offset: 5, limit: 5)
134
144
  ```
135
145
 
136
146
  ### Messages
@@ -155,6 +165,7 @@ client.remove_device(jane_phone['id'], jane_phone['user_id'])
155
165
  ```
156
166
 
157
167
  ### Blocklists
168
+
158
169
  ```ruby
159
170
  # Create a blocklist
160
171
  client.create_blocklist('my_blocker', %w[fudge cream sugar])
@@ -170,6 +181,7 @@ client.delete_blocklist('my_blocker')
170
181
  ```
171
182
 
172
183
  ### Export Channels
184
+
173
185
  ```ruby
174
186
  # Register an export
175
187
  response = client.export_channels({type: 'messaging', id: 'jane'})
@@ -179,6 +191,19 @@ status_response = client.get_export_channel_status(response['task_id'])
179
191
  # status_response['status'] == 'pending', 'completed'
180
192
  ```
181
193
 
194
+ ### Rate limits
195
+
196
+ ```ruby
197
+ # Get all rate limits
198
+ limits = client.get_rate_limits
199
+
200
+ # Get rate limits for specific platform(s)
201
+ limits = client.get_rate_limits(server_side: true)
202
+
203
+ # Get rate limits for specific platforms and endpoints
204
+ limits = client.get_rate_limits(android: true, ios: true, endpoints: ['QueryChannels', 'SendMessage'])
205
+ ```
206
+
182
207
  ### Example Rails application
183
208
 
184
209
  See [an example rails application using the Ruby SDK](https://github.com/GetStream/rails-chat-example).
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'stream-chat/errors'
4
+ require 'stream-chat/util'
4
5
 
5
6
  module StreamChat
6
7
  class Channel # rubocop:todo Metrics/ClassLength # rubocop:todo Style/Documentation
7
8
  attr_reader :id
8
9
  attr_reader :channel_type
9
10
  attr_reader :custom_data
11
+ attr_reader :members
10
12
 
11
13
  def initialize(client, channel_type, channel_id = nil, custom_data = nil)
12
14
  @channel_type = channel_type
@@ -23,7 +25,7 @@ module StreamChat
23
25
  end
24
26
 
25
27
  def send_message(message, user_id)
26
- payload = { "message": add_user_id(message, user_id) }
28
+ payload = { message: add_user_id(message, user_id) }
27
29
  @client.post("#{url}/message", data: payload)
28
30
  end
29
31
 
@@ -33,24 +35,24 @@ module StreamChat
33
35
  end
34
36
 
35
37
  def send_reaction(message_id, reaction, user_id)
36
- payload = { "reaction": add_user_id(reaction, user_id) }
38
+ payload = { reaction: add_user_id(reaction, user_id) }
37
39
  @client.post("messages/#{message_id}/reaction", data: payload)
38
40
  end
39
41
 
40
42
  def delete_reaction(message_id, reaction_type, user_id)
41
43
  @client.delete(
42
44
  "messages/#{message_id}/reaction/#{reaction_type}",
43
- params: { "user_id": user_id }
45
+ params: { user_id: user_id }
44
46
  )
45
47
  end
46
48
 
47
49
  def create(user_id)
48
- @custom_data['created_by'] = { "id": user_id }
50
+ @custom_data['created_by'] = { id: user_id }
49
51
  query(watch: false, state: false, presence: false)
50
52
  end
51
53
 
52
54
  def query(**options)
53
- payload = { "state": true, "data": @custom_data }.merge(options)
55
+ payload = { state: true, data: @custom_data }.merge(options)
54
56
  url = "channels/#{@channel_type}"
55
57
  url = "#{url}/#{@id}" unless @id.nil?
56
58
 
@@ -59,11 +61,36 @@ module StreamChat
59
61
  state
60
62
  end
61
63
 
64
+ def query_members(filter_conditions = {}, sort: nil, **options)
65
+ params = {}.merge(options).merge({
66
+ id: @id,
67
+ type: @channel_type,
68
+ filter_conditions: filter_conditions,
69
+ sort: get_sort_fields(sort)
70
+ })
71
+
72
+ if @id == '' && @members.length.positive?
73
+ params['members'] = []
74
+ @members&.each do |m|
75
+ params['members'] << m['user'].nil? ? m['user_id'] : m['user']['id']
76
+ end
77
+ end
78
+
79
+ @client.get('members', params: { payload: params.to_json })
80
+ end
81
+
62
82
  def update(channel_data, update_message = nil)
63
- payload = { "data": channel_data, "message": update_message }
83
+ payload = { data: channel_data, message: update_message }
64
84
  @client.post(url, data: payload)
65
85
  end
66
86
 
87
+ def update_partial(set = nil, unset = nil)
88
+ raise StreamChannelException 'set or unset is needed' if set.nil? && unset.nil?
89
+
90
+ payload = { set: set, unset: unset }
91
+ @client.patch(url, data: payload)
92
+ end
93
+
67
94
  def delete
68
95
  @client.delete(url)
69
96
  end
@@ -73,23 +100,23 @@ module StreamChat
73
100
  end
74
101
 
75
102
  def add_members(user_ids)
76
- @client.post(url, data: { "add_members": user_ids })
103
+ @client.post(url, data: { add_members: user_ids })
77
104
  end
78
105
 
79
106
  def invite_members(user_ids)
80
- @client.post(url, data: { "invites": user_ids })
107
+ @client.post(url, data: { invites: user_ids })
81
108
  end
82
109
 
83
110
  def add_moderators(user_ids)
84
- @client.post(url, data: { "add_moderators": user_ids })
111
+ @client.post(url, data: { add_moderators: user_ids })
85
112
  end
86
113
 
87
114
  def remove_members(user_ids)
88
- @client.post(url, data: { "remove_members": user_ids })
115
+ @client.post(url, data: { remove_members: user_ids })
89
116
  end
90
117
 
91
118
  def demote_moderators(user_ids)
92
- @client.post(url, data: { "demote_moderators": user_ids })
119
+ @client.post(url, data: { demote_moderators: user_ids })
93
120
  end
94
121
 
95
122
  def mark_read(user_id, **options)
@@ -130,17 +157,17 @@ module StreamChat
130
157
  end
131
158
 
132
159
  def delete_file(url)
133
- @client.delete("#{self.url}/file", params: { "url": url })
160
+ @client.delete("#{self.url}/file", params: { url: url })
134
161
  end
135
162
 
136
163
  def delete_image(url)
137
- @client.delete("#{self.url}/image", params: { "url": url })
164
+ @client.delete("#{self.url}/image", params: { url: url })
138
165
  end
139
166
 
140
167
  private
141
168
 
142
169
  def add_user_id(payload, user_id)
143
- payload.merge({ "user": { "id": user_id } })
170
+ payload.merge({ user: { id: user_id } })
144
171
  end
145
172
  end
146
173
  end
@@ -4,9 +4,11 @@
4
4
  require 'open-uri'
5
5
  require 'faraday'
6
6
  require 'jwt'
7
+ require 'time'
7
8
  require 'stream-chat/channel'
8
9
  require 'stream-chat/errors'
9
10
  require 'stream-chat/version'
11
+ require 'stream-chat/util'
10
12
 
11
13
  module StreamChat
12
14
  DEFAULT_BLOCKLIST = 'profanity_en_2020_v1'
@@ -44,9 +46,10 @@ module StreamChat
44
46
  end
45
47
  end
46
48
 
47
- def create_token(user_id, exp = nil)
49
+ def create_token(user_id, exp = nil, iat = nil)
48
50
  payload = { user_id: user_id }
49
51
  payload['exp'] = exp unless exp.nil?
52
+ payload['iat'] = iat unless iat.nil?
50
53
  JWT.encode(payload, @api_secret, 'HS256')
51
54
  end
52
55
 
@@ -59,22 +62,29 @@ module StreamChat
59
62
  end
60
63
 
61
64
  def flag_message(id, **options)
62
- payload = { 'target_message_id': id }.merge(options)
65
+ payload = { target_message_id: id }.merge(options)
63
66
  post('moderation/flag', data: payload)
64
67
  end
65
68
 
66
69
  def unflag_message(id, **options)
67
- payload = { 'target_message_id': id }.merge(options)
70
+ payload = { target_message_id: id }.merge(options)
68
71
  post('moderation/unflag', data: payload)
69
72
  end
70
73
 
74
+ def query_message_flags(filter_conditions, **options)
75
+ params = options.merge({
76
+ filter_conditions: filter_conditions
77
+ })
78
+ get('moderation/flags/message', params: { payload: params.to_json })
79
+ end
80
+
71
81
  def flag_user(id, **options)
72
- payload = { 'target_user_id': id }.merge(options)
82
+ payload = { target_user_id: id }.merge(options)
73
83
  post('moderation/flag', data: payload)
74
84
  end
75
85
 
76
86
  def unflag_user(id, **options)
77
- payload = { 'target_user_id': id }.merge(options)
87
+ payload = { target_user_id: id }.merge(options)
78
88
  post('moderation/unflag', data: payload)
79
89
  end
80
90
 
@@ -84,11 +94,11 @@ module StreamChat
84
94
 
85
95
  def search(filter_conditions, query, **options)
86
96
  params = options.merge({
87
- "filter_conditions": filter_conditions,
88
- "query": query
97
+ filter_conditions: filter_conditions,
98
+ query: query
89
99
  })
90
100
 
91
- get('search', params: { "payload": params.to_json })
101
+ get('search', params: { payload: params.to_json })
92
102
  end
93
103
 
94
104
  def update_users(users)
@@ -99,7 +109,7 @@ module StreamChat
99
109
 
100
110
  payload[id] = user
101
111
  end
102
- post('users', data: { 'users': payload })
112
+ post('users', data: { users: payload })
103
113
  end
104
114
 
105
115
  def update_user(user)
@@ -107,7 +117,7 @@ module StreamChat
107
117
  end
108
118
 
109
119
  def update_users_partial(updates)
110
- patch('users', data: { 'users': updates })
120
+ patch('users', data: { users: updates })
111
121
  end
112
122
 
113
123
  def update_user_partial(update)
@@ -131,34 +141,34 @@ module StreamChat
131
141
  end
132
142
 
133
143
  def ban_user(target_id, **options)
134
- payload = { 'target_user_id': target_id }.merge(options)
144
+ payload = { target_user_id: target_id }.merge(options)
135
145
  post('moderation/ban', data: payload)
136
146
  end
137
147
 
138
148
  def unban_user(target_id, **options)
139
- params = { 'target_user_id': target_id }.merge(options)
149
+ params = { target_user_id: target_id }.merge(options)
140
150
  delete('moderation/ban', params: params)
141
151
  end
142
152
 
143
153
  def mute_user(target_id, user_id)
144
- payload = { 'target_id': target_id, 'user_id': user_id }
154
+ payload = { target_id: target_id, user_id: user_id }
145
155
  post('moderation/mute', data: payload)
146
156
  end
147
157
 
148
158
  def unmute_user(target_id, user_id)
149
- payload = { 'target_id': target_id, 'user_id': user_id }
159
+ payload = { target_id: target_id, user_id: user_id }
150
160
  post('moderation/unmute', data: payload)
151
161
  end
152
162
 
153
163
  def mark_all_read(user_id)
154
- payload = { 'user': { 'id': user_id } }
164
+ payload = { user: { id: user_id } }
155
165
  post('channels/read', data: payload)
156
166
  end
157
167
 
158
168
  def update_message(message)
159
169
  raise ArgumentError 'message must have an id' unless message.key? 'id'
160
170
 
161
- post("messages/#{message['id']}", data: { 'message': message })
171
+ post("messages/#{message['id']}", data: { message: message })
162
172
  end
163
173
 
164
174
  def delete_message(message_id)
@@ -166,28 +176,20 @@ module StreamChat
166
176
  end
167
177
 
168
178
  def query_users(filter_conditions, sort: nil, **options)
169
- sort_fields = []
170
- sort&.each do |k, v|
171
- sort_fields << { "field": k, "direction": v }
172
- end
173
179
  params = options.merge({
174
- "filter_conditions": filter_conditions,
175
- "sort": sort_fields
180
+ filter_conditions: filter_conditions,
181
+ sort: get_sort_fields(sort)
176
182
  })
177
- get('users', params: { "payload": params.to_json })
183
+ get('users', params: { payload: params.to_json })
178
184
  end
179
185
 
180
186
  def query_channels(filter_conditions, sort: nil, **options)
181
- params = { "state": true, "watch": false, "presence": false }
182
- sort_fields = []
183
- sort&.each do |k, v|
184
- sort_fields << { "field": k, "direction": v }
185
- end
186
- params = params.merge(options).merge({
187
- "filter_conditions": filter_conditions,
188
- "sort": sort_fields
189
- })
190
- get('channels', params: { "payload": params.to_json })
187
+ data = { state: true, watch: false, presence: false }
188
+ data = data.merge(options).merge({
189
+ filter_conditions: filter_conditions,
190
+ sort: get_sort_fields(sort)
191
+ })
192
+ post('channels', data: data)
191
193
  end
192
194
 
193
195
  def create_channel_type(data)
@@ -225,18 +227,29 @@ module StreamChat
225
227
 
226
228
  def add_device(device_id, push_provider, user_id)
227
229
  post('devices', data: {
228
- "id": device_id,
229
- "push_provider": push_provider,
230
- "user_id": user_id
230
+ id: device_id,
231
+ push_provider: push_provider,
232
+ user_id: user_id
231
233
  })
232
234
  end
233
235
 
234
236
  def delete_device(device_id, user_id)
235
- delete('devices', params: { "id": device_id, "user_id": user_id })
237
+ delete('devices', params: { id: device_id, user_id: user_id })
236
238
  end
237
239
 
238
240
  def get_devices(user_id)
239
- get('devices', params: { "user_id": user_id })
241
+ get('devices', params: { user_id: user_id })
242
+ end
243
+
244
+ def get_rate_limits(server_side: false, android: false, ios: false, web: false, endpoints: [])
245
+ params = {}
246
+ params['server_side'] = server_side if server_side
247
+ params['android'] = android if android
248
+ params['ios'] = ios if ios
249
+ params['web'] = web if web
250
+ params['endpoints'] = endpoints.join(',') unless endpoints.empty?
251
+
252
+ get('rate_limits', params: params)
240
253
  end
241
254
 
242
255
  def verify_webhook(request_body, x_signature)
@@ -253,11 +266,11 @@ module StreamChat
253
266
  end
254
267
 
255
268
  def create_blocklist(name, words)
256
- post('blocklists', data: { "name": name, "words": words })
269
+ post('blocklists', data: { name: name, words: words })
257
270
  end
258
271
 
259
272
  def update_blocklist(name, words)
260
- put("blocklists/#{name}", data: { "words": words })
273
+ put("blocklists/#{name}", data: { words: words })
261
274
  end
262
275
 
263
276
  def delete_blocklist(name)
@@ -265,13 +278,37 @@ module StreamChat
265
278
  end
266
279
 
267
280
  def export_channels(*channels)
268
- post('export_channels', data: { "channels": channels })
281
+ post('export_channels', data: { channels: channels })
269
282
  end
270
283
 
271
284
  def get_export_channel_status(task_id)
272
285
  get("export_channels/#{task_id}")
273
286
  end
274
287
 
288
+ def revoke_tokens(before)
289
+ before = before.rfc3339 if before.instance_of?(DateTime)
290
+ update_app_settings({ 'revoke_tokens_issued_before' => before })
291
+ end
292
+
293
+ def revoke_user_token(user_id, before)
294
+ revoke_users_token([user_id], before)
295
+ end
296
+
297
+ def revoke_users_token(user_ids, before)
298
+ before = before.rfc3339 if before.instance_of?(DateTime)
299
+
300
+ updates = []
301
+ user_ids.each do |user_id|
302
+ updates.push({
303
+ 'id' => user_id,
304
+ 'set' => {
305
+ 'revoke_tokens_issued_before' => before
306
+ }
307
+ })
308
+ end
309
+ update_users_partial(updates)
310
+ end
311
+
275
312
  def put(relative_url, params: nil, data: nil)
276
313
  make_http_request(:put, relative_url, params: params, data: data)
277
314
  end
@@ -312,7 +349,7 @@ module StreamChat
312
349
  end
313
350
 
314
351
  def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
315
- post('check_sqs', data: { "sqs_key": sqs_key, "sqs_secret": sqs_secret, "sqs_url": sqs_url })
352
+ post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
316
353
  end
317
354
 
318
355
  private
@@ -349,7 +386,7 @@ module StreamChat
349
386
  headers['stream-auth-type'] = 'jwt'
350
387
  url = [@base_url, relative_url].join('/')
351
388
  params = params.nil? ? {} : params
352
- params = Hash[get_default_params.merge(params).sort_by { |k, _v| k.to_s }]
389
+ params = (get_default_params.merge(params).sort_by { |k, _v| k.to_s }).to_h
353
390
  url = "#{url}?#{URI.encode_www_form(params)}"
354
391
 
355
392
  body = data.to_json if %w[patch post put].include? method.to_s
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/util.rb
4
+
5
+ def get_sort_fields(sort)
6
+ sort_fields = []
7
+ sort&.each do |k, v|
8
+ sort_fields << { field: k, direction: v }
9
+ end
10
+ sort_fields
11
+ end
@@ -3,5 +3,5 @@
3
3
  # lib/version.rb
4
4
 
5
5
  module StreamChat
6
- VERSION = '2.3.0'
6
+ VERSION = '2.9.0'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mircea Cosbuc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-05 00:00:00.000000000 Z
11
+ date: 2021-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -99,6 +99,7 @@ files:
99
99
  - lib/stream-chat/channel.rb
100
100
  - lib/stream-chat/client.rb
101
101
  - lib/stream-chat/errors.rb
102
+ - lib/stream-chat/util.rb
102
103
  - lib/stream-chat/version.rb
103
104
  - stream-chat.gemspec
104
105
  homepage: http://github.com/GetStream/stream-chat-ruby