Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: (#20) - change json to moshi #21

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".di.GomsApplication"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class JvmLibraryConventionPlugin : Plugin<Project> {
with(pluginManager) {
apply("org.jetbrains.kotlin.jvm")
apply("goms.android.lint")
apply("com.google.devtools.ksp")
}
configureKotlinJvm()
}
Expand Down
2 changes: 2 additions & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ plugins {

dependencies {
implementation(libs.kotlinx.datetime)
implementation(libs.moshi)
ksp(libs.retrofit.moshi.codegen)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.goms.model.request.auth

import com.squareup.moshi.JsonClass
import com.squareup.moshi.Json

@JsonClass(generateAdapter = true)
data class LoginRequest(
val code: String
@Json(name = "code") val code: String
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.goms.model.response.auth

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class LoginResponse(
val accessToken: String,
val refreshToken: String,
val accessTokenExp: String,
val refreshTokenExp: String,
val authority: String
@Json(name = "accessToken") val accessToken: String,
@Json(name = "refreshToken") val refreshToken: String,
@Json(name = "accessTokenExp") val accessTokenExp: String,
@Json(name = "refreshTokenExp") val refreshTokenExp: String,
@Json(name = "authority") val authority: String
)
15 changes: 11 additions & 4 deletions core/network/src/main/java/com/goms/network/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.goms.network.di
import android.util.Log
import com.goms.network.BuildConfig
import com.goms.network.api.AuthAPI
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -39,20 +40,26 @@ object NetworkModule {

@Provides
@Singleton
fun provideConverterFactory(): MoshiConverterFactory {
return MoshiConverterFactory.create()
fun provideMoshiInstance(): Moshi {
return Moshi.Builder().build()
}

@Provides
@Singleton
fun provideConverterFactory(moshi: Moshi): MoshiConverterFactory {
return MoshiConverterFactory.create(moshi)
}

@Provides
@Singleton
fun provideRetrofitInstance(
okHttpClient: OkHttpClient,
gsonConverterFactory: MoshiConverterFactory,
moshiConverterFactory: MoshiConverterFactory,
): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.client(okHttpClient)
.addConverterFactory(gsonConverterFactory)
.addConverterFactory(moshiConverterFactory)
.build()
}

Expand Down
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ androidxTestRunner = "1.5.2"
androidx-test-ext-junit = "1.1.5"
androidxWindowManager = "1.2.0"
coil = "2.4.0"
converter-moshi = "2.9.0"
firebaseBom = "31.2.0"
firebaseCrashlyticsPlugin = "2.9.2"
firebasePerfPlugin = "1.4.2"
Expand All @@ -40,7 +41,7 @@ ksp = "1.8.10-1.0.9"
lint = "31.2.1"
lifecycle-runtime-ktx = "2.6.2"
material = "1.2.0-alpha02"
moshi = "2.9.0"
moshi = "1.15.0"
okhttp = "4.11.0"
org-jetbrains-kotlin-android = "1.8.10"
protobuf = "3.24.0"
Expand Down Expand Up @@ -98,11 +99,13 @@ kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinxDateTime" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
lint-api = { group = "com.android.tools.lint", name = "lint-api", version.ref = "lint" }
moshi = { group = "com.squareup.moshi", name = "moshi", version.ref = "moshi" }
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version.ref = "protobuf" }
protobuf-protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" }
retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
retrofit-moshi-converter = { group = "com.squareup.retrofit2", name = "converter-moshi", version.ref = "moshi" }
retrofit-moshi-codegen = { group = "com.squareup.moshi", name = "moshi-kotlin-codegen", version.ref = "moshi" }
retrofit-moshi-converter = { group = "com.squareup.retrofit2", name = "converter-moshi", version.ref = "converter-moshi" }
retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerializableJson" }
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
Expand Down
Loading