Skip to content

Commit c67896f

Browse files
committed
Merge branch 'develop'
2 parents a98f3df + cf46b45 commit c67896f

File tree

5 files changed

+33
-127
lines changed

5 files changed

+33
-127
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 9.4.1 - 2025-09-11
4+
5+
Return ProcessResponse from AssetUpdateStartRequest.
6+
37
## 9.4.0 - 2025-09-10
48

59
Added support for AssetUpdateStartRequest (private API).

src/AssetsClient.php

Lines changed: 4 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -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";

src/AssetsUtils.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class AssetsUtils
2424
* Parse JSON response string into array, throw exception on error response
2525
*
2626
* @see https://helpcenter.woodwing.com/hc/en-us/articles/360041851272-Assets-Server-REST-API-error-handling
27-
* @param string $jsonString
28-
* @return array
2927
*/
3028
public static function parseJsonResponse(string $jsonString): array
3129
{
@@ -47,10 +45,6 @@ public static function buildGetUrl(string $url, array $data = []): string
4745
}
4846

4947

50-
/**
51-
* @param array $currentMetadata
52-
* @param array $updateMetadata
53-
*/
5448
public static function cleanUpUnchangedMetadataFields(array &$updateMetadata, array $currentMetadata): void
5549
{
5650
foreach ($updateMetadata as $key => $newValue) {
@@ -99,8 +93,6 @@ public static function cleanUpUnchangedMetadataFields(array &$updateMetadata, ar
9993
/**
10094
* Escape a query term for use with Elasticsearch
10195
*
102-
* @param string $queryTerm Query term
103-
* @return string Escaped query term
10496
* @see https://stackoverflow.com/questions/33845230/escape-elasticsearch-special-characters-in-php
10597
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-query-string-query.html#_reserved_characters
10698
*/
@@ -163,13 +155,6 @@ public static function replaceInvalidFilenameCharacters(string $subject, string
163155
* Get a Twig template for building an Assets query
164156
*
165157
* Call render($templateVariables) on the returned object to get the query string.
166-
*
167-
* @param string $templateString
168-
* @param array $allowedTags
169-
* @param array $allowedFilters
170-
* @return TemplateWrapper
171-
* @throws LoaderError
172-
* @throws SyntaxError
173158
*/
174159
public static function getQueryTemplate(string $templateString, array $allowedTags = [], array $allowedFilters = []): TemplateWrapper
175160
{

src/PrivateApi/System/ActiveUsersRequest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
namespace DerSpiegel\WoodWingAssetsClient\PrivateApi\System;
44

5+
use DerSpiegel\WoodWingAssetsClient\AssetsUtils;
56
use DerSpiegel\WoodWingAssetsClient\Request;
67

78

89
class ActiveUsersRequest extends Request
910
{
1011
public function __invoke(): array
1112
{
12-
return $this->assetsClient->privateApiRequest('GET', 'system/active-users');
13+
$httpResponse = $this->assetsClient->privateApiRequest('GET', 'system/active-users');
14+
15+
$responseBody = (string)$httpResponse->getBody();
16+
17+
if (empty($responseBody)) {
18+
return [];
19+
}
20+
21+
return AssetsUtils::parseJsonResponse($responseBody);
1322
}
1423
}

0 commit comments

Comments
 (0)