@@ -65,59 +65,37 @@ public function __construct(
6565 }
6666
6767
68- /**
69- * @param bool $allowReLogin
70- * @return self
71- */
7268 public function setAllowReLogin (bool $ allowReLogin ): self
7369 {
7470 $ this ->allowReLogin = $ allowReLogin ;
7571 return $ this ;
7672 }
7773
7874
79- /**
80- * @param int $authMethod
81- */
8275 public function setAuthMethod (int $ authMethod ): void
8376 {
8477 $ this ->authMethod = $ authMethod ;
8578 }
8679
8780
88- /**
89- * @return int
90- */
9181 public function getRequestTimeout (): int
9282 {
9383 return $ this ->requestTimeout ;
9484 }
9585
9686
97- /**
98- * @param int $seconds
99- * @return self
100- */
10187 public function setRequestTimeout (int $ seconds ): self
10288 {
10389 $ this ->requestTimeout = max ($ seconds , 1 );
10490 return $ this ;
10591 }
10692
10793
108- /**
109- * @param string $method
110- * @param string $url
111- * @param array $data
112- * @param bool $multipart - whether to send the data as multipart or application/json
113- * @param bool $sendToken
114- * @return ResponseInterface
115- */
11694 public function request (
11795 string $ method ,
11896 string $ url ,
11997 array $ data = [],
120- bool $ multipart = true ,
98+ bool $ multipart = true , // Whether to send the data as multipart or application/json
12199 bool $ sendToken = true
122100 ): ResponseInterface {
123101 $ options = [
@@ -256,13 +234,6 @@ public function serviceRequest(
256234 }
257235
258236
259- /**
260- * @param string $method
261- * @param string $urlPath
262- * @param array $data
263- * @return array
264- * @throws JsonException
265- */
266237 public function apiRequest (string $ method , string $ urlPath , array $ data = []): array
267238 {
268239 $ url = sprintf (
@@ -311,14 +282,7 @@ public function apiRequest(string $method, string $urlPath, array $data = []): a
311282 }
312283
313284
314- /**
315- * @param string $method
316- * @param string $urlPath
317- * @param array $data
318- * @return array
319- * @throws JsonException
320- */
321- public function privateApiRequest (string $ method , string $ urlPath , array $ data = []): array
285+ public function privateApiRequest (string $ method , string $ urlPath , array $ data = []): ResponseInterface
322286 {
323287 $ url = sprintf (
324288 '%sprivate-api/%s ' ,
@@ -328,14 +292,6 @@ public function privateApiRequest(string $method, string $urlPath, array $data =
328292
329293 try {
330294 $ httpResponse = $ this ->request ($ method , $ url , $ data , false );
331-
332- $ responseBbody = (string )$ httpResponse ->getBody ();
333-
334- if (empty ($ responseBbody )) {
335- return [];
336- }
337-
338- return AssetsUtils::parseJsonResponse ($ responseBbody );
339295 } catch (Exception $ e ) {
340296 switch ($ e ->getCode ()) {
341297 case 401 : // Unauthorized
@@ -353,12 +309,11 @@ public function privateApiRequest(string $method, string $urlPath, array $data =
353309 throw $ e ;
354310 }
355311 }
312+
313+ return $ httpResponse ;
356314 }
357315
358316
359- /**
360- * @return Client
361- */
362317 protected function newHttpClient (): Client
363318 {
364319 $ stack = HandlerStack::create ();
@@ -375,9 +330,6 @@ protected function newHttpClient(): Client
375330 }
376331
377332
378- /**
379- * @return string
380- */
381333 protected function getDefaultHttpUserAgent (): string
382334 {
383335 return sprintf (
@@ -387,29 +339,19 @@ protected function getDefaultHttpUserAgent(): string
387339 }
388340
389341
390- /**
391- * @return string
392- */
393342 public function getHttpUserAgent (): string
394343 {
395344 return $ this ->httpUserAgent ;
396345 }
397346
398347
399- /**
400- * @param string $httpUserAgent
401- * @return self
402- */
403348 public function setHttpUserAgent (string $ httpUserAgent ): self
404349 {
405350 $ this ->httpUserAgent = $ httpUserAgent ;
406351 return $ this ;
407352 }
408353
409354
410- /**
411- * @return bool
412- */
413355 private function reLogin (): bool
414356 {
415357 try {
@@ -421,10 +363,6 @@ private function reLogin(): bool
421363 }
422364
423365
424- /**
425- * @param bool $force
426- * @return string
427- */
428366 public function getToken (bool $ force = false ): string
429367 {
430368 return match ($ this ->authMethod ) {
@@ -452,10 +390,6 @@ private function preventLoginLoops(): void
452390 }
453391
454392
455- /**
456- * @param array $data
457- * @return array
458- */
459393 private function dataToMultipart (array $ data ): array
460394 {
461395 $ multipart = [];
@@ -469,9 +403,6 @@ private function dataToMultipart(array $data): array
469403 }
470404
471405
472- /**
473- * @param string $bearerToken
474- */
475406 public function setBearerToken (string $ bearerToken ): void
476407 {
477408 $ this ->bearerToken = $ bearerToken ;
@@ -481,8 +412,6 @@ public function setBearerToken(string $bearerToken): void
481412
482413 /**
483414 * Perform API login and return Authorization token
484- * @param bool $force
485- * @return string
486415 */
487416 public function getBearerToken (bool $ force = false ): string
488417 {
@@ -522,10 +451,6 @@ public function getBearerToken(bool $force = false): string
522451 }
523452
524453
525- /**
526- * @param string $csrfToken
527- * @param array $cookies
528- */
529454 public function setCsrfToken (string $ csrfToken , array $ cookies = []): void
530455 {
531456 $ this ->csrfToken = $ csrfToken ;
@@ -534,38 +459,25 @@ public function setCsrfToken(string $csrfToken, array $cookies = []): void
534459 }
535460
536461
537- /**
538- * @return string
539- */
540462 public function getAuthCred (): string
541463 {
542464 return $ this ->authCred ;
543465 }
544466
545467
546- /**
547- * @param string $authCred
548- */
549468 public function setAuthCred (string $ authCred ): void
550469 {
551470 $ this ->authCred = $ authCred ;
552471 $ this ->setAuthMethod (self ::AUTH_METHOD_AUTHCRED );
553472 }
554473
555474
556- /**
557- * @return array
558- */
559475 public function getCookies (): array
560476 {
561477 return $ this ->cookies ;
562478 }
563479
564480
565- /**
566- * @param bool $force
567- * @return string
568- */
569481 public function getCsrfToken (bool $ force = false ): string
570482 {
571483 if ((strlen ($ this ->csrfToken ) > 0 ) && (!$ force )) {
@@ -606,10 +518,6 @@ public function getCsrfToken(bool $force = false): string
606518 }
607519
608520
609- /**
610- * @param bool $cleanUpToken
611- * @return LogoutResponse
612- */
613521 public function logout (bool $ cleanUpToken = true ): LogoutResponse
614522 {
615523 $ httpResponse = $ this ->serviceRequest ('POST ' , 'logout ' );
@@ -623,10 +531,6 @@ public function logout(bool $cleanUpToken = true): LogoutResponse
623531 }
624532
625533
626- /**
627- * @param string $url
628- * @param string $targetPath
629- */
630534 public function downloadFileToPath (string $ url , string $ targetPath ): void
631535 {
632536 try {
@@ -663,10 +567,6 @@ public function downloadFileToPath(string $url, string $targetPath): void
663567 }
664568
665569
666- /**
667- * @param ResponseInterface $httpResponse
668- * @param string $targetPath
669- */
670570 public function writeResponseBodyToPath (ResponseInterface $ httpResponse , string $ targetPath ): void
671571 {
672572 $ fp = fopen ($ targetPath , 'wb ' );
@@ -705,10 +605,6 @@ public function writeResponseBodyToPath(ResponseInterface $httpResponse, string
705605 }
706606
707607
708- /**
709- * @param string $assetId
710- * @return string
711- */
712608 public function buildOriginalFileUrl (string $ assetId ): string
713609 {
714610 return "{$ this ->config ->url }file/ $ assetId/*/ $ assetId " ;
0 commit comments