Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/stream-chat/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,16 @@ def get_export_channel_status(task_id)
get("export_channels/#{task_id}")
end

# Requests a users export.
#
# User exports are created asynchronously, you can use the Task ID returned by
# the APIs to keep track of the status and to download the final result when it is ready.
# Use `get_task` to check the status of the export.
sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
def export_users(user_ids)
post('export/users', data: { user_ids: user_ids })
end

# Returns the status of a task.
sig { params(task_id: String).returns(StreamChat::StreamResponse) }
def get_task(task_id)
Expand Down
23 changes: 23 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,29 @@ def loop_times(times)
end
end

it 'request users export' do
user_id1 = SecureRandom.uuid
@client.update_users([{ id: user_id1 }])

resp = @client.export_users([user_id1])
expect(resp['task_id']).not_to be_empty

task_id = resp['task_id']
loop do
resp = @client.get_task(task_id)
expect(resp['status']).not_to be_empty
expect(resp['created_at']).not_to be_empty
expect(resp['updated_at']).not_to be_empty
if resp['status'] == 'completed'
expect(resp['result']).not_to be_empty
expect(resp['result']['url']).not_to be_empty
expect(resp).not_to include 'error'
break
end
sleep(0.5)
end
end

it 'request delete channels' do
ch1 = @client.channel('messaging', channel_id: SecureRandom.uuid)
ch1.create(@random_user[:id])
Expand Down