Skip to content

Commit cc2b9cd

Browse files
committed
Return ProcessResponse from AssetUpdateStartRequest.
1 parent 4c69b2d commit cc2b9cd

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,9 @@ public function apiRequest(string $method, string $urlPath, array $data = []): a
315315
* @param string $method
316316
* @param string $urlPath
317317
* @param array $data
318-
* @return array
319-
* @throws JsonException
318+
* @return ResponseInterface
320319
*/
321-
public function privateApiRequest(string $method, string $urlPath, array $data = []): array
320+
public function privateApiRequest(string $method, string $urlPath, array $data = []): ResponseInterface
322321
{
323322
$url = sprintf(
324323
'%sprivate-api/%s',
@@ -328,14 +327,6 @@ public function privateApiRequest(string $method, string $urlPath, array $data =
328327

329328
try {
330329
$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);
339330
} catch (Exception $e) {
340331
switch ($e->getCode()) {
341332
case 401: // Unauthorized
@@ -353,6 +344,8 @@ public function privateApiRequest(string $method, string $urlPath, array $data =
353344
throw $e;
354345
}
355346
}
347+
348+
return $httpResponse;
356349
}
357350

358351

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
}

src/PrivateApi/System/AssetUpdateStartRequest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DerSpiegel\WoodWingAssetsClient\AssetsClient;
66
use DerSpiegel\WoodWingAssetsClient\Request;
7+
use DerSpiegel\WoodWingAssetsClient\Service\ProcessResponse;
78

89

910
class AssetUpdateStartRequest extends Request
@@ -27,13 +28,24 @@ public function __construct(
2728
}
2829

2930

30-
public function __invoke(): array
31+
public function __invoke(): ProcessResponse
3132
{
32-
return $this->assetsClient->privateApiRequest(
33+
$data = $this->toArray();
34+
35+
$httpResponse = $this->assetsClient->privateApiRequest(
3336
'POST',
3437
'system/asset/update/start',
35-
$this->toArray()
38+
$data
39+
);
40+
41+
$this->logger->info(
42+
sprintf('Sending request to <system/asset/update/start>: %s', json_encode($data)),
43+
[
44+
'method' => __METHOD__,
45+
]
3646
);
47+
48+
return ProcessResponse::createFromHttpResponse($httpResponse);
3749
}
3850

3951

0 commit comments

Comments
 (0)