Skip to content

Commit

Permalink
style: ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Jul 18, 2024
1 parent 2be1990 commit d801ab8
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package poke.rogue.helper.remote


import kotlinx.serialization.json.Json
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaType
Expand All @@ -13,7 +12,6 @@ import retrofit2.converter.kotlinx.serialization.asConverterFactory
import java.util.concurrent.TimeUnit

object RetrofitModule {

private val retrofit by lazy {
val converterFactory = jsonConverterFactory(json())
val client = okHttpClient(loggingInterceptor())
Expand All @@ -24,28 +22,31 @@ object RetrofitModule {
.build()
}

private fun json(): Json = Json {
coerceInputValues = true
}
private fun json(): Json =
Json {
coerceInputValues = true
}

private fun jsonConverterFactory(json: Json): Converter.Factory {
return json.asConverterFactory("application/json".toMediaType())
}

private fun loggingInterceptor(): Interceptor = HttpLoggingInterceptor().setLevel(
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
}
)

private fun okHttpClient(logInterceptor: Interceptor): OkHttpClient = OkHttpClient
.Builder()
.addInterceptor(logInterceptor)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS).build()
private fun loggingInterceptor(): Interceptor =
HttpLoggingInterceptor().setLevel(
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
},
)

private fun okHttpClient(logInterceptor: Interceptor): OkHttpClient =
OkHttpClient
.Builder()
.addInterceptor(logInterceptor)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS).build()

fun retrofit(): Retrofit = retrofit
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import poke.rogue.helper.remote.service.PokeDexService
import retrofit2.create

object ServiceModule {

fun pokeDexService(): PokeDexService = ServicePool.pokeDexService

fun abilityService(): AbilityService = ServicePool.abilityService


private object ServicePool {
val pokeDexService: PokeDexService by lazy {
RetrofitModule.retrofit().create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import kotlinx.serialization.Serializable
data class BaseResponse<T>(
val message: String,
val data: T,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ data class AbilityDetailResponse(
val name: String,
val description: String,
val detailDescription: String,
val pokemons: List<PokemonResponse>
val pokemons: List<PokemonResponse>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data class AbilityResponse(
val name: String,
@SerialName("shortDescription")
val description: String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ data class PokemonDetailResponse(
val baseDefense: Int,
val baseSpecialAttack: Int,
val baseSpecialDefense: Int,
val baseSpeed: Int
val baseSpeed: Int,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package poke.rogue.helper.remote.dto.response.poke


import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import poke.rogue.helper.remote.dto.response.type.PokemonTypeResponse
Expand All @@ -12,5 +11,5 @@ data class PokemonResponse(
val name: String,
val pokedexNumber: Long,
@SerialName("pokemonTypeResponses")
val types: List<PokemonTypeResponse>
)
val types: List<PokemonTypeResponse>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class PokemonTypeResponse(
val pokemonTypeLogo: String,
val pokemonTypeName: String
)
val pokemonTypeName: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import retrofit2.http.GET
import retrofit2.http.Path

interface AbilityService {

@GET("api/v1/abilities")
fun abilities(): List<AbilityResponse>

@GET("api/v1/abilities/{id}")
fun ability(@Path("id") id: Int): AbilityDetailResponse
}
fun ability(
@Path("id") id: Int,
): AbilityDetailResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ interface PokeDexService {
fun pokemons(): List<PokemonResponse>

@GET("api/v1/pokemon/{id}")
fun pokemon(@Path("id") id: Long): PokemonDetailResponse
fun pokemon(
@Path("id") id: Long,
): PokemonDetailResponse
}

0 comments on commit d801ab8

Please sign in to comment.