Skip to content

Commit

Permalink
chore: add serializer for room to room entry
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed Mar 7, 2023
1 parent 88b6733 commit e6b57b0
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package application.presenter.api.serializer
import application.presenter.api.model.EnvironmentalDataApiDto
import application.presenter.api.model.RoomApiDto
import application.presenter.api.model.RoomApiDtoType
import application.presenter.api.model.RoomEntry
import application.presenter.api.model.ValueWithUnit
import entity.zone.Room
import entity.zone.RoomEnvironmentalData
Expand All @@ -20,6 +21,17 @@ import entity.zone.RoomType
* Serializer for data to return in API.
*/
object ApiSerializer {
/**
* Extension method to obtain the room entry information.
* @return the room entry.
*/
fun Room.toRoomEntry(): RoomEntry = RoomEntry(
id = this.id.value,
name = this.name.orEmpty(),
zoneId = this.zoneId.value,
type = this.type.toString()
)

/**
* Extension method to convert [Room] API DTO to [application.presenter.api.model.RoomApiDto] class.
*/
Expand Down

0 comments on commit e6b57b0

Please sign in to comment.