Skip to content

Commit

Permalink
[feat] detail_image / 사진 삭제 api 데이터 소스까지 작성 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
2chang5 committed Jul 22, 2022
1 parent 33d9501 commit e5e98a1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ object RetrofitServiceModule {
@Singleton
fun providesDetailImageService(retrofit: Retrofit): DetailImageService =
retrofit.create(DetailImageService::class.java)

@Provides
@Singleton
fun providesDeleteImageService(retrofit: Retrofit): DeleteImageService =
retrofit.create(DeleteImageService::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package com.photosurfer.android.data.remote.datasource
import com.photosurfer.android.data.remote.calladapter.NetworkState
import com.photosurfer.android.data.remote.model.response.BaseResponse
import com.photosurfer.android.data.remote.model.response.DetailImageResponse
import com.photosurfer.android.data.remote.model.response.NoDataResponse

interface RemoteImageDataSource {

suspend fun getDetailImageInfo(photoId: Int): NetworkState<BaseResponse<DetailImageResponse>>

suspend fun deleteImage(options: Map<String, Int>): NetworkState<NoDataResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package com.photosurfer.android.data.remote.datasource
import com.photosurfer.android.data.remote.calladapter.NetworkState
import com.photosurfer.android.data.remote.model.response.BaseResponse
import com.photosurfer.android.data.remote.model.response.DetailImageResponse
import com.photosurfer.android.data.remote.model.response.NoDataResponse
import com.photosurfer.android.data.remote.service.DeleteImageService
import com.photosurfer.android.data.remote.service.DetailImageService
import javax.inject.Inject

class RemoteImageDataSourceImpl @Inject constructor(
private val detailImageService: DetailImageService
private val detailImageService: DetailImageService,
private val deleteImageService: DeleteImageService
) : RemoteImageDataSource {

override suspend fun getDetailImageInfo(photoId: Int): NetworkState<BaseResponse<DetailImageResponse>> =
detailImageService.getDetailImageInfo(photoId)

override suspend fun deleteImage(options: Map<String, Int>): NetworkState<NoDataResponse> =
deleteImageService.deleteImage(options)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.photosurfer.android.data.remote.model.response


import com.google.gson.annotations.SerializedName

data class NoDataResponse(
@SerializedName("message")
val message: String,
@SerializedName("status")
val status: Int,
@SerializedName("success")
val success: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.photosurfer.android.data.remote.service

import com.photosurfer.android.data.remote.calladapter.NetworkState
import com.photosurfer.android.data.remote.model.response.BaseResponse
import com.photosurfer.android.data.remote.model.response.NoDataResponse
import retrofit2.http.PUT
import retrofit2.http.QueryMap

interface DeleteImageService {
@PUT("photo")
suspend fun deleteImage(
@QueryMap options: Map<String, Int>
): NetworkState<NoDataResponse>
}

0 comments on commit e5e98a1

Please sign in to comment.