File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed
composeApp/src/commonMain/kotlin/com/developersbreach/kotlindictionarymultiplatform/data/topic Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,16 @@ import kotlinx.serialization.SerialName
44import kotlinx.serialization.Serializable
55
66@Serializable
7- data class FirestoreDocument (
8- @SerialName(" fields" ) val fields : Map <String , FirestoreField >,
7+ data class RawTopic (
8+ @SerialName(" fields" ) val fields : Map <String , RawField >,
99)
1010
1111@Serializable
12- data class FirestoreField (
13- @SerialName(" stringValue" ) val stringValue : String ,
12+ data class RawField (
13+ @SerialName(" stringValue" ) val value : String ,
1414)
1515
1616@Serializable
17- data class FirestoreResponse (
18- @SerialName(" documents" ) val documents : List <FirestoreDocument >,
19- )
17+ data class Response (
18+ @SerialName(" documents" ) val topics : List <RawTopic >,
19+ )
Original file line number Diff line number Diff line change 11package com.developersbreach.kotlindictionarymultiplatform.data.topic.repository
22
33import arrow.core.Either
4- import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.FirestoreResponse
4+ import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Response
55import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
66import com.developersbreach.kotlindictionarymultiplatform.data.topic.utils.FirestoreConstants
77import com.developersbreach.kotlindictionarymultiplatform.data.topic.utils.toTopic
@@ -22,8 +22,8 @@ object TopicRepository {
2222
2323 suspend fun getTopics (): Either <Throwable , List <Topic >> {
2424 return Either .catch {
25- val response: FirestoreResponse = client.get(FirestoreConstants .TOPICS_URL ).body()
26- response.documents .map { it.toTopic() }
25+ val response: Response = client.get(FirestoreConstants .TOPICS_URL ).body()
26+ response.topics .map { it.toTopic() }
2727 }
2828 }
2929}
Original file line number Diff line number Diff line change 11package com.developersbreach.kotlindictionarymultiplatform.data.topic.utils
22
3- import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.FirestoreDocument
3+ import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.RawTopic
44import com.developersbreach.kotlindictionarymultiplatform.data.topic.model.Topic
55
6- fun FirestoreDocument .toTopic (): Topic {
6+ fun RawTopic .toTopic (): Topic {
77 return Topic (
8- name = fields[" name" ]?.stringValue .orEmpty(),
9- description = fields[" description" ]?.stringValue .orEmpty(),
8+ name = fields[" name" ]?.value .orEmpty(),
9+ description = fields[" description" ]?.value .orEmpty(),
1010 )
1111}
You can’t perform that action at this time.
0 commit comments