From 97e0d048421290e151950ae737df09d7f7aaa5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 20 Jan 2020 21:34:22 +0100 Subject: [PATCH] [API] Partially revert "Include device object in each request." --- .../edziennik/data/api/szkolny/SzkolnyApi.kt | 2 +- .../data/api/szkolny/request/ApiRequest.kt | 21 ------------------- .../api/szkolny/request/AppUserRequest.kt | 6 +++--- .../data/api/szkolny/request/Device.kt | 16 ++++++++++++++ .../api/szkolny/request/ErrorReportRequest.kt | 6 +++--- .../api/szkolny/request/EventShareRequest.kt | 6 +++--- .../api/szkolny/request/ServerSyncRequest.kt | 6 +++--- .../api/szkolny/request/WebPushRequest.kt | 6 +++--- 8 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ApiRequest.kt create mode 100644 app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/Device.kt diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/SzkolnyApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/SzkolnyApi.kt index 3997e27a..7427d9e7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/SzkolnyApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/SzkolnyApi.kt @@ -57,7 +57,7 @@ class SzkolnyApi(val app: App) { private fun getDevice() = run { val config = app.config - val device = ApiRequest.Device( + val device = Device( osType = "Android", osVersion = Build.VERSION.RELEASE, hardware = "${Build.MANUFACTURER} ${Build.MODEL}", diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ApiRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ApiRequest.kt deleted file mode 100644 index 2794a39a..00000000 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ApiRequest.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Kuba SzczodrzyƄski 2020-1-20. - */ - -package pl.szczodrzynski.edziennik.data.api.szkolny.request - -open class ApiRequest( - open val deviceId: String, - open val device: Device? = null -) { - data class Device( - val osType: String, - val osVersion: String, - val hardware: String, - val pushToken: String?, - val appVersion: String, - val appType: String, - val appVersionCode: Int, - val syncInterval: Int - ) -} diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/AppUserRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/AppUserRequest.kt index 0fde00b7..7c9d59ea 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/AppUserRequest.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/AppUserRequest.kt @@ -5,9 +5,9 @@ package pl.szczodrzynski.edziennik.data.api.szkolny.request data class AppUserRequest( - override val deviceId: String, - override val device: Device? = null, + val deviceId: String, + val device: Device? = null, val action: String = "unregister", val userCode: String -) : ApiRequest(deviceId, device) +) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/Device.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/Device.kt new file mode 100644 index 00000000..3c297c9b --- /dev/null +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/Device.kt @@ -0,0 +1,16 @@ +/* + * Copyright (c) Kuba SzczodrzyƄski 2020-1-20. + */ + +package pl.szczodrzynski.edziennik.data.api.szkolny.request + +data class Device( + val osType: String, + val osVersion: String, + val hardware: String, + val pushToken: String?, + val appVersion: String, + val appType: String, + val appVersionCode: Int, + val syncInterval: Int +) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ErrorReportRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ErrorReportRequest.kt index 18a2cc3f..93795ec8 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ErrorReportRequest.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ErrorReportRequest.kt @@ -5,12 +5,12 @@ package pl.szczodrzynski.edziennik.data.api.szkolny.request data class ErrorReportRequest( - override val deviceId: String, - override val device: Device? = null, + val deviceId: String, + val device: Device? = null, val appVersion: String, val errors: List -) : ApiRequest(deviceId, device) { +) { data class Error( val id: Long, val tag: String, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/EventShareRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/EventShareRequest.kt index cf7cd776..624b8b0f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/EventShareRequest.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/EventShareRequest.kt @@ -7,8 +7,8 @@ package pl.szczodrzynski.edziennik.data.api.szkolny.request import pl.szczodrzynski.edziennik.data.db.full.EventFull data class EventShareRequest ( - override val deviceId: String, - override val device: Device? = null, + val deviceId: String, + val device: Device? = null, val action: String = "event", @@ -19,4 +19,4 @@ data class EventShareRequest ( val eventId: Long? = null, val event: EventFull? = null -) : ApiRequest(deviceId, device) +) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ServerSyncRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ServerSyncRequest.kt index 3624aece..a60742e0 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ServerSyncRequest.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/ServerSyncRequest.kt @@ -5,14 +5,14 @@ package pl.szczodrzynski.edziennik.data.api.szkolny.request data class ServerSyncRequest( - override val deviceId: String, - override val device: Device? = null, + val deviceId: String, + val device: Device? = null, val userCodes: List, val users: List? = null, val notifications: List? = null -) : ApiRequest(deviceId, device) { +) { data class User( val userCode: String, val studentName: String, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/WebPushRequest.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/WebPushRequest.kt index 9be53747..225b8e08 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/WebPushRequest.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/request/WebPushRequest.kt @@ -5,11 +5,11 @@ package pl.szczodrzynski.edziennik.data.api.szkolny.request data class WebPushRequest( - override val deviceId: String, - override val device: Device? = null, + val deviceId: String, + val device: Device? = null, val action: String, val browserId: String? = null, val pairToken: String? = null -) : ApiRequest(deviceId, device) +)