Fix: Handle missing 'color', 'isArchived' and 'value' fields in DTOs and mappers to prevent JsonDataException
This commit is contained in:
@@ -19,10 +19,10 @@ data class ItemSummaryDto(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "assetId") val assetId: String?,
|
||||
@Json(name = "image") val image: ImageDto?,
|
||||
@Json(name = "isArchived") val isArchived: Boolean,
|
||||
@Json(name = "isArchived") val isArchived: Boolean? = false,
|
||||
@Json(name = "labels") val labels: List<LabelOutDto>,
|
||||
@Json(name = "location") val location: LocationOutDto?,
|
||||
@Json(name = "value") val value: Double,
|
||||
@Json(name = "value") val value: Double? = 0.0,
|
||||
@Json(name = "createdAt") val createdAt: String,
|
||||
@Json(name = "updatedAt") val updatedAt: String
|
||||
)
|
||||
@@ -39,10 +39,10 @@ fun ItemSummaryDto.toDomain(): ItemSummary {
|
||||
name = this.name,
|
||||
assetId = this.assetId,
|
||||
image = this.image?.toDomain(),
|
||||
isArchived = this.isArchived,
|
||||
isArchived = this.isArchived ?: false,
|
||||
labels = this.labels.map { it.toDomain() },
|
||||
location = this.location?.toDomain(),
|
||||
value = this.value,
|
||||
value = this.value ?: 0.0,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
|
||||
@@ -16,9 +16,9 @@ data class LocationOutDto(
|
||||
@Json(name = "name")
|
||||
val name: String,
|
||||
@Json(name = "color")
|
||||
val color: String?,
|
||||
val color: String? = "#000000",
|
||||
@Json(name = "isArchived")
|
||||
val isArchived: Boolean?,
|
||||
val isArchived: Boolean? = false,
|
||||
@Json(name = "createdAt")
|
||||
val createdAt: String,
|
||||
@Json(name = "updatedAt")
|
||||
|
||||
@@ -103,10 +103,10 @@ fun ItemSummaryDto.toDomain(): DomainItemSummary {
|
||||
name = this.name,
|
||||
assetId = this.assetId,
|
||||
image = this.image?.toDomain(),
|
||||
isArchived = this.isArchived,
|
||||
isArchived = this.isArchived ?: false,
|
||||
labels = this.labels.map { it.toDomain() },
|
||||
location = this.location?.toDomain(),
|
||||
value = this.value,
|
||||
value = this.value ?: 0.0,
|
||||
createdAt = this.createdAt,
|
||||
updatedAt = this.updatedAt
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user