Skip to content

Return wrappers from Mod::getLatestFiles() and Mod::getCategories() - #26

Merged
pavog merged 1 commit into
masterfrom
wrap-mod-files-and-categories
Oct 19, 2026
Merged

pavog merged 1 commit into
masterfrom
wrap-mod-files-and-categories

Conversation

@pavog

@pavog pavog commented Oct 19, 2026

Copy link
Copy Markdown
Member

The latest files and the categories are included in the mod returned by the API, but Mod::getLatestFiles() and Mod::getCategories() returned them as generated models. They now return the File and Category wrappers, so their fetch* methods can be used without another lookup:

// before
$file = $client->getModFile($mod->getId(), $mod->getLatestFiles()[0]->getId());
$changelog = $file->fetchChangelog();

// after
$changelog = $mod->getLatestFiles()[0]->fetchChangelog();

Changes

  • Mod::getLatestFiles() returns File[], Mod::getCategories() returns Category[]. Both still return null if the data is missing, so the JSON serialization of a mod does not change.
  • Mod::getPrimaryCategory() uses getCategories() instead of wrapping the category itself.
  • README: example for the latest files and categories of a mod.

Tests

  • New unit tests check that both getters return wrappers without sending a request, that the wrappers can send requests themselves, and that null is returned if the data is missing.
  • The serialization test also checks the nested files and categories.

@pavog
pavog requested a review from JulianVennen October 19, 2026 12:19
@pavog
pavog merged commit a68d6f5 into master Oct 19, 2026
3 checks passed
@pavog
pavog deleted the wrap-mod-files-and-categories branch October 19, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants