-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.php
More file actions
47 lines (37 loc) · 1.36 KB
/
App.php
File metadata and controls
47 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Hypernode\Api\Service;
class App extends AbstractService
{
public const V2_APP_LIST_URL = "/v2/app/";
public const V2_APP_DETAIL_URL = "/v2/app/%s/";
public const V2_APP_CANCEL_URL = "/v2/app/%s/cancel/";
public const V2_BRANCHER_APP_URL = "/v2/brancher/app/%s/";
public const V2_BRANCHER_DETAIL_URL = "/v2/brancher/%s/";
public const V1_APP_FLOWS_URL = "/logbook/v1/logbooks/%s/flows/";
/**
* @param array $params
* @return \Hypernode\Api\Resource\App[]
* @throws \Http\Client\Exception
* @throws \Hypernode\Api\Exception\HypernodeApiClientException
* @throws \Hypernode\Api\Exception\HypernodeApiServerException
*/
public function getList(array $params = []): array
{
$apps = [];
$requestUrl = self::V2_APP_LIST_URL;
if ($params) {
$requestUrl .= '?' . http_build_query($params);
}
while ($requestUrl) {
$response = $this->client->api->get($requestUrl);
$this->client->maybeThrowApiExceptions($response);
$data = $this->client->getJsonFromResponse($response);
foreach ($data['results'] as $item) {
$apps[] = new \Hypernode\Api\Resource\App($this->client, $item);
}
$requestUrl = $data['next'];
}
return $apps;
}
}