refactor(model): use Konvert to automatically generate mappings

This commit is contained in:
Harsh Shandilya 2023-09-09 13:31:19 +05:30
parent d4672ae8bd
commit 25382acf0e
No known key found for this signature in database
8 changed files with 57 additions and 47 deletions

View file

@ -1,41 +0,0 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.posts
import dev.msfjarvis.claw.database.local.SavedPost
import dev.msfjarvis.claw.model.LobstersPost
import dev.msfjarvis.claw.model.LobstersPostDetails
fun LobstersPost.toDbModel(): SavedPost {
return SavedPost(
shortId = shortId,
title = title,
url = url,
createdAt = createdAt,
commentCount = commentCount,
commentsUrl = commentsUrl,
submitterName = submitter.username,
submitterAvatarUrl = submitter.avatarUrl,
tags = tags,
description = description,
)
}
fun LobstersPostDetails.toDbModel(): SavedPost {
return SavedPost(
shortId = shortId,
title = title,
url = url,
createdAt = createdAt,
commentCount = commentCount,
commentsUrl = commentsUrl,
submitterName = submitter.username,
submitterAvatarUrl = submitter.avatarUrl,
tags = tags,
description = description,
)
}