@@ -123,7 +123,7 @@ public function getBaseUrl(): string
123123 return "https://chat.stream-io-api.com " ;
124124 }
125125
126- /**
126+ /** For internal usage only.
127127 * @internal
128128 */
129129 public function buildRequestUrl (string $ uri ): string
@@ -163,7 +163,7 @@ private function getHttpRequestHeaders(): array
163163 /**
164164 * @throws StreamException
165165 */
166- public function makeHttpRequest (string $ uri , string $ method , $ data = [], array $ queryParams = [], array $ multipart = []): StreamResponse
166+ private function makeHttpRequest (string $ uri , string $ method , $ data = [], array $ queryParams = [], array $ multipart = []): StreamResponse
167167 {
168168 $ queryParams ['api_key ' ] = $ this ->apiKey ;
169169 $ headers = $ this ->getHttpRequestHeaders ();
@@ -232,39 +232,44 @@ public function createToken(string $userId, int $expiration = null, int $issuedA
232232 return $ this ->jwtHandler ->encode ($ this ->apiSecret , $ payload );
233233 }
234234
235- /**
235+ /** For internal usage only.
236+ * @internal
236237 * @throws StreamException
237238 */
238239 public function get (string $ uri , array $ queryParams = []): StreamResponse
239240 {
240241 return $ this ->makeHttpRequest ($ uri , "GET " , [], $ queryParams );
241242 }
242243
243- /**
244+ /** For internal usage only.
245+ * @internal
244246 * @throws StreamException
245247 */
246248 public function delete (string $ uri , array $ queryParams = []): StreamResponse
247249 {
248250 return $ this ->makeHttpRequest ($ uri , "DELETE " , [], $ queryParams );
249251 }
250252
251- /**
253+ /** For internal usage only.
254+ * @internal
252255 * @throws StreamException
253256 */
254257 public function patch (string $ uri , array $ data , array $ queryParams = []): StreamResponse
255258 {
256259 return $ this ->makeHttpRequest ($ uri , "PATCH " , $ data , $ queryParams );
257260 }
258261
259- /**
262+ /** For internal usage only.
263+ * @internal
260264 * @throws StreamException
261265 */
262266 public function post (string $ uri , $ data , array $ queryParams = []): StreamResponse
263267 {
264268 return $ this ->makeHttpRequest ($ uri , "POST " , $ data , $ queryParams );
265269 }
266270
267- /**
271+ /** For internal usage only.
272+ * @internal
268273 * @throws StreamException
269274 */
270275 public function put (string $ uri , array $ data , array $ queryParams = []): StreamResponse
@@ -332,7 +337,8 @@ public function upsertUser(array $user): StreamResponse
332337 return $ this ->upsertUsers ([$ user ]);
333338 }
334339
335- /** @link https://getstream.io/chat/docs/php/update_users/?language=php
340+ /** Update multiple users.
341+ * @link https://getstream.io/chat/docs/php/update_users/?language=php
336342 * @deprecated use `$client->upsertUsers` instead
337343 * @throws StreamException
338344 */
@@ -341,7 +347,8 @@ public function updateUsers(array $users): StreamResponse
341347 return $ this ->upsertUsers ($ users );
342348 }
343349
344- /** @link https://getstream.io/chat/docs/php/update_users/?language=php
350+ /** Update a single user.
351+ * @link https://getstream.io/chat/docs/php/update_users/?language=php
345352 * @deprecated use `$client->upsertUser` instead
346353 * @throws StreamException
347354 */
@@ -869,7 +876,8 @@ public function Channel(string $channelTypeName, ?string $channelId, array $data
869876 return new Channel ($ this , $ channelTypeName , $ channelId , $ data );
870877 }
871878
872- /** @deprecated method: use `$client->Channel` instead
879+ /** Returns a Channel object. Don't use it.
880+ * @deprecated method: use `$client->Channel` instead
873881 * @throws StreamException
874882 */
875883 public function getChannel (string $ channelTypeName , string $ channelId , array $ data = null ): Channel
@@ -1303,4 +1311,84 @@ public function listPushProviders(): StreamResponse
13031311 {
13041312 return $ this ->get ("push_providers " );
13051313 }
1314+
1315+ /** Create import url
1316+ *
1317+ * A full flow looks like this:
1318+ * ```php
1319+ * $urlResp = $client->createImportUrl('myfile.json');
1320+ * $guzzleClient->put($urlResp['upload_url'], [
1321+ * 'body' => file_get_contents("myfile.json"),
1322+ * 'headers' => ['Content-Type' => 'application/json']
1323+ * ]);
1324+ * $createResp = $client->createImport($urlResp['path'], "upsert");
1325+ * $getResp = $client->getImport($createResp['import_task']['id']);
1326+ * ```
1327+ * @link https://getstream.io/chat/docs/php/import/?language=php
1328+ * @throws StreamException
1329+ */
1330+ public function createImportUrl (string $ filename ): StreamResponse
1331+ {
1332+ return $ this ->post ("import_urls " , ["filename " => $ filename ]);
1333+ }
1334+
1335+ /** Create an import. `$mode` can be `upsert` or `insert`.
1336+ *
1337+ * A full flow looks like this:
1338+ * ```php
1339+ * $urlResp = $client->createImportUrl('myfile.json');
1340+ * $guzzleClient->put($urlResp['upload_url'], [
1341+ * 'body' => file_get_contents("myfile.json"),
1342+ * 'headers' => ['Content-Type' => 'application/json']
1343+ * ]);
1344+ * $createResp = $client->createImport($urlResp['path'], "upsert");
1345+ * $getResp = $client->getImport($createResp['import_task']['id']);
1346+ * ```
1347+ * @link https://getstream.io/chat/docs/php/import/?language=php
1348+ * @throws StreamException
1349+ */
1350+ public function createImport (string $ path , string $ mode ): StreamResponse
1351+ {
1352+ return $ this ->post ("imports " , ["path " => $ path , "mode " => $ mode ]);
1353+ }
1354+
1355+ /** Get an import
1356+ *
1357+ * A full flow looks like this:
1358+ * ```php
1359+ * $urlResp = $client->createImportUrl('myfile.json');
1360+ * $guzzleClient->put($urlResp['upload_url'], [
1361+ * 'body' => file_get_contents("myfile.json"),
1362+ * 'headers' => ['Content-Type' => 'application/json']
1363+ * ]);
1364+ * $createResp = $client->createImport($urlResp['path'], "upsert");
1365+ * $getResp = $client->getImport($createResp['import_task']['id']);
1366+ * ```
1367+ * @link https://getstream.io/chat/docs/php/import/?language=php
1368+ * @throws StreamException
1369+ */
1370+ public function getImport (string $ id ): StreamResponse
1371+ {
1372+ return $ this ->get ("imports/ {$ id }" );
1373+ }
1374+
1375+ /** List all imports. Options array can contain `limit` and `offset` fields for pagination.
1376+ *
1377+ * A full flow looks like this:
1378+ * ```php
1379+ * $urlResp = $client->createImportUrl('myfile.json');
1380+ * $guzzleClient->put($urlResp['upload_url'], [
1381+ * 'body' => file_get_contents("myfile.json"),
1382+ * 'headers' => ['Content-Type' => 'application/json']
1383+ * ]);
1384+ * $createResp = $client->createImport($urlResp['path'], "upsert");
1385+ * $getResp = $client->getImport($createResp['import_task']['id']);
1386+ * ```
1387+ * @link https://getstream.io/chat/docs/php/import/?language=php
1388+ * @throws StreamException
1389+ */
1390+ public function listImports (array $ options = []): StreamResponse
1391+ {
1392+ return $ this ->get ("imports " , $ options );
1393+ }
13061394}
0 commit comments