Skip to content

Commit fe637e8

Browse files
committed
Use direct_asset_url for assets if exists
1 parent af02ae5 commit fe637e8

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

src/Module/Repository/Internal/GitLab/Api/RepositoryApi.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,18 @@ public function getReleases(int $page = 1): Paginator
103103
$response = $this->releasesRequest($currentPage);
104104

105105
/** @var array<array-key, array{
106-
* name: string|null,
107-
* tag_name: string,
108-
* released_at: string,
106+
* name: non-empty-string|null,
107+
* tag_name: non-empty-string,
108+
* description: null|non-empty-string,
109+
* created_at: non-empty-string,
110+
* released_at: non-empty-string,
109111
* assets: array{
110112
* links: list<array{
111-
* name: string,
112-
* url: string,
113-
* direct_asset_url: string,
114-
* }>
113+
* name: non-empty-string,
114+
* url: non-empty-string,
115+
* direct_asset_url?: non-empty-string,
116+
* link_type: non-empty-string,
117+
* }>
115118
* },
116119
* upcoming_release: bool
117120
* }> $data */

src/Module/Repository/Internal/GitLab/Api/Response/AssetInfo.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,28 @@ final class AssetInfo
1515
/**
1616
* @param non-empty-string $name
1717
* @param non-empty-string $downloadUrl
18+
* @param non-empty-string|null $linkType
1819
*/
1920
public function __construct(
2021
public readonly string $name,
2122
public readonly string $downloadUrl,
23+
public readonly ?string $linkType = null,
2224
) {}
2325

2426
/**
2527
* @param array{
26-
* name: string,
27-
* url: string,
28-
* direct_asset_url: string,
28+
* name: non-empty-string,
29+
* url: non-empty-string,
30+
* direct_asset_url?: non-empty-string,
31+
* link_type: non-empty-string,
2932
* } $data
3033
*/
3134
public static function fromApiResponse(array $data): self
3235
{
3336
return new self(
3437
name: $data['name'],
35-
downloadUrl: $data['url'],
38+
downloadUrl: !empty($data['direct_asset_url']) ? $data['direct_asset_url'] : $data['url'],
39+
linkType: $data['link_type'] ?? null,
3640
);
3741
}
3842
}

src/Module/Repository/Internal/GitLab/Api/Response/ReleaseInfo.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ public function __construct(
2727

2828
/**
2929
* @param array{
30-
* name: string|null,
31-
* tag_name: string,
32-
* released_at: string,
33-
* assets: array{
34-
* links: list<array{
35-
* name: string,
36-
* url: string,
37-
* direct_asset_url: string,
38-
* }>
30+
* name: non-empty-string|null,
31+
* tag_name: non-empty-string,
32+
* description: null|non-empty-string,
33+
* created_at: non-empty-string,
34+
* released_at: non-empty-string,
35+
* assets: array{
36+
* links: list<array{
37+
* name: non-empty-string,
38+
* url: non-empty-string,
39+
* direct_asset_url?: non-empty-string,
40+
* link_type: non-empty-string,
41+
* }>
3942
* },
4043
* upcoming_release: bool
4144
* } $data

0 commit comments

Comments
 (0)