Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the ExtensionRepoService to use DTOs #573

Merged
merged 2 commits into from
Mar 23, 2024

Conversation

MajorTanya
Copy link
Contributor

Slightly refactored the ExtensionRepoService so it uses DTO data classes with parseAs to avoid parsing the JSON response by hand.

The default Json instance Injekt provides here has ignoreUnknownKeys enabled, so the ExtensionRepoMetaDto only specifies the meta key of the response content.

The extension function toExtensionRepo allows for mapping the new DTO to the domain's ExtensionRepo data class.

Slightly refactored the `ExtensionRepoService` so it uses a DTO with
`parseAs` to avoid parsing the JSON response by hand.

The default Json instance Injekt provides here has
`ignoreUnknownKeys` enabled, so the `ExtensionRepoMetaDto` only
specifies the meta key of the response content.

The extension function `toExtensionRepo` allows for mapping the new
DTO to the `domain` `ExtensionRepo` data class.
- Removed SerialName of the ExtensionRepoMetaDto property and renamed
it `meta`, same as the incoming attribute.
- Added a more general catch clause that also logs the occurring
Exception

Detekt likes to complain about TooGenericExceptionCaught, hence the
Suppress annotation on the function.
@AntsyLich AntsyLich merged commit 8c437ce into mihonapp:main Mar 23, 2024
1 check passed
@MajorTanya MajorTanya deleted the refactor-repo-service branch March 23, 2024 19:08
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants