Remove deprecated LocalDateTime in sdk pojos
This commit is contained in:
parent
5cb09ec919
commit
995e652716
11 changed files with 26 additions and 57 deletions
|
@ -21,9 +21,7 @@ fun Long.toLocalDateTime(): LocalDateTime = Instant
|
|||
.atZone(registerTimeZone)
|
||||
.toLocalDateTime()
|
||||
|
||||
fun Date.toLocalDateTime(): LocalDateTime = Instant
|
||||
.ofEpochMilli(time)
|
||||
.atZone(registerTimeZone)
|
||||
.toLocalDateTime()
|
||||
|
||||
fun String.normalizeRecipient() = substringBeforeLast("-").substringBefore(" [").substringBeforeLast(" (").trim()
|
||||
fun String.normalizeRecipient() = substringBeforeLast("-")
|
||||
.substringBefore(" [")
|
||||
.substringBeforeLast(" (")
|
||||
.trim()
|
||||
|
|
|
@ -11,8 +11,7 @@ fun List<ScrapperConference>.mapConferences(zoneId: ZoneId) = map {
|
|||
agenda = it.agenda,
|
||||
presentOnConference = it.presentOnConference,
|
||||
online = it.online,
|
||||
date = it.date,
|
||||
dateZoned = it.date.atZone(zoneId),
|
||||
date = it.date.atZone(zoneId),
|
||||
id = it.id,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ fun List<ApiMessage>.mapMessages(zoneId: ZoneId) = map {
|
|||
else -> 1
|
||||
},
|
||||
content = it.content,
|
||||
dateZoned = it.sentDateTime.toLocalDateTime().atZone(zoneId),
|
||||
date = it.sentDateTime.toLocalDateTime().atZone(zoneId),
|
||||
subject = it.subject,
|
||||
hasAttachments = false,
|
||||
)
|
||||
|
@ -42,7 +42,7 @@ fun List<ScrapperMessageMeta>.mapMessages(zoneId: ZoneId, folderId: Folder) = ma
|
|||
id = it.id,
|
||||
mailbox = it.mailbox,
|
||||
subject = it.subject,
|
||||
dateZoned = it.date.atZone(zoneId),
|
||||
date = it.date.atZone(zoneId),
|
||||
content = null,
|
||||
folderId = folderId.id,
|
||||
recipients = emptyList(),
|
||||
|
|
|
@ -3,7 +3,7 @@ package io.github.wulkanowy.sdk.mapper
|
|||
import io.github.wulkanowy.sdk.pojo.Device
|
||||
import io.github.wulkanowy.sdk.pojo.Token
|
||||
import io.github.wulkanowy.sdk.scrapper.mobile.TokenResponse
|
||||
import java.time.LocalDateTime.now
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import io.github.wulkanowy.sdk.scrapper.mobile.Device as ScrapperDevice
|
||||
|
||||
|
@ -19,9 +19,7 @@ fun List<ScrapperDevice>.mapDevices(zoneId: ZoneId) = map {
|
|||
id = it.id,
|
||||
deviceId = it.deviceId.orEmpty(),
|
||||
name = it.name.orEmpty(),
|
||||
createDate = it.createDate ?: now(),
|
||||
modificationDate = it.modificationDate,
|
||||
createDateZoned = (it.createDate ?: now()).atZone(zoneId),
|
||||
modificationDateZoned = it.modificationDate?.atZone(zoneId),
|
||||
createDate = (it.createDate ?: LocalDateTime.now()).atZone(zoneId),
|
||||
modificationDate = it.modificationDate?.atZone(zoneId),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ fun List<ApiTimetable>.mapTimetable(dictionaries: Dictionaries, zoneId: ZoneId)
|
|||
canceled = it.overriddenName,
|
||||
changes = it.boldName || (!it.annotationAboutChange.isNullOrBlank() && !it.overriddenName),
|
||||
date = it.day.toLocalDate(),
|
||||
start = startDateTime,
|
||||
end = endDateTime,
|
||||
startZoned = startDateTime.atZone(zoneId),
|
||||
endZoned = endDateTime.atZone(zoneId),
|
||||
start = startDateTime.atZone(zoneId),
|
||||
end = endDateTime.atZone(zoneId),
|
||||
group = it.divisionShort.orEmpty(),
|
||||
info = it.annotationAboutChange?.substringAfter("(")?.substringBefore(")").orEmpty(),
|
||||
number = it.lessonNumber,
|
||||
|
@ -70,10 +68,8 @@ fun List<ScrapperTimetable>.mapTimetable(zoneId: ZoneId) = map {
|
|||
canceled = it.canceled,
|
||||
changes = it.changes,
|
||||
date = it.date,
|
||||
start = it.start,
|
||||
end = it.end,
|
||||
startZoned = it.start.atZone(zoneId),
|
||||
endZoned = it.end.atZone(zoneId),
|
||||
start = it.start.atZone(zoneId),
|
||||
end = it.end.atZone(zoneId),
|
||||
group = it.group,
|
||||
info = it.info,
|
||||
number = it.number,
|
||||
|
@ -98,10 +94,8 @@ fun List<ScrapperTimetableAdditional>.mapTimetableAdditional(zoneId: ZoneId) = m
|
|||
TimetableAdditional(
|
||||
subject = it.subject,
|
||||
date = it.date,
|
||||
start = it.start,
|
||||
end = it.end,
|
||||
startZoned = it.start.atZone(zoneId),
|
||||
endZoned = it.end.atZone(zoneId),
|
||||
start = it.start.atZone(zoneId),
|
||||
end = it.end.atZone(zoneId),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.github.wulkanowy.sdk.pojo
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
data class Conference(
|
||||
|
@ -10,7 +9,5 @@ data class Conference(
|
|||
val presentOnConference: String,
|
||||
val online: Any?,
|
||||
val id: Int,
|
||||
@Deprecated("use dateZoned instead")
|
||||
val date: LocalDateTime,
|
||||
val dateZoned: ZonedDateTime,
|
||||
val date: ZonedDateTime,
|
||||
)
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package io.github.wulkanowy.sdk.pojo
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
data class Device(
|
||||
val id: Int,
|
||||
val deviceId: String,
|
||||
val name: String,
|
||||
@Deprecated("use createDateZoned instead")
|
||||
val createDate: LocalDateTime,
|
||||
@Deprecated("use modificationDateZoned instead")
|
||||
val modificationDate: LocalDateTime?,
|
||||
val createDateZoned: ZonedDateTime,
|
||||
val modificationDateZoned: ZonedDateTime?,
|
||||
val createDate: ZonedDateTime,
|
||||
val modificationDate: ZonedDateTime?,
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ data class Message(
|
|||
val correspondents: String,
|
||||
val subject: String,
|
||||
val content: String?,
|
||||
val dateZoned: ZonedDateTime,
|
||||
val date: ZonedDateTime,
|
||||
val folderId: Int,
|
||||
val unread: Boolean,
|
||||
val readBy: Int?,
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
package io.github.wulkanowy.sdk.pojo
|
||||
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
data class Timetable(
|
||||
val number: Int,
|
||||
@Deprecated("use startZoned instead")
|
||||
val start: LocalDateTime,
|
||||
@Deprecated("use endZoned instead")
|
||||
val end: LocalDateTime,
|
||||
val startZoned: ZonedDateTime,
|
||||
val endZoned: ZonedDateTime,
|
||||
val start: ZonedDateTime,
|
||||
val end: ZonedDateTime,
|
||||
val date: LocalDate,
|
||||
val subject: String,
|
||||
val subjectOld: String,
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package io.github.wulkanowy.sdk.pojo
|
||||
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
data class TimetableAdditional(
|
||||
@Deprecated("use startZoned instead")
|
||||
val start: LocalDateTime,
|
||||
@Deprecated("use endZoned instead")
|
||||
val end: LocalDateTime,
|
||||
val startZoned: ZonedDateTime,
|
||||
val endZoned: ZonedDateTime,
|
||||
val start: ZonedDateTime,
|
||||
val end: ZonedDateTime,
|
||||
val date: LocalDate,
|
||||
val subject: String,
|
||||
)
|
||||
|
|
|
@ -30,10 +30,8 @@ class TimetableMapperTest : BaseLocalTest() {
|
|||
|
||||
with(lessons[1]) {
|
||||
assertEquals(2, number)
|
||||
assertEquals(LocalDateTime.of(2020, 2, 3, 8, 55, 0), start)
|
||||
assertEquals(LocalDateTime.of(2020, 2, 3, 9, 40, 0), end)
|
||||
assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 8, 55, 0), ZoneId.of("Europe/Warsaw")), startZoned)
|
||||
assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 9, 40, 0), ZoneId.of("Europe/Warsaw")), endZoned)
|
||||
assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 8, 55, 0), ZoneId.of("Europe/Warsaw")), start)
|
||||
assertEquals(ZonedDateTime.of(LocalDateTime.of(2020, 2, 3, 9, 40, 0), ZoneId.of("Europe/Warsaw")), end)
|
||||
|
||||
assertEquals("Sieci komputerowe", subject)
|
||||
assertEquals("t.infor", group)
|
||||
|
|
Loading…
Reference in a new issue