Skip to content

Commit f11caea

Browse files
committed
Add include changelog option to client methods for listing versions
1 parent 1cbf87d commit f11caea

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
invokerPackage: Aternos\ModrinthApi
2-
artifactVersion: 3.2.0
2+
artifactVersion: 3.2.1
33
generatorName: php
44
outputDir: .
55
inputSpec: https://raw.githubusercontent.com/modrinth/code/refs/heads/main/apps/docs/public/openapi.yaml

lib/Client/ModrinthAPIClient.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ public function checkProjectValidity(string $idOrSlug): ?string
223223
{
224224
try {
225225
return $this->projects->checkProjectValidity($idOrSlug)->getId();
226-
}
227-
catch (ApiException $exception) {
226+
} catch (ApiException $exception) {
228227
if ($exception->getCode() === 404) {
229228
return null;
230229
}
@@ -258,17 +257,19 @@ public function getProjectVersionFromIdOrNumber(string $idOrSlug, string $versio
258257
/**
259258
* Get all versions of a project
260259
* @param string $idOrSlug Project ID or slug
261-
* @param string[]|null $loaders only show versions for any of these loaders // TODO: enum??
260+
* @param string[]|null $loaders only show versions for any of these loaders
262261
* @param string[]|null $gameVersions
263262
* @param bool|null $featured
263+
* @param bool|null $include_changelog whether to include changelogs in the response. Currently defaults to true on modrinth side.
264264
* @return Version[]
265265
* @throws ApiException
266266
*/
267267
public function getProjectVersions(
268268
string $idOrSlug,
269269
?array $loaders = null,
270270
?array $gameVersions = null,
271-
?bool $featured = null
271+
?bool $featured = null,
272+
?bool $include_changelog = null,
272273
): array
273274
{
274275
return array_map(function (VersionModel $version): Version {
@@ -277,7 +278,8 @@ public function getProjectVersions(
277278
$idOrSlug,
278279
$loaders ? json_encode($loaders) : null,
279280
$gameVersions ? json_encode($gameVersions) : null,
280-
$featured
281+
$featured,
282+
$include_changelog,
281283
));
282284
}
283285

@@ -366,9 +368,9 @@ public function getLatestVersionFromHash(
366368
* @throws ApiException
367369
*/
368370
public function getLatestVersionsFromHashes(
369-
array $hashes,
370-
array $loaders,
371-
array $gameVersions,
371+
array $hashes,
372+
array $loaders,
373+
array $gameVersions,
372374
HashAlgorithm $algorithm = HashAlgorithm::SHA1
373375
): array
374376
{

lib/Client/ProjectTrait.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@ public function getDependencies(): ProjectDependencies
3030

3131
/**
3232
* Get all versions of this project
33-
* @param string[]|null $loaders
33+
* @param string[]|null $loaders only show versions for any of these loaders
3434
* @param string[]|null $gameVersions
3535
* @param bool|null $featured
36+
* @param bool|null $include_changelog whether to include changelogs in the response. Currently defaults to true on modrinth side.
3637
* @return Version[]
3738
* @throws ApiException
3839
*/
3940
public function getVersions(
4041
?array $loaders = null,
4142
?array $gameVersions = null,
42-
?bool $featured = null
43+
?bool $featured = null,
44+
?bool $include_changelog = null,
4345
): array
4446
{
45-
return $this->getClient()->getProjectVersions($this->getId(), $loaders, $gameVersions, $featured);
47+
return $this->getClient()->getProjectVersions($this->getId(), $loaders, $gameVersions, $featured, $include_changelog);
4648
}
4749

4850
/**
@@ -54,4 +56,4 @@ public function getMembers(): array
5456
{
5557
return $this->getClient()->getProjectMembers($this->getId());
5658
}
57-
}
59+
}

0 commit comments

Comments
 (0)