Skip to content

Commit

Permalink
add api class
Browse files Browse the repository at this point in the history
  • Loading branch information
RivuChk committed Feb 11, 2024
1 parent b82f972 commit af168ca
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 2 deletions.
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
1 change: 1 addition & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.ksp)
alias(libs.plugins.sqlDelight)
alias(libs.plugins.kotlinSerialization)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion shared/src/commonMain/kotlin/Greeting.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Throwable, List<Conference>>
suspend fun addConference(conference: Conference): Either<Throwable, Boolean>
suspend fun deleteConference(conferenceId: String): Either<Throwable, Boolean>
suspend fun updateConference(conferenceId: String, conference: Conference): Either<Throwable, Boolean>
}

data class ConferenceFilters(
val time: ConferenceTime? = null,
val type: ConferenceType? = null,
) {
enum class ConferenceType {
Online, Offline
}
enum class ConferenceTime {
Past, Future
}
}
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.rivu.courses.indiaconferences.data.remote

import io.ktor.client.HttpClient

class IndiaConferencesAPI(
val ktorClient: HttpClient
) {

}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Throwable, List<Conference>> {
TODO("Not yet implemented")
}

override suspend fun addConference(conference: Conference): Either<Throwable, Boolean> {
TODO("Not yet implemented")
}

override suspend fun deleteConference(conferenceId: String): Either<Throwable, Boolean> {
TODO("Not yet implemented")
}

override suspend fun updateConference(conferenceId: String, conference: Conference): Either<Throwable, Boolean> {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit af168ca

Please sign in to comment.