File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ gem install stream-chat-ruby
3737- User devices
3838- User search
3939- Channel search
40+ - Blocklists
41+ - Export channels
4042
4143### Import
4244
@@ -152,6 +154,31 @@ client.get_devices('jane-77')
152154client.remove_device(jane_phone[' id' ], jane_phone[' user_id' ])
153155```
154156
157+ ### Blocklists
158+ ``` ruby
159+ # Create a blocklist
160+ client.create_blocklist(' my_blocker' , %w[fudge cream sugar] )
161+
162+ # Enable it on messaging channel type
163+ client.update_channel_type(' messaging' , blocklist: ' my_blocker' , blocklist_behavior: ' block' )
164+
165+ # Get the details of the blocklist
166+ client.get_blocklist(' my_blocker' )
167+
168+ # Delete the blocklist
169+ client.delete_blocklist(' my_blocker' )
170+ ```
171+
172+ ### Export Channels
173+ ``` ruby
174+ # Register an export
175+ response = client.export_channels({type: ' messaging' , id: ' jane' })
176+
177+ # Check completion
178+ status_response = client.get_export_channel_status(response[' task_id' ])
179+ # status_response['status'] == 'pending', 'completed'
180+ ```
181+
155182### Example Rails application
156183
157184See [ an example rails application using the Ruby SDK] ( https://github.com/GetStream/rails-chat-example ) .
Original file line number Diff line number Diff line change @@ -264,6 +264,14 @@ def delete_blocklist(name)
264264 delete ( "blocklists/#{ name } " )
265265 end
266266
267+ def export_channels ( *channels )
268+ post ( 'export_channels' , data : { "channels" : channels } )
269+ end
270+
271+ def get_export_channel_status ( task_id )
272+ get ( "export_channels/#{ task_id } " )
273+ end
274+
267275 def put ( relative_url , params : nil , data : nil )
268276 make_http_request ( :put , relative_url , params : params , data : data )
269277 end
Original file line number Diff line number Diff line change 316316 )
317317 end
318318 end
319+
320+ it 'check status for a task that does not exist' do
321+ expect do
322+ @client . get_export_channel_status ( SecureRandom . uuid )
323+ end . to raise_error (
324+ /Can't find task with id/
325+ )
326+ end
327+
328+ it 'request the export for a channel that does not exist' do
329+ expect do
330+ @client . export_channels ( { type : 'messaging' , id : SecureRandom . uuid } )
331+ end . to raise_error
332+ end
333+
334+ it 'request the channel export' do
335+ ch = @client . channel ( 'messaging' , channel_id : SecureRandom . uuid )
336+ ch . create ( @random_user [ :id ] )
337+ ch . send_message ( { text : 'Hey Joni' } , @random_user [ :id ] )
338+
339+ resp = @client . export_channels ( { type : ch . channel_type , id : ch . id } )
340+ expect ( resp [ 'task_id' ] ) . not_to be_empty
341+
342+ task_id = resp [ 'task_id' ]
343+ loop do
344+ resp = @client . get_export_channel_status ( task_id )
345+ expect ( resp [ 'status' ] ) . not_to be_empty
346+ expect ( resp [ 'created_at' ] ) . not_to be_empty
347+ expect ( resp [ 'updated_at' ] ) . not_to be_empty
348+ if resp [ 'status' ] == 'completed'
349+ expect ( resp [ 'result' ] ) . not_to be_empty
350+ expect ( resp [ 'result' ] [ 'url' ] ) . not_to be_empty
351+ expect ( resp [ 'error' ] ) . not_to be_empty
352+ break
353+ end
354+ sleep ( 0.5 )
355+ end
356+ end
319357end
You can’t perform that action at this time.
0 commit comments