stream-chat-ruby 2.22.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +2 -0
- data/lib/stream-chat/channel.rb +0 -4
- data/lib/stream-chat/client.rb +125 -13
- data/lib/stream-chat/errors.rb +0 -4
- data/lib/stream-chat/stream_rate_limits.rb +0 -4
- data/lib/stream-chat/stream_response.rb +0 -4
- data/lib/stream-chat/types.rb +0 -4
- data/lib/stream-chat/util.rb +0 -4
- data/lib/stream-chat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf7346fa100815ad5e6ded38ee11d3941ce5b8ef33e180ab39f0ce7d5edf1321
|
4
|
+
data.tar.gz: 1d4276d85a538fa0e3aa46b8836383e9a674b5701350ea834acfbed87406d07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebcd5bcf54929c7d7c93194c447f511b0e1a341fbae359ba06d8757e3e3b8097ef468da0d0bc9f0ea401fcd2c95a051c3acdab5797c864b5298387c87d0e7f4a
|
7
|
+
data.tar.gz: 12730b06d2997b07b91bef7f9e19f7c40b3d059b3b5b97e490190f80a1837650189190a121fa891a63145cf783262d9cf7b41d51846f05dae3a7ee0238803a05
|
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
|
+
## [3.0.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.23.0...v3.0.0) (2022-05-24)
|
6
|
+
|
7
|
+
|
8
|
+
### ⚠ BREAKING CHANGES
|
9
|
+
|
10
|
+
* **sorbet:** enable runtime typecheck (#104)
|
11
|
+
|
12
|
+
> In this release we have enabled runtime level typechecking for Sorbet. This means that if you input parameters
|
13
|
+
are invalid **your code will throw an error during runtime**. Please ensure that your code is properly tested
|
14
|
+
before continuing with v3.0.0 of this library.
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
* **sorbet:** enable runtime typecheck ([#104](https://github.com/GetStream/stream-chat-ruby/issues/104)) ([97d5f29](https://github.com/GetStream/stream-chat-ruby/commit/97d5f299b652e8328af6e76d0d605c59f05a5cc3))
|
19
|
+
|
20
|
+
## [2.23.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.2...v2.23.0) (2022-05-19)
|
21
|
+
|
22
|
+
|
23
|
+
### Features
|
24
|
+
|
25
|
+
* **campaign:** add campaign endpoints ([c8c698b](https://github.com/GetStream/stream-chat-ruby/commit/c8c698b51ee2c9f54819c2b9407a3fff7808efd5))
|
26
|
+
* **import:** add import endpoints ([#102](https://github.com/GetStream/stream-chat-ruby/issues/102)) ([4d7358d](https://github.com/GetStream/stream-chat-ruby/commit/4d7358d39615c5346f9fdcb2b0dfbffa3c2ae79c))
|
27
|
+
|
28
|
+
### [2.22.2](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.1...v2.22.2) (2022-04-21)
|
29
|
+
|
30
|
+
|
31
|
+
### Bug Fixes
|
32
|
+
|
33
|
+
* **sorbet:** turn off runtime checks properly ([#98](https://github.com/GetStream/stream-chat-ruby/issues/98)) ([29e9e73](https://github.com/GetStream/stream-chat-ruby/commit/29e9e73ac07d163e8c1ca7b24516cb7ac61e93cd))
|
34
|
+
|
5
35
|
### [2.22.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.22.0...v2.22.1) (2022-04-20)
|
6
36
|
|
7
37
|
### Features
|
data/README.md
CHANGED
@@ -47,6 +47,8 @@ client = StreamChat::Client.new(api_key='STREAM_KEY', api_secret='STREAM_SECRET'
|
|
47
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
48
|
|
49
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
|
+
> **Update (2022-May-24)**: we have relased [v3.0.0](https://github.com/GetStream/stream-chat-ruby/releases/tag/v3.0.0) with enabled runtime checks.
|
50
52
|
|
51
53
|
---
|
52
54
|
|
data/lib/stream-chat/channel.rb
CHANGED
@@ -9,10 +9,6 @@ require 'stream-chat/types'
|
|
9
9
|
module StreamChat
|
10
10
|
class Channel
|
11
11
|
extend T::Sig
|
12
|
-
T::Configuration.default_checked_level = :never
|
13
|
-
# For now we disable runtime type checks.
|
14
|
-
# We will enable it with a major bump in the future,
|
15
|
-
# but for now, let's just run a static type check.
|
16
12
|
|
17
13
|
sig { returns(T.nilable(String)) }
|
18
14
|
attr_reader :id
|
data/lib/stream-chat/client.rb
CHANGED
@@ -22,10 +22,6 @@ module StreamChat
|
|
22
22
|
|
23
23
|
class Client
|
24
24
|
extend T::Sig
|
25
|
-
T::Configuration.default_checked_level = :never
|
26
|
-
# For now we disable runtime type checks.
|
27
|
-
# We will enable it with a major bump in the future,
|
28
|
-
# but for now, let's just run a static type check.
|
29
25
|
|
30
26
|
DEFAULT_BASE_URL = 'https://chat.stream-io-api.com'
|
31
27
|
DEFAULT_TIMEOUT = 6.0
|
@@ -76,10 +72,10 @@ module StreamChat
|
|
76
72
|
# @param [StringKeyHash] options extra options
|
77
73
|
sig { params(options: T.untyped).returns(Client) }
|
78
74
|
def self.from_env(**options)
|
79
|
-
Client.new(
|
80
|
-
|
81
|
-
ENV
|
82
|
-
**{ base_url: ENV
|
75
|
+
Client.new(ENV.fetch('STREAM_KEY'),
|
76
|
+
ENV.fetch('STREAM_SECRET'),
|
77
|
+
ENV.fetch('STREAM_CHAT_TIMEOUT', DEFAULT_TIMEOUT),
|
78
|
+
**{ base_url: ENV.fetch('STREAM_CHAT_URL', DEFAULT_BASE_URL) }.merge(options))
|
83
79
|
end
|
84
80
|
|
85
81
|
# Sets the underlying Faraday http client.
|
@@ -207,14 +203,14 @@ module StreamChat
|
|
207
203
|
get('search', params: { payload: options.merge(to_merge).to_json })
|
208
204
|
end
|
209
205
|
|
210
|
-
#
|
206
|
+
# @deprecated Use {#upsert_users} instead.
|
211
207
|
sig { params(users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
212
208
|
def update_users(users)
|
213
209
|
warn '[DEPRECATION] `update_users` is deprecated. Please use `upsert_users` instead.'
|
214
210
|
upsert_users(users)
|
215
211
|
end
|
216
212
|
|
217
|
-
#
|
213
|
+
# @deprecated Use {#upsert_user} instead.
|
218
214
|
sig { params(user: StringKeyHash).returns(StreamChat::StreamResponse) }
|
219
215
|
def update_user(user)
|
220
216
|
warn '[DEPRECATION] `update_user` is deprecated. Please use `upsert_user` instead.'
|
@@ -583,7 +579,7 @@ module StreamChat
|
|
583
579
|
# of the most common profane words.
|
584
580
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
585
581
|
# blocklists and configure your channel types to use them.
|
586
|
-
sig { params(name: String, words:
|
582
|
+
sig { params(name: String, words: T::Array[String]).returns(StreamChat::StreamResponse) }
|
587
583
|
def create_blocklist(name, words)
|
588
584
|
post('blocklists', data: { name: name, words: words })
|
589
585
|
end
|
@@ -595,7 +591,7 @@ module StreamChat
|
|
595
591
|
# of the most common profane words.
|
596
592
|
# You can manage your own block lists via the Stream dashboard or APIs to a manage
|
597
593
|
# blocklists and configure your channel types to use them.
|
598
|
-
sig { params(name: String, words:
|
594
|
+
sig { params(name: String, words: T::Array[String]).returns(StreamChat::StreamResponse) }
|
599
595
|
def update_blocklist(name, words)
|
600
596
|
put("blocklists/#{name}", data: { words: words })
|
601
597
|
end
|
@@ -635,7 +631,7 @@ module StreamChat
|
|
635
631
|
end
|
636
632
|
|
637
633
|
# Delete users asynchronously. Use `get_task` to check the status of the task.
|
638
|
-
sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(
|
634
|
+
sig { params(user_ids: T::Array[String], user: String, messages: T.nilable(String), conversations: T.nilable(String)).returns(StreamChat::StreamResponse) }
|
639
635
|
def delete_users(user_ids, user: SOFT_DELETE, messages: nil, conversations: nil)
|
640
636
|
post('users/delete', data: { user_ids: user_ids, user: user, messages: messages, conversations: conversations })
|
641
637
|
end
|
@@ -835,6 +831,122 @@ module StreamChat
|
|
835
831
|
get('push_providers')
|
836
832
|
end
|
837
833
|
|
834
|
+
# Creates a signed URL for imports.
|
835
|
+
# @example
|
836
|
+
# url_resp = client.create_import_url('myfile.json')
|
837
|
+
# Faraday.put(url_resp['upload_url'], File.read('myfile.json'), 'Content-Type' => 'application/json')
|
838
|
+
# client.create_import(url_resp['path'], 'upsert')
|
839
|
+
sig { params(filename: String).returns(StreamChat::StreamResponse) }
|
840
|
+
def create_import_url(filename)
|
841
|
+
post('import_urls', data: { filename: filename })
|
842
|
+
end
|
843
|
+
|
844
|
+
# Creates a new import.
|
845
|
+
# @example
|
846
|
+
# url_resp = client.create_import_url('myfile.json')
|
847
|
+
# Faraday.put(url_resp['upload_url'], File.read('myfile.json'), 'Content-Type' => 'application/json')
|
848
|
+
# client.create_import(url_resp['path'], 'upsert')
|
849
|
+
sig { params(path: String, mode: String).returns(StreamChat::StreamResponse) }
|
850
|
+
def create_import(path, mode)
|
851
|
+
post('imports', data: { path: path, mode: mode })
|
852
|
+
end
|
853
|
+
|
854
|
+
# Returns an import by id.
|
855
|
+
sig { params(id: String).returns(StreamChat::StreamResponse) }
|
856
|
+
def get_import(id)
|
857
|
+
get("imports/#{id}")
|
858
|
+
end
|
859
|
+
|
860
|
+
# Lists imports. Options dictionary can contain 'offset' and 'limit' keys for pagination.
|
861
|
+
sig { params(options: T.untyped).returns(StreamChat::StreamResponse) }
|
862
|
+
def list_imports(options)
|
863
|
+
get('imports', params: options)
|
864
|
+
end
|
865
|
+
|
866
|
+
# Creates a campaign.
|
867
|
+
sig { params(campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
|
868
|
+
def create_campaign(campaign)
|
869
|
+
post('campaigns', data: { campaign: campaign })
|
870
|
+
end
|
871
|
+
|
872
|
+
# Gets a campaign.
|
873
|
+
sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
|
874
|
+
def get_campaign(campaign_id)
|
875
|
+
get("campaigns/#{campaign_id}")
|
876
|
+
end
|
877
|
+
|
878
|
+
# Lists all campaigns. Options dictionary can contain 'offset' and 'limit' keys for pagination.
|
879
|
+
sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
|
880
|
+
def list_campaigns(options)
|
881
|
+
get('campaigns', params: options)
|
882
|
+
end
|
883
|
+
|
884
|
+
# Updates a campaign.
|
885
|
+
sig { params(campaign_id: String, campaign: StringKeyHash).returns(StreamChat::StreamResponse) }
|
886
|
+
def update_campaign(campaign_id, campaign)
|
887
|
+
put("campaigns/#{campaign_id}", data: { campaign: campaign })
|
888
|
+
end
|
889
|
+
|
890
|
+
# Deletes a campaign.
|
891
|
+
sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
|
892
|
+
def delete_campaign(campaign_id)
|
893
|
+
delete("campaigns/#{campaign_id}")
|
894
|
+
end
|
895
|
+
|
896
|
+
# Schedules a campaign.
|
897
|
+
sig { params(campaign_id: String, send_at: Integer).returns(StreamChat::StreamResponse) }
|
898
|
+
def schedule_campaign(campaign_id, send_at)
|
899
|
+
patch("campaigns/#{campaign_id}/schedule", data: { send_at: send_at })
|
900
|
+
end
|
901
|
+
|
902
|
+
# Stops a campaign.
|
903
|
+
sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
|
904
|
+
def stop_campaign(campaign_id)
|
905
|
+
patch("campaigns/#{campaign_id}/stop")
|
906
|
+
end
|
907
|
+
|
908
|
+
# Resumes a campaign.
|
909
|
+
sig { params(campaign_id: String).returns(StreamChat::StreamResponse) }
|
910
|
+
def resume_campaign(campaign_id)
|
911
|
+
patch("campaigns/#{campaign_id}/resume")
|
912
|
+
end
|
913
|
+
|
914
|
+
# Tests a campaign.
|
915
|
+
sig { params(campaign_id: String, users: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) }
|
916
|
+
def test_campaign(campaign_id, users)
|
917
|
+
post("campaigns/#{campaign_id}/test", data: { users: users })
|
918
|
+
end
|
919
|
+
|
920
|
+
# Creates a campaign segment.
|
921
|
+
sig { params(segment: StringKeyHash).returns(StreamChat::StreamResponse) }
|
922
|
+
def create_segment(segment)
|
923
|
+
post('segments', data: { segment: segment })
|
924
|
+
end
|
925
|
+
|
926
|
+
# Gets a campaign segment.
|
927
|
+
sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
|
928
|
+
def get_segment(segment_id)
|
929
|
+
get("segments/#{segment_id}")
|
930
|
+
end
|
931
|
+
|
932
|
+
# Lists all campaign segments. Options dictionary can contain 'offset' and 'limit' keys for pagination.
|
933
|
+
sig { params(options: StringKeyHash).returns(StreamChat::StreamResponse) }
|
934
|
+
def list_segments(options)
|
935
|
+
get('segments', params: options)
|
936
|
+
end
|
937
|
+
|
938
|
+
# Updates a campaign segment.
|
939
|
+
sig { params(segment_id: String, segment: StringKeyHash).returns(StreamChat::StreamResponse) }
|
940
|
+
def update_segment(segment_id, segment)
|
941
|
+
put("segments/#{segment_id}", data: { segment: segment })
|
942
|
+
end
|
943
|
+
|
944
|
+
# Deletes a campaign segment.
|
945
|
+
sig { params(segment_id: String).returns(StreamChat::StreamResponse) }
|
946
|
+
def delete_segment(segment_id)
|
947
|
+
delete("segments/#{segment_id}")
|
948
|
+
end
|
949
|
+
|
838
950
|
private
|
839
951
|
|
840
952
|
sig { returns(T::Hash[String, String]) }
|
data/lib/stream-chat/errors.rb
CHANGED
@@ -4,10 +4,6 @@
|
|
4
4
|
module StreamChat
|
5
5
|
class StreamAPIException < StandardError
|
6
6
|
extend T::Sig
|
7
|
-
T::Configuration.default_checked_level = :never
|
8
|
-
# For now we disable runtime type checks.
|
9
|
-
# We will enable it with a major bump in the future,
|
10
|
-
# but for now, let's just run a static type check.
|
11
7
|
|
12
8
|
sig { returns(Integer) }
|
13
9
|
attr_reader :error_code
|
@@ -4,10 +4,6 @@
|
|
4
4
|
module StreamChat
|
5
5
|
class StreamRateLimits
|
6
6
|
extend T::Sig
|
7
|
-
T::Configuration.default_checked_level = :never
|
8
|
-
# For now we disable runtime type checks.
|
9
|
-
# We will enable it with a major bump in the future,
|
10
|
-
# but for now, let's just run a static type check.
|
11
7
|
|
12
8
|
sig { returns(Integer) }
|
13
9
|
attr_reader :limit
|
@@ -7,10 +7,6 @@ require 'stream-chat/types'
|
|
7
7
|
module StreamChat
|
8
8
|
class StreamResponse < Hash
|
9
9
|
extend T::Sig
|
10
|
-
T::Configuration.default_checked_level = :never
|
11
|
-
# For now we disable runtime type checks.
|
12
|
-
# We will enable it with a major bump in the future,
|
13
|
-
# but for now, let's just run a static type check.
|
14
10
|
|
15
11
|
sig { returns(StreamRateLimits) }
|
16
12
|
attr_reader :rate_limit
|
data/lib/stream-chat/types.rb
CHANGED
@@ -3,10 +3,6 @@
|
|
3
3
|
|
4
4
|
module StreamChat
|
5
5
|
extend T::Sig
|
6
|
-
T::Configuration.default_checked_level = :never
|
7
|
-
# For now we disable runtime type checks.
|
8
|
-
# We will enable it with a major bump in the future,
|
9
|
-
# but for now, let's just run a static type check.
|
10
6
|
|
11
7
|
StringKeyHash = T.type_alias { T::Hash[T.any(String, Symbol), T.untyped] }
|
12
8
|
SortArray = T.type_alias { T::Array[{ field: String, direction: Integer }] }
|
data/lib/stream-chat/util.rb
CHANGED
@@ -5,10 +5,6 @@ require 'stream-chat/types'
|
|
5
5
|
|
6
6
|
module StreamChat
|
7
7
|
extend T::Sig
|
8
|
-
T::Configuration.default_checked_level = :never
|
9
|
-
# For now we disable runtime type checks.
|
10
|
-
# We will enable it with a major bump in the future,
|
11
|
-
# but for now, let's just run a static type check.
|
12
8
|
|
13
9
|
sig { params(sort: T.nilable(T::Hash[String, Integer])).returns(SortArray) }
|
14
10
|
def self.get_sort_fields(sort)
|
data/lib/stream-chat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stream-chat-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- getstream.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|