-
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.
[feat] detail_image / 사진 정보 가져오기 api repository까지 완료 (#90)
- Loading branch information
Showing
5 changed files
with
78 additions
and
8 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
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/photosurfer/android/data/remote/mapper/ImageMapper.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,15 @@ | ||
package com.photosurfer.android.data.remote.mapper | ||
|
||
import com.photosurfer.android.data.remote.model.response.DetailImageResponse | ||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
import javax.inject.Inject | ||
|
||
class ImageMapper @Inject constructor() { | ||
|
||
fun toDetailImageInfo(detailImageResponse: DetailImageResponse): DetailImageInfo = | ||
DetailImageInfo( | ||
photoId = detailImageResponse.id, | ||
imageUrl = detailImageResponse.imageUrl, | ||
tagList = detailImageResponse.tags | ||
) | ||
} |
42 changes: 42 additions & 0 deletions
42
data/src/main/java/com/photosurfer/android/data/repository/ImageRepositoryImpl.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,42 @@ | ||
package com.photosurfer.android.data.repository | ||
|
||
import com.photosurfer.android.core.exception.RetrofitFailureStateException | ||
import com.photosurfer.android.data.remote.calladapter.NetworkState | ||
import com.photosurfer.android.data.remote.datasource.RemoteImageDataSource | ||
import com.photosurfer.android.data.remote.mapper.ImageMapper | ||
import com.photosurfer.android.data.remote.model.request.ChooseTagRequest | ||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
import com.photosurfer.android.domain.repository.ImageRepository | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class ImageRepositoryImpl @Inject constructor( | ||
private val remoteImageDataSource: RemoteImageDataSource, | ||
private val imageMapper: ImageMapper | ||
) : ImageRepository { | ||
|
||
override suspend fun getDetailImageInfo(photoId: Int): Result<DetailImageInfo> { | ||
when ( | ||
val response = remoteImageDataSource.getDetailImageInfo(photoId) | ||
) { | ||
is NetworkState.Success -> return Result.success( | ||
imageMapper.toDetailImageInfo(response.body.data) | ||
) | ||
is NetworkState.Failure -> return Result.failure( | ||
RetrofitFailureStateException( | ||
response.error, | ||
response.code | ||
) | ||
) | ||
is NetworkState.NetworkError -> Timber.d( | ||
response.error, | ||
"${this.javaClass.name}_getDetailImageInfo" | ||
) | ||
is NetworkState.UnknownError -> Timber.d( | ||
response.t, | ||
"${this.javaClass.name}_getDetailImageInfo" | ||
) | ||
} | ||
return Result.failure(IllegalStateException("NetworkError or UnKnownError please check timber")) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/photosurfer/android/domain/entity/DetailImageInfo.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,7 @@ | ||
package com.photosurfer.android.domain.entity | ||
|
||
data class DetailImageInfo( | ||
val photoId: Int, | ||
val imageUrl: String, | ||
val tagList: List<TagInfo> | ||
) |
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/photosurfer/android/domain/repository/ImageRepository.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,8 @@ | ||
package com.photosurfer.android.domain.repository | ||
|
||
import com.photosurfer.android.domain.entity.DetailImageInfo | ||
|
||
interface ImageRepository { | ||
|
||
suspend fun getDetailImageInfo(photoId: Int): Result<DetailImageInfo> | ||
} |