stream-chat-ruby 3.2.0 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a528ef5495dbf3fc9d123e554151ee6654ef3ddf04499f89e6c093fce8f2e93
4
- data.tar.gz: 5b08570a5dbfbbfdc73c356d93861f9fad95f81cf2578ef9caea24947deb9c34
3
+ metadata.gz: 73e40b4cf714cd04476c91ac638895cab0327dc618fb54031a83aaadc8b3279a
4
+ data.tar.gz: b5c98b143f98798cb2cd9db4e5a3c2c8c4cc7aaf9e35aa55a392c371d06fc970
5
5
  SHA512:
6
- metadata.gz: 3f5e0d125c1b9a95395daea29a8694ca96d74939193f5eb035c8e1b0af840c91f457beaa4eca4dec6485fecfe2e9fd7a57f0f1c3ea34ee4f829027a77145cd59
7
- data.tar.gz: 6548249f3cd5ddbb2051c84a546c94f6277571075c84c4cbcb38d359c0970ceb9d45df3158c59c2dcd160dec44508ad108371343bd6ad5c3a3b931b9a4399d6f
6
+ metadata.gz: 74e06fd1205667b6c0a6f2d745f197aac2639ca5d932dee52bea8f2a4e371d9fc7d4ed8c2663010b47a1b1af0d7dd644f3bdf16b26f0048ed2fad6d8a5c18859
7
+ data.tar.gz: a91d9ec87dfb82fb7a393212a08641bd4b8164ccd38ef0259fbcb27d4824dc3a4b0330b973b6d46315ab77cf17c357dd48961cf37ac3ccf1748310e3fb6bfb8f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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.3.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.2.0...v3.3.0) (2022-11-17)
6
+
7
+
8
+ ### Features
9
+
10
+ * add campaign support ([#124](https://github.com/GetStream/stream-chat-ruby/issues/124)) ([d7a935f](https://github.com/GetStream/stream-chat-ruby/commit/d7a935f7b4459399b82db1d51a541388caeb5e68))
11
+
5
12
  ## [3.2.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.1.0...v3.2.0) (2022-11-17)
6
13
 
7
14
 
data/README.md CHANGED
@@ -57,7 +57,7 @@ client = StreamChat::Client.new('STREAM_KEY', 'STREAM_SECRET')
57
57
  > # Wrong:
58
58
  > user = { "user" => { "id" => "bob-1"}}
59
59
  > # Correct:
60
- > user = { :user => { :id => "bob-1" }}
60
+ > user = { user: { id: "bob-1" }}
61
61
  > ```
62
62
 
63
63
  ### Generate a token for client-side usage:
@@ -70,14 +70,14 @@ client.create_token('bob-1')
70
70
 
71
71
  ```ruby
72
72
  client.upsert_user({
73
- :id => 'bob-1',
74
- :role => 'admin',
75
- :name => 'Robert Tables'
73
+ id: 'bob-1',
74
+ role: 'admin',
75
+ name: 'Robert Tables'
76
76
  })
77
77
 
78
78
  # Batch update is also supported
79
- jane = {:id => 'jane-1'}
80
- june = {:id => 'june-1'}
79
+ jane = {id: 'jane-1'}
80
+ june = {id: 'june-1'}
81
81
  client.upsert_users([jane, june])
82
82
  ```
83
83
 
@@ -85,10 +85,10 @@ client.upsert_users([jane, june])
85
85
 
86
86
  ```ruby
87
87
  client.create_channel_type({
88
- :name => 'livechat',
89
- :automod => 'disabled',
90
- :commands => ['ban'],
91
- :mutes => true
88
+ name: 'livechat',
89
+ automod: 'disabled',
90
+ commands: ['ban'],
91
+ mutes: true
92
92
  })
93
93
 
94
94
  channel_types = client.list_channel_types()
@@ -109,7 +109,7 @@ chan.add_members(['bob-1', 'jane-77'])
109
109
 
110
110
  ### Reactions
111
111
  ```ruby
112
- chan.send_reaction(m1['id'], {:type => 'like'}, 'bob-1')
112
+ chan.send_reaction(m1['id'], {type: 'like'}, 'bob-1')
113
113
  ```
114
114
 
115
115
  ### Moderation
@@ -125,7 +125,7 @@ chan.unban_user('bob-1')
125
125
  ### Messages
126
126
 
127
127
  ```ruby
128
- m1 = chan.send_message({:text => 'Hi Jane!'}, 'bob-1')
128
+ m1 = chan.send_message({text: 'Hi Jane!'}, 'bob-1')
129
129
 
130
130
  deleted_message = client.delete_message(m1['message']['id'])
131
131
 
@@ -158,13 +158,39 @@ client.delete_blocklist('my_blocker')
158
158
 
159
159
  ```ruby
160
160
  # Register an export
161
- response = client.export_channels({:type => 'messaging', :id => 'jane'})
161
+ response = client.export_channels({type: 'messaging', id: 'jane'})
162
162
 
163
163
  # Check completion
164
164
  status_response = client.get_export_channel_status(response['task_id'])
165
165
  # status_response['status'] == 'pending', 'completed'
166
166
  ```
167
167
 
168
+ ### Campaigns
169
+
170
+ ```ruby
171
+ # Create a user or channel segment
172
+ client.create_segment({ name: 'test', type: 'user', filter: { uniq: 'a flag on users' } })
173
+
174
+ # Create a campaign that uses the segment
175
+ client.create_campaign({
176
+ name: 'test',
177
+ text: 'Hi',
178
+ sender_id: campaign_sender,
179
+ segment_id: segment_id,
180
+ channel_type: 'messaging'
181
+ })
182
+
183
+ # Schedule the campaign
184
+ client.schedule_campaign(campaign_id, Time.now.to_i)
185
+
186
+ # Query the campaign to check the status
187
+ response = client.query_campaigns(filter_conditions: { id: campaign_id })
188
+ response['campaigns'][0]['status'] == 'completed'
189
+
190
+ # Read sent information
191
+ client.query_recipients(filter_conditions: { campaign_id: campaign_id })
192
+ ```
193
+
168
194
  ### Rate limits
169
195
 
170
196
  ```ruby
@@ -869,16 +869,10 @@ module StreamChat
869
869
  post('campaigns', data: { campaign: campaign })
870
870
  end
871
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)
872
+ # Queries campaigns similar to query_channels or query_users.
873
+ sig { params(params: T.untyped).returns(StreamChat::StreamResponse) }
874
+ def query_campaigns(**params)
875
+ get('campaigns', params: { payload: params.to_json })
882
876
  end
883
877
 
884
878
  # Updates a campaign.
@@ -894,9 +888,9 @@ module StreamChat
894
888
  end
895
889
 
896
890
  # 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 })
891
+ sig { params(campaign_id: String, scheduled_for: Integer).returns(StreamChat::StreamResponse) }
892
+ def schedule_campaign(campaign_id, scheduled_for)
893
+ patch("campaigns/#{campaign_id}/schedule", data: { scheduled_for: scheduled_for })
900
894
  end
901
895
 
902
896
  # Stops a campaign.
@@ -923,16 +917,10 @@ module StreamChat
923
917
  post('segments', data: { segment: segment })
924
918
  end
925
919
 
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)
920
+ # Queries campaign segments.
921
+ sig { params(params: T.untyped).returns(StreamChat::StreamResponse) }
922
+ def query_segments(**params)
923
+ get('segments', params: { payload: params.to_json })
936
924
  end
937
925
 
938
926
  # Updates a campaign segment.
@@ -947,6 +935,12 @@ module StreamChat
947
935
  delete("segments/#{segment_id}")
948
936
  end
949
937
 
938
+ # Queries campaign recipients.
939
+ sig { params(params: T.untyped).returns(StreamChat::StreamResponse) }
940
+ def query_recipients(**params)
941
+ get('recipients', params: { payload: params.to_json })
942
+ end
943
+
950
944
  private
951
945
 
952
946
  sig { returns(T::Hash[String, String]) }
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module StreamChat
5
- VERSION = '3.2.0'
5
+ VERSION = '3.3.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - getstream.io