-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.puzzle.data.di | ||
|
||
import com.puzzle.data.repository.AuthRepositoryImpl | ||
import com.puzzle.domain.repository.AuthRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataModule { | ||
|
||
@Binds | ||
@Singleton | ||
abstract fun bindsAuthRepository( | ||
authRepositoryImpl: AuthRepositoryImpl, | ||
): AuthRepository | ||
} |
10 changes: 10 additions & 0 deletions
10
core/data/src/main/java/com/puzzle/data/repository/AuthRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.puzzle.data.repository | ||
|
||
import com.puzzle.domain.repository.AuthRepository | ||
import com.puzzle.network.source.AuthDataSource | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource, | ||
) : AuthRepository { | ||
} |
4 changes: 4 additions & 0 deletions
4
core/domain/src/main/java/com/puzzle/domain/repository/AuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.puzzle.domain.repository | ||
|
||
interface AuthRepository { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
core/network/src/main/java/com/puzzle/network/api/PieceApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.puzzle.network.api | ||
|
||
interface PieceApi { | ||
} |
49 changes: 49 additions & 0 deletions
49
core/network/src/main/java/com/puzzle/network/di/RetrofitModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.puzzle.network.di | ||
|
||
import com.puzzle.network.BuildConfig | ||
import com.puzzle.network.api.PieceApi | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RetrofitModule { | ||
|
||
private val json = Json { | ||
ignoreUnknownKeys = true | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideOkHttpClient(): OkHttpClient { | ||
val builder = OkHttpClient.Builder() | ||
|
||
if (BuildConfig.DEBUG) { | ||
val loggingInterceptor = HttpLoggingInterceptor() | ||
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY | ||
builder.addInterceptor(loggingInterceptor) | ||
} | ||
|
||
return builder.build() | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun providesAuthApi( | ||
okHttpClient: OkHttpClient, | ||
): PieceApi = Retrofit.Builder() | ||
.client(okHttpClient) | ||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType())) | ||
.baseUrl(BuildConfig.PIECE_BASE_URL) | ||
.build() | ||
.create(PieceApi::class.java) | ||
} |
10 changes: 10 additions & 0 deletions
10
core/network/src/main/java/com/puzzle/network/source/AuthDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.puzzle.network.source | ||
|
||
import com.puzzle.network.api.PieceApi | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class AuthDataSource @Inject constructor( | ||
private val pieceApi: PieceApi, | ||
) {} |