diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2528d49..3b4dca8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -73,6 +73,7 @@ jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } ktor = { id = "io.ktor.plugin", version.ref = "ktor" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } ksp = { id = 'com.google.devtools.ksp', version.ref = 'ksp' } sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 371d3d7..3a52c12 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -6,6 +6,7 @@ plugins { alias(libs.plugins.androidLibrary) alias(libs.plugins.ksp) alias(libs.plugins.sqlDelight) + alias(libs.plugins.kotlinSerialization) } kotlin { diff --git a/shared/src/androidMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.android.kt b/shared/src/androidMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.android.kt index 5359d1d..bcd2d3b 100644 --- a/shared/src/androidMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.android.kt +++ b/shared/src/androidMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.android.kt @@ -1,6 +1,8 @@ package dev.rivu.courses.indiaconferences.remote import android.util.Log +import dev.rivu.courses.indiaconferences.data.remote.json +import dev.rivu.courses.indiaconferences.data.remote.retryConfig import io.ktor.client.HttpClient import io.ktor.client.engine.okhttp.OkHttp import io.ktor.client.plugins.HttpRequestRetry diff --git a/shared/src/commonMain/kotlin/Greeting.kt b/shared/src/commonMain/kotlin/Greeting.kt index 2c116f0..c03668a 100644 --- a/shared/src/commonMain/kotlin/Greeting.kt +++ b/shared/src/commonMain/kotlin/Greeting.kt @@ -1,4 +1,4 @@ -import dev.rivu.courses.indiaconferences.remote.KtorClient +import dev.rivu.courses.indiaconferences.data.remote.KtorClient import io.ktor.client.call.body import io.ktor.client.request.get import io.ktor.client.statement.bodyAsText diff --git a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/ConferencesDS.kt b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/ConferencesDS.kt new file mode 100644 index 0000000..35afabe --- /dev/null +++ b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/ConferencesDS.kt @@ -0,0 +1,24 @@ +package dev.rivu.courses.indiaconferences.data + +import arrow.core.Either +import dev.rivu.courses.indiaconferences.data.models.Conference +import io.ktor.util.reflect.Type + +interface ConferencesDS { + suspend fun getAllConferences(conferenceFilters: ConferenceFilters = ConferenceFilters()): Either> + suspend fun addConference(conference: Conference): Either + suspend fun deleteConference(conferenceId: String): Either + suspend fun updateConference(conferenceId: String, conference: Conference): Either +} + +data class ConferenceFilters( + val time: ConferenceTime? = null, + val type: ConferenceType? = null, +) { + enum class ConferenceType { + Online, Offline + } + enum class ConferenceTime { + Past, Future + } +} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/models/Conference.kt b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/models/Conference.kt new file mode 100644 index 0000000..b5aaccc --- /dev/null +++ b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/models/Conference.kt @@ -0,0 +1,22 @@ +package dev.rivu.courses.indiaconferences.data.models + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Conference( + @SerialName("link") + val link: String = "", + @SerialName("conference_end_date") + val conferenceEndDate: String = "", + @SerialName("conference_name") + val conferenceName: String = "", + @SerialName("conference_start_date") + val conferenceStartDate: String = "", + @SerialName("location") + val location: String = "", + @SerialName("id") + val id: String = "", + @SerialName("is_paid") + val isPaid: Boolean = false +) \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/IndiaConferencesAPI.kt b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/IndiaConferencesAPI.kt new file mode 100644 index 0000000..0f01196 --- /dev/null +++ b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/IndiaConferencesAPI.kt @@ -0,0 +1,9 @@ +package dev.rivu.courses.indiaconferences.data.remote + +import io.ktor.client.HttpClient + +class IndiaConferencesAPI( + val ktorClient: HttpClient +) { + +} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.kt b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/KtorClient.kt similarity index 86% rename from shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.kt rename to shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/KtorClient.kt index fb27330..75cc8ec 100644 --- a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.kt +++ b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/KtorClient.kt @@ -1,4 +1,4 @@ -package dev.rivu.courses.indiaconferences.remote +package dev.rivu.courses.indiaconferences.data.remote import io.ktor.client.HttpClient import io.ktor.client.plugins.HttpRequestRetry.Configuration diff --git a/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/RemoteConferencesDS.kt b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/RemoteConferencesDS.kt new file mode 100644 index 0000000..9ca979a --- /dev/null +++ b/shared/src/commonMain/kotlin/dev/rivu/courses/indiaconferences/data/remote/RemoteConferencesDS.kt @@ -0,0 +1,24 @@ +package dev.rivu.courses.indiaconferences.data.remote + +import arrow.core.Either +import dev.rivu.courses.indiaconferences.data.ConferenceFilters +import dev.rivu.courses.indiaconferences.data.ConferencesDS +import dev.rivu.courses.indiaconferences.data.models.Conference + +class RemoteConferencesDS : ConferencesDS { + override suspend fun getAllConferences(conferenceFilters: ConferenceFilters): Either> { + TODO("Not yet implemented") + } + + override suspend fun addConference(conference: Conference): Either { + TODO("Not yet implemented") + } + + override suspend fun deleteConference(conferenceId: String): Either { + TODO("Not yet implemented") + } + + override suspend fun updateConference(conferenceId: String, conference: Conference): Either { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/shared/src/nativeMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.native.kt b/shared/src/nativeMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.native.kt index acdb74e..4c22036 100644 --- a/shared/src/nativeMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.native.kt +++ b/shared/src/nativeMain/kotlin/dev/rivu/courses/indiaconferences/remote/KtorClient.native.kt @@ -1,5 +1,7 @@ package dev.rivu.courses.indiaconferences.remote +import dev.rivu.courses.indiaconferences.data.remote.json +import dev.rivu.courses.indiaconferences.data.remote.retryConfig import io.ktor.client.HttpClient import io.ktor.client.engine.darwin.Darwin import io.ktor.client.plugins.HttpRequestRetry