-
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.
Showing
10 changed files
with
111 additions
and
14 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/spoony/spoony/data/datasource/PostRemoteDataSource.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.spoony.spoony.data.datasource | ||
|
||
import com.spoony.spoony.data.dto.base.BaseResponseDTO | ||
|
||
interface PostRemoteDataSource { | ||
suspend fun postScoopPost(postId: Int, userId: Int): BaseResponseDTO<Boolean> | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/spoony/spoony/data/datasourceimpl/PostRemoteDataSourceImpl.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.spoony.spoony.data.datasourceimpl | ||
|
||
import com.spoony.spoony.data.datasource.PostRemoteDataSource | ||
import com.spoony.spoony.data.dto.base.BaseResponseDTO | ||
import com.spoony.spoony.data.dto.request.PostScoopRequestDTO | ||
import com.spoony.spoony.data.service.PostService | ||
import javax.inject.Inject | ||
|
||
class PostRemoteDataSourceImpl @Inject constructor( | ||
private val postService: PostService | ||
) : PostRemoteDataSource { | ||
override suspend fun postScoopPost(postId: Int, userId: Int): BaseResponseDTO<Boolean> = postService.postScoopPost( | ||
PostScoopRequestDTO(postId = postId, userId = userId) | ||
) | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/spoony/spoony/data/dto/base/BaseResponseDTO.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,20 @@ | ||
package com.spoony.spoony.data.dto.base | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponseDTO<T>( | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("error") | ||
val error: ErrorResponse? = null, | ||
@SerialName("data") | ||
val data: T? = null | ||
) | ||
|
||
@Serializable | ||
data class ErrorResponse( | ||
@SerialName("message") | ||
val message: String | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/spoony/spoony/data/dto/request/PostScoopRequestDTO.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,12 @@ | ||
package com.spoony.spoony.data.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PostScoopRequestDTO( | ||
@SerialName("postId") | ||
val postId: Int, | ||
@SerialName("userId") | ||
val userId: Int | ||
) |
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/spoony/spoony/data/service/PostService.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,19 @@ | ||
package com.spoony.spoony.data.service | ||
|
||
import com.spoony.spoony.data.dto.base.BaseResponseDTO | ||
import com.spoony.spoony.data.dto.request.PostScoopRequestDTO | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface PostService { | ||
companion object { | ||
const val API = "api" | ||
const val V1 = "v1" | ||
const val POST = "post" | ||
} | ||
|
||
@POST("/$API/$V1/$POST/scoop") | ||
suspend fun postScoopPost( | ||
@Body postScoopRequestDTO: PostScoopRequestDTO | ||
): BaseResponseDTO<Boolean> | ||
} |
3 changes: 2 additions & 1 deletion
3
app/src/main/java/com/spoony/spoony/domain/repository/PostRepository.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
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