@@ -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,12 +282,6 @@ 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 ResponseInterface
319- */
320285 public function privateApiRequest (string $ method , string $ urlPath , array $ data = []): ResponseInterface
321286 {
322287 $ url = sprintf (
@@ -349,9 +314,6 @@ public function privateApiRequest(string $method, string $urlPath, array $data =
349314 }
350315
351316
352- /**
353- * @return Client
354- */
355317 protected function newHttpClient (): Client
356318 {
357319 $ stack = HandlerStack::create ();
@@ -368,9 +330,6 @@ protected function newHttpClient(): Client
368330 }
369331
370332
371- /**
372- * @return string
373- */
374333 protected function getDefaultHttpUserAgent (): string
375334 {
376335 return sprintf (
@@ -380,29 +339,19 @@ protected function getDefaultHttpUserAgent(): string
380339 }
381340
382341
383- /**
384- * @return string
385- */
386342 public function getHttpUserAgent (): string
387343 {
388344 return $ this ->httpUserAgent ;
389345 }
390346
391347
392- /**
393- * @param string $httpUserAgent
394- * @return self
395- */
396348 public function setHttpUserAgent (string $ httpUserAgent ): self
397349 {
398350 $ this ->httpUserAgent = $ httpUserAgent ;
399351 return $ this ;
400352 }
401353
402354
403- /**
404- * @return bool
405- */
406355 private function reLogin (): bool
407356 {
408357 try {
@@ -414,10 +363,6 @@ private function reLogin(): bool
414363 }
415364
416365
417- /**
418- * @param bool $force
419- * @return string
420- */
421366 public function getToken (bool $ force = false ): string
422367 {
423368 return match ($ this ->authMethod ) {
@@ -445,10 +390,6 @@ private function preventLoginLoops(): void
445390 }
446391
447392
448- /**
449- * @param array $data
450- * @return array
451- */
452393 private function dataToMultipart (array $ data ): array
453394 {
454395 $ multipart = [];
@@ -462,9 +403,6 @@ private function dataToMultipart(array $data): array
462403 }
463404
464405
465- /**
466- * @param string $bearerToken
467- */
468406 public function setBearerToken (string $ bearerToken ): void
469407 {
470408 $ this ->bearerToken = $ bearerToken ;
@@ -474,8 +412,6 @@ public function setBearerToken(string $bearerToken): void
474412
475413 /**
476414 * Perform API login and return Authorization token
477- * @param bool $force
478- * @return string
479415 */
480416 public function getBearerToken (bool $ force = false ): string
481417 {
@@ -515,10 +451,6 @@ public function getBearerToken(bool $force = false): string
515451 }
516452
517453
518- /**
519- * @param string $csrfToken
520- * @param array $cookies
521- */
522454 public function setCsrfToken (string $ csrfToken , array $ cookies = []): void
523455 {
524456 $ this ->csrfToken = $ csrfToken ;
@@ -527,38 +459,25 @@ public function setCsrfToken(string $csrfToken, array $cookies = []): void
527459 }
528460
529461
530- /**
531- * @return string
532- */
533462 public function getAuthCred (): string
534463 {
535464 return $ this ->authCred ;
536465 }
537466
538467
539- /**
540- * @param string $authCred
541- */
542468 public function setAuthCred (string $ authCred ): void
543469 {
544470 $ this ->authCred = $ authCred ;
545471 $ this ->setAuthMethod (self ::AUTH_METHOD_AUTHCRED );
546472 }
547473
548474
549- /**
550- * @return array
551- */
552475 public function getCookies (): array
553476 {
554477 return $ this ->cookies ;
555478 }
556479
557480
558- /**
559- * @param bool $force
560- * @return string
561- */
562481 public function getCsrfToken (bool $ force = false ): string
563482 {
564483 if ((strlen ($ this ->csrfToken ) > 0 ) && (!$ force )) {
@@ -599,10 +518,6 @@ public function getCsrfToken(bool $force = false): string
599518 }
600519
601520
602- /**
603- * @param bool $cleanUpToken
604- * @return LogoutResponse
605- */
606521 public function logout (bool $ cleanUpToken = true ): LogoutResponse
607522 {
608523 $ httpResponse = $ this ->serviceRequest ('POST ' , 'logout ' );
@@ -616,10 +531,6 @@ public function logout(bool $cleanUpToken = true): LogoutResponse
616531 }
617532
618533
619- /**
620- * @param string $url
621- * @param string $targetPath
622- */
623534 public function downloadFileToPath (string $ url , string $ targetPath ): void
624535 {
625536 try {
@@ -656,10 +567,6 @@ public function downloadFileToPath(string $url, string $targetPath): void
656567 }
657568
658569
659- /**
660- * @param ResponseInterface $httpResponse
661- * @param string $targetPath
662- */
663570 public function writeResponseBodyToPath (ResponseInterface $ httpResponse , string $ targetPath ): void
664571 {
665572 $ fp = fopen ($ targetPath , 'wb ' );
@@ -698,10 +605,6 @@ public function writeResponseBodyToPath(ResponseInterface $httpResponse, string
698605 }
699606
700607
701- /**
702- * @param string $assetId
703- * @return string
704- */
705608 public function buildOriginalFileUrl (string $ assetId ): string
706609 {
707610 return "{$ this ->config ->url }file/ $ assetId/*/ $ assetId " ;
0 commit comments