stream-chat-ruby 2.20.0 → 2.22.1

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: 36870782d8439c010ce69c4593b2a9007b25ea0c18f748ea8bc809507378b2cd
4
- data.tar.gz: f5eeb52979560fa3be08059c71517dd5637ef317f78f9cf6ff27f2fabe8e3d61
3
+ metadata.gz: 0bfc513b8901c9efe810c00bb59d9aa23b3e12e0816af1896c31a54b69614053
4
+ data.tar.gz: ad8e9b4f3b2e4f1a4515226382e8fbf243acfdb46bbab93ba0c9a5c27d8208de
5
5
  SHA512:
6
- metadata.gz: cdffeaa2e783243ca32b098034b27c5175993d480dd34d78b7e6b2538e2c788fef8bbcf4c32357a2ab48e14edfcee056c4b3018a0f2cc4fb1e2a09a4b5c22fb3
7
- data.tar.gz: b2be01f9571c5ff952660fd046b35dd3fabe8920e3d3d58e50087253c74a57351ccee9b7fe5e0ccaa8fd154b64a20cd1046e6e4fd1662d1abbd1dc03ea1c5578
6
+ metadata.gz: 8189c936e8c1df17285a51e5410be20f1c6852f92f688a8b1292a971550399404848739772099cfd6e506c89fa5911063793ba46859d757160aa7fe000c8ed8d
7
+ data.tar.gz: 47de88506b215de1098ae643e7f08cd3636a71709470057a7d672849479f28351f66851e22508e31a59e888bb10b71cf1af99521f15884e1bf385f6b1b760d72
data/.rubocop.yml CHANGED
@@ -2,6 +2,9 @@ AllCops:
2
2
  DisabledByDefault: false
3
3
  NewCops: enable
4
4
  TargetRubyVersion: 2.5
5
+ Exclude:
6
+ - sorbet/**/*.rbi
7
+ - vendor/bundle/**/*
5
8
 
6
9
  Layout/LineLength:
7
10
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.22.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.0...v2.22.1) (2022-04-20)
6
+
7
+ ### Features
8
+
9
+ * added comments to public methods ([#93](https://github.com/GetStream/stream-chat-ruby/issues/93)) ([3843fe4](https://github.com/GetStream/stream-chat-ruby/commit/3843fe41ea7716d2b6a787d695bbe54981b2b35e))
10
+
11
+ ## [2.22.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.21.0...v2.22.0) (2022-04-01)
12
+
13
+
14
+ ### Features
15
+
16
+ * add new device field ([#90](https://github.com/GetStream/stream-chat-ruby/issues/90)) ([aa6723c](https://github.com/GetStream/stream-chat-ruby/commit/aa6723cd54e58aab0f1b8c55bc4e54211ab39f3c))
17
+ * add new moderation apis ([#88](https://github.com/GetStream/stream-chat-ruby/issues/88)) ([573c586](https://github.com/GetStream/stream-chat-ruby/commit/573c58650392eaa5a6d38b4423e170e30b3e98df))
18
+ * add push provider apis ([#89](https://github.com/GetStream/stream-chat-ruby/issues/89)) ([d592fba](https://github.com/GetStream/stream-chat-ruby/commit/d592fba4c0041102fa18d0fee11961f881414337))
19
+ * **update_user:** deprecate update in favor of upsert ([#91](https://github.com/GetStream/stream-chat-ruby/issues/91)) ([74d3163](https://github.com/GetStream/stream-chat-ruby/commit/74d316339b277b0f9cf0f94f40f11aae30fd7644))
20
+
21
+ ## [2.21.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.20.0...v2.21.0) (2022-03-03)
22
+
23
+
24
+ ### Features
25
+
26
+ * add options to delete message ([#80](https://github.com/GetStream/stream-chat-ruby/issues/80)) ([6a343e9](https://github.com/GetStream/stream-chat-ruby/commit/6a343e9fa9409150c27afc4246765f07bb12e571))
27
+ * add sorbet type checker ([#83](https://github.com/GetStream/stream-chat-ruby/issues/83)) ([f2fcee5](https://github.com/GetStream/stream-chat-ruby/commit/f2fcee58ecc0c3b4016721e997c42c44753bba9a))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * update app settings ([#86](https://github.com/GetStream/stream-chat-ruby/issues/86)) ([3f88185](https://github.com/GetStream/stream-chat-ruby/commit/3f88185117c5710e0b3e66f7f402f2c8969dec2f))
33
+
5
34
  ## [2.20.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.19.0...v2.20.0) (2022-02-04)
6
35
 
7
36
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,64 @@
1
+
2
+ # :recycle: Contributing
3
+
4
+ We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.
5
+
6
+ ## Getting started
7
+
8
+ ### Install dependencies
9
+
10
+ ```shell
11
+ $ bundle install --path vendor/bundle
12
+ ```
13
+
14
+ ### Run tests
15
+
16
+ ```shell
17
+ $ STREAM_KEY=my_api_key STREAM_SECRET=my_api_secret bundle exec rake spec
18
+ ```
19
+
20
+ ### Linters and type check
21
+
22
+ We use [Rubocop](https://github.com/rubocop/rubocop) for linting and [Sorbet](https://sorbet.org/) for type checking.
23
+
24
+ To run them:
25
+ ```shell
26
+ $ bundle exec rake rubocop
27
+ $ bundle exec srb tc
28
+ ```
29
+
30
+ These linters can be easily integrated into IDEs such as RubyMine or VS Code.
31
+
32
+ For VS Code, just install the basic Ruby extension which handles Rubocop ([`rebornix.ruby`](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby)) and the official Sorbet one ([`sorbet.sorbet-vscode-extension`](https://marketplace.visualstudio.com/items?itemName=sorbet.sorbet-vscode-extension)).
33
+
34
+ Recommended settings:
35
+ ```json
36
+ {
37
+ "editor.formatOnSave": true,
38
+ "ruby.useBundler": true,
39
+ "ruby.lint": {
40
+ "rubocop": {
41
+ "useBundler": true, // enable rubocop via bundler
42
+ }
43
+ },
44
+ "ruby.format": "rubocop",
45
+ "ruby.useLanguageServer": true,
46
+ "sorbet.enabled": true
47
+ }
48
+ ```
49
+
50
+ ### Commit message convention
51
+
52
+ This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.
53
+
54
+ ### Releasing a new version (for Stream developers)
55
+
56
+ In order to release new version you need to be a maintainer of the library.
57
+
58
+ - Kick off a job called `initiate_release` ([link](https://github.com/GetStream/stream-chat-ruby/actions/workflows/initiate_release.yml)).
59
+
60
+ The job creates a pull request with the changelog. Check if it looks good.
61
+
62
+ - Merge the pull request.
63
+
64
+ Once the PR is merged, it automatically kicks off another job which will upload the Gem to RubyGems.org and creates a GitHub release.
data/Gemfile CHANGED
@@ -9,9 +9,11 @@ group :dev do
9
9
  gem 'pry'
10
10
  gem 'pry-doc'
11
11
  gem 'rubocop', require: false
12
+ gem 'sorbet'
12
13
  end
13
14
 
14
15
  group :test do
15
16
  gem 'rack'
16
17
  gem 'simplecov'
18
+ gem 'simplecov-console'
17
19
  end
data/README.md CHANGED
@@ -1,57 +1,64 @@
1
- # stream-chat-ruby
1
+ # Official Ruby SDK for [Stream Chat](https://getstream.io/chat/)
2
2
 
3
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
- stream-chat-ruby is the official Ruby client for [Stream chat](https://getstream.io/chat/) a service for building chat applications.
5
+ <p align="center">
6
+ <img src="./assets/logo.svg" width="50%" height="50%">
7
+ </p>
8
+ <p align="center">
9
+ Official Ruby API client for Stream Chat, a service for building chat applications.
10
+ <br />
11
+ <a href="https://getstream.io/chat/docs/"><strong>Explore the docs »</strong></a>
12
+ <br />
13
+ <br />
14
+ <a href="https://github.com/GetStream/rails-chat-example">Code Samples</a>
15
+ ·
16
+ <a href="https://github.com/GetStream/stream-chat-ruby/issues">Report Bug</a>
17
+ ·
18
+ <a href="https://github.com/GetStream/stream-chat-ruby/issues">Request Feature</a>
19
+ </p>
6
20
 
7
- You can sign up for a Stream account at https://getstream.io/chat/get_started/.
21
+ ## 📝 About Stream
8
22
 
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
11
- Android SDK libraries (https://getstream.io/chat/).
23
+ You can sign up for a Stream account at our [Get Started](https://getstream.io/chat/get_started/) page.
12
24
 
13
- ### Installation
25
+ You can use this library to access chat API endpoints server-side.
14
26
 
15
- stream-chat-ruby supports:
27
+ For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries ([docs](https://getstream.io/chat/)).
16
28
 
17
- - Ruby (2.5, 2.6, 2.7, 3.0, 3.1)
29
+ ## ⚙️ Installation
30
+
31
+ [`stream-chat-ruby`](https://rubygems.org/gems/stream-chat-ruby) supports:
18
32
 
19
- #### Install
33
+ - Ruby (2.5, 2.6, 2.7, 3.0, 3.1)
20
34
 
21
35
  ```bash
22
- gem install stream-chat-ruby
36
+ $ gem install stream-chat-ruby
23
37
  ```
24
38
 
25
- ### Documentation
26
-
27
- [Official API docs](https://getstream.io/chat/docs/)
28
-
29
- ### Supported features
30
-
31
- - Chat channel type, channels and members
32
- - Messages
33
- - User management
34
- - Moderation API
35
- - Push configuration
36
- - User devices
37
- - User search
38
- - Channel search
39
- - Blocklists
40
- - Export channels
41
-
42
- ### Import
39
+ ## ✨ Getting started
43
40
 
44
41
  ```ruby
45
42
  require 'stream-chat'
46
- ```
47
43
 
48
- ### Initialize client
49
-
50
- ```ruby
51
44
  client = StreamChat::Client.new(api_key='STREAM_KEY', api_secret='STREAM_SECRET')
52
45
  ```
53
46
 
54
- ### Generate a token for client side use
47
+ > 💡 Note: since v2.21.0 we implemented [Sorbet](https://sorbet.org/) type checker. As of v2.x.x we only use it for static type checks and you won't notice any difference, but from v3.0.0 **we will enable runtime checks** 🚨 🚨 🚨.
48
+
49
+ > What this means, is that you'll receive an error during runtime if you pass an invalid type to our methods. To prepare for that, just make sure whatever you pass in, matches the method signature (`sig { ... }`).
50
+
51
+ ---
52
+
53
+ > Additionally, in a future major version, we would like to enforce symbol hash keys during runtime to conform to Ruby best practises. It's a good idea to prepare your application for that.
54
+ > ```ruby
55
+ > # Wrong:
56
+ > user = { "user" => { "id" => "bob-1"}}
57
+ > # Correct:
58
+ > user = { :user => { :id => "bob-1" }}
59
+ > ```
60
+
61
+ ### Generate a token for client-side usage:
55
62
 
56
63
  ```ruby
57
64
  client.create_token('bob-1')
@@ -60,93 +67,64 @@ client.create_token('bob-1')
60
67
  ### Create/Update users
61
68
 
62
69
  ```ruby
63
- client.update_user({
70
+ client.upsert_user({
64
71
  :id => 'bob-1',
65
72
  :role => 'admin',
66
73
  :name => 'Robert Tables'
67
74
  })
68
75
 
69
- # batch update is also supported
70
- jane = ...
71
- june = ...
72
- client.update_users([jane, june])
76
+ # Batch update is also supported
77
+ jane = {:id => 'jane-1'}
78
+ june = {:id => 'june-1'}
79
+ client.upsert_users([jane, june])
73
80
  ```
74
81
 
75
- ### Channel types CRUD
82
+ ### Channel types
76
83
 
77
84
  ```ruby
78
- # Create
79
85
  client.create_channel_type({
80
- 'name' => 'livechat',
81
- 'automod' => 'disabled',
82
- 'commands' => ['ban'],
83
- 'mutes' => true
86
+ :name => 'livechat',
87
+ :automod => 'disabled',
88
+ :commands => ['ban'],
89
+ :mutes => true
84
90
  })
85
91
 
86
- # Update
87
- client.update_channel_type('livechat', 'automod' => 'enabled'})
88
-
89
- # Get
90
- client.get_channel_type('livechat')
91
-
92
- # List
93
- client.list_channel_types
94
-
95
- # Delete
96
- client.delete_channel_type('livechat')
92
+ channel_types = client.list_channel_types()
97
93
  ```
98
94
 
99
95
  ### Channels
100
96
 
101
97
  ```ruby
102
98
  # Create a channel with members from the start
103
- chan = client.channel("messaging", channel_id: "bob-and-jane", data: {'members'=> ['bob-1', 'jane-77']})
99
+ chan = client.channel("messaging", channel_id: "bob-and-jane", data: {:members => ['bob-1', 'jane-77']})
104
100
  chan.create('bob-1')
105
101
 
106
102
  # Create a channel and then add members
107
103
  chan = client.channel("messaging", channel_id: "bob-and-jane")
108
104
  chan.create('bob-1')
109
105
  chan.add_members(['bob-1', 'jane-77'])
106
+ ```
110
107
 
111
- # Send messages
112
- m1 = chan.send_message({'text' => 'Hi Jane!'}, 'bob-1')
113
- m2 = chan.send_message({'text' => 'Hi Bob'}, 'jane-77')
114
-
115
- # Send replies
116
- r1 = chan.send_message({'text' => 'And a good day!', 'parent_id' => m1['id']}, 'bob-1')
117
-
118
- # Send reactions
119
- chan.send_reaction(m1['id'], {'type' => 'like'}, 'bob-1')
108
+ ### Reactions
109
+ ```ruby
110
+ chan.send_reaction(m1['id'], {:type => 'like'}, 'bob-1')
111
+ ```
120
112
 
121
- # Add/remove moderators
113
+ ### Moderation
114
+ ```ruby
122
115
  chan.add_moderators(['jane-77'])
123
116
  chan.demote_moderators(['bob-1'])
124
117
 
125
- # Add a ban with a timeout
126
118
  chan.ban_user('bob-1', timeout: 30)
127
119
 
128
- # Remove a ban
129
120
  chan.unban_user('bob-1')
130
-
131
- # Query channel state
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)
144
121
  ```
145
122
 
146
123
  ### Messages
147
124
 
148
125
  ```ruby
149
- # Delete a message from any channel by ID
126
+ m1 = chan.send_message({:text => 'Hi Jane!'}, 'bob-1')
127
+
150
128
  deleted_message = client.delete_message(r1['id'])
151
129
 
152
130
  ```
@@ -154,29 +132,23 @@ deleted_message = client.delete_message(r1['id'])
154
132
  ### Devices
155
133
 
156
134
  ```ruby
157
- # Add device
158
- jane_phone = client.add_device({'id' => 'iOS Device Token', 'push_provider' => push_provider.apn, 'user_id' => 'jane-77'})
135
+ jane_phone = client.add_device({:id => 'iOS Device Token', :push_provider => push_provider.apn, :user_id => 'jane-77'})
159
136
 
160
- # List devices
161
137
  client.get_devices('jane-77')
162
138
 
163
- # Remove device
164
139
  client.remove_device(jane_phone['id'], jane_phone['user_id'])
165
140
  ```
166
141
 
167
142
  ### Blocklists
168
143
 
169
144
  ```ruby
170
- # Create a blocklist
171
145
  client.create_blocklist('my_blocker', %w[fudge cream sugar])
172
146
 
173
- # Enable it on messaging channel type
147
+ # Enable it on 'messaging' channel type
174
148
  client.update_channel_type('messaging', blocklist: 'my_blocker', blocklist_behavior: 'block')
175
149
 
176
- # Get the details of the blocklist
177
150
  client.get_blocklist('my_blocker')
178
151
 
179
- # Delete the blocklist
180
152
  client.delete_blocklist('my_blocker')
181
153
  ```
182
154
 
@@ -184,7 +156,7 @@ client.delete_blocklist('my_blocker')
184
156
 
185
157
  ```ruby
186
158
  # Register an export
187
- response = client.export_channels({type: 'messaging', id: 'jane'})
159
+ response = client.export_channels({:type => 'messaging', :id => 'jane'})
188
160
 
189
161
  # Check completion
190
162
  status_response = client.get_export_channel_status(response['task_id'])
@@ -204,33 +176,13 @@ limits = client.get_rate_limits(server_side: true)
204
176
  limits = client.get_rate_limits(android: true, ios: true, endpoints: ['QueryChannels', 'SendMessage'])
205
177
  ```
206
178
 
207
- ### Example Rails application
208
-
209
- See [an example rails application using the Ruby SDK](https://github.com/GetStream/rails-chat-example).
210
-
211
- ### Contributing
212
-
213
- First, make sure you can run the test suite. Tests are run via rspec
214
-
215
- ```bash
216
- STREAM_KEY=my_api_key STREAM_SECRET=my_api_secret bundle exec rake spec
217
- ```
218
-
219
- This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.
220
-
221
- ### Releasing a new version
222
-
223
- In order to release new version you need to be a maintainer of the library.
224
-
225
- - Kick off a job called `initiate_release` ([link](https://github.com/GetStream/stream-chat-ruby/actions/workflows/initiate_release.yml)).
226
-
227
- The job creates a pull request with the changelog. Check if it looks good.
179
+ ## ✍️ Contributing
228
180
 
229
- - Merge the pull request.
181
+ We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our [license file](./LICENSE) for more details.
230
182
 
231
- Once the PR is merged, it automatically kicks off another job which will upload the Gem to RubyGems.org and creates a GitHub release.
183
+ Head over to [CONTRIBUTING.md](./CONTRIBUTING.md) for some development tips.
232
184
 
233
- ## We are hiring!
185
+ ## 🧑‍💻 We are hiring!
234
186
 
235
187
  We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
236
188
  Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.