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
11 changes: 11 additions & 0 deletions lib/GetStream/StreamChat/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,17 @@ public function getExportChannelStatus(string $id): StreamResponse
return $this->get("export_channels/{$id}");
}

/**
* Schedules user export task for a list of users
* @link https://getstream.io/chat/docs/php/exporting_users/?language=php
* @param $userIds array of user IDs to export.
* @return StreamResponse returns task ID that you can use to get export status (see getTask method)
*/
public function exportUsers(array $userIds): StreamResponse
{
return $this->post("export/users", ["user_ids" => $userIds]);
}

/**
* Returns task status
* @link https://getstream.io/chat/docs/rest/#tasks-gettask
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1460,4 +1460,24 @@ public function testUpdateMessagePartialWithRestrictedVisibility()
$this->assertNotNull($response["message"]["restricted_visibility"]);
$this->assertEquals([$this->user1["id"]], $response["message"]["restricted_visibility"]);
}

public function testExportUsers()
{
$user = ["id" => $this->generateGuid()];
$this->client->upsertUser($user);

$response = $this->client->exportUsers([$user["id"]]);
$this->assertTrue(array_key_exists("task_id", (array)$response));

$taskId = $response["task_id"];
for ($i = 0; $i < 30; $i++) {
$response = $this->client->getTask($taskId);
if ($response["status"] == "completed") {
$this->assertStringContainsString("/exports/users/", $response["result"]["url"]);
return;
}
usleep(300000);
}
$this->assertSame($response["status"], "completed");
}
}