stream-chat-ruby 2.19.0 → 2.22.0
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/.rubocop.yml +3 -0
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +64 -0
- data/Gemfile +1 -0
- data/README.md +69 -117
- data/lib/stream-chat/channel.rb +78 -15
- data/lib/stream-chat/client.rb +178 -30
- data/lib/stream-chat/errors.rb +22 -9
- data/lib/stream-chat/stream_rate_limits.rb +16 -5
- data/lib/stream-chat/stream_response.rb +21 -8
- data/lib/stream-chat/types.rb +13 -0
- data/lib/stream-chat/util.rb +16 -6
- data/lib/stream-chat/version.rb +2 -3
- data/lib/stream-chat.rb +2 -1
- data/stream-chat.gemspec +2 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0493f781c7cda5a16174cd56949d41ebf9234a9903d94dfcaf8826e90778d1c4'
|
4
|
+
data.tar.gz: 0b81431fb6fce8e3d230ad0838d5b666696c1368ec00c7417f37789218d20847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2cb64ead68735919747ca939dbd4185440d44a5f52164524d874ec98765a37207b3126a63afa30a6de0eb3faadac0f93561c4ecd246add31eb69e6bab6add52
|
7
|
+
data.tar.gz: f6bdf47417e6ed4af0d2a0ed2eb9c775bdb7a4ea5bff3b89bff69c7b702edf892d4009e8e521e067c3a65eb9251e3728e76cbbf9f72e6a90e169907920e65bc0
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,36 @@
|
|
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.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.21.0...v2.22.0) (2022-04-01)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* add new device field ([#90](https://github.com/GetStream/stream-chat-ruby/issues/90)) ([aa6723c](https://github.com/GetStream/stream-chat-ruby/commit/aa6723cd54e58aab0f1b8c55bc4e54211ab39f3c))
|
11
|
+
* add new moderation apis ([#88](https://github.com/GetStream/stream-chat-ruby/issues/88)) ([573c586](https://github.com/GetStream/stream-chat-ruby/commit/573c58650392eaa5a6d38b4423e170e30b3e98df))
|
12
|
+
* add push provider apis ([#89](https://github.com/GetStream/stream-chat-ruby/issues/89)) ([d592fba](https://github.com/GetStream/stream-chat-ruby/commit/d592fba4c0041102fa18d0fee11961f881414337))
|
13
|
+
* **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))
|
14
|
+
|
15
|
+
## [2.21.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.20.0...v2.21.0) (2022-03-03)
|
16
|
+
|
17
|
+
|
18
|
+
### Features
|
19
|
+
|
20
|
+
* 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))
|
21
|
+
* add sorbet type checker ([#83](https://github.com/GetStream/stream-chat-ruby/issues/83)) ([f2fcee5](https://github.com/GetStream/stream-chat-ruby/commit/f2fcee58ecc0c3b4016721e997c42c44753bba9a))
|
22
|
+
|
23
|
+
|
24
|
+
### Bug Fixes
|
25
|
+
|
26
|
+
* update app settings ([#86](https://github.com/GetStream/stream-chat-ruby/issues/86)) ([3f88185](https://github.com/GetStream/stream-chat-ruby/commit/3f88185117c5710e0b3e66f7f402f2c8969dec2f))
|
27
|
+
|
28
|
+
## [2.20.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.19.0...v2.20.0) (2022-02-04)
|
29
|
+
|
30
|
+
|
31
|
+
### Features
|
32
|
+
|
33
|
+
* add helper for invitation acceptance and rejection ([#78](https://github.com/GetStream/stream-chat-ruby/issues/78)) ([c950694](https://github.com/GetStream/stream-chat-ruby/commit/c950694a0ac2b0906d7bedb4ebc9a1af00eea606))
|
34
|
+
|
5
35
|
## [2.19.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.18.0...v2.19.0) (2022-02-02)
|
6
36
|
|
7
37
|
|
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
data/README.md
CHANGED
@@ -1,57 +1,64 @@
|
|
1
|
-
#
|
1
|
+
# Official Ruby SDK for [Stream Chat](https://getstream.io/chat/)
|
2
2
|
|
3
3
|
[](https://github.com/GetStream/stream-chat-ruby/actions) [](http://badge.fury.io/rb/stream-chat-ruby)
|
4
4
|
|
5
|
-
|
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
|
-
|
21
|
+
## 📝 About Stream
|
8
22
|
|
9
|
-
You can
|
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
|
-
|
25
|
+
You can use this library to access chat API endpoints server-side.
|
14
26
|
|
15
|
-
|
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
|
-
|
29
|
+
## ⚙️ Installation
|
30
|
+
|
31
|
+
[`stream-chat-ruby`](https://rubygems.org/gems/stream-chat-ruby) supports:
|
18
32
|
|
19
|
-
|
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
|
-
|
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
|
-
|
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.
|
70
|
+
client.upsert_user({
|
64
71
|
:id => 'bob-1',
|
65
72
|
:role => 'admin',
|
66
73
|
:name => 'Robert Tables'
|
67
74
|
})
|
68
75
|
|
69
|
-
#
|
70
|
-
jane =
|
71
|
-
june =
|
72
|
-
client.
|
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
|
82
|
+
### Channel types
|
76
83
|
|
77
84
|
```ruby
|
78
|
-
# Create
|
79
85
|
client.create_channel_type({
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
:name => 'livechat',
|
87
|
+
:automod => 'disabled',
|
88
|
+
:commands => ['ban'],
|
89
|
+
:mutes => true
|
84
90
|
})
|
85
91
|
|
86
|
-
|
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: {
|
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
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|