Skip to content

Commit 6f0346a

Browse files
chore: add environmental data to room api dto
1 parent f68e963 commit 6f0346a

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/main/kotlin/application/presenter/api/model/RoomApiDto.kt

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
package application.presenter.api.model
1010

11-
import kotlinx.serialization.SerialName
1211
import kotlinx.serialization.Serializable
1312

1413
/**
1514
* Presenter class to be able to deserialize data that comes from API.
16-
* It deserializes [id], [name], [zoneId] and the [type] of the room.
15+
* It deserializes [id], [name], [zoneId], the [type] of the room and [environmentalData].
1716
*/
1817
@Serializable
1918
data class RoomApiDto(
2019
val id: String,
2120
val name: String,
22-
@SerialName("zone-id") val zoneId: String,
23-
val type: RoomApiDtoType
21+
val zoneId: String,
22+
val type: RoomApiDtoType,
23+
val environmentalData: EnvironmentalDataApiDto = EnvironmentalDataApiDto()
2424
)
2525

2626
/**
@@ -33,3 +33,27 @@ enum class RoomApiDtoType {
3333
/** Pre-operating room type. */
3434
PRE_OPERATING_ROOM
3535
}
36+
37+
/**
38+
* Describes a [value] with a [unit] of measurement.
39+
*/
40+
@Serializable
41+
data class ValueWithUnit<T>(val value: T, val unit: String)
42+
43+
/**
44+
* Wraps all the environmental data associated to a Room.
45+
* It corresponds to the model used with the API.
46+
* So it describe:
47+
* - the [temperature] inside the room
48+
* - the [humidity] inside the room
49+
* - the [luminosity] inside the room
50+
* - the [presence] of someone in the room
51+
* All the data may be not present.
52+
*/
53+
@Serializable
54+
data class EnvironmentalDataApiDto(
55+
val temperature: ValueWithUnit<Double>? = null,
56+
val humidity: Double? = null,
57+
val luminosity: ValueWithUnit<Double>? = null,
58+
val presence: Boolean? = null
59+
)

0 commit comments

Comments
 (0)