Skip to content

Commit

Permalink
Merge pull request #129 from GSM-MSG/feature/#128_set_up_network_on_i…
Browse files Browse the repository at this point in the history
…nquiry_my_page

🔀 :: (#128) - Set up network on inquiry my page
  • Loading branch information
wjdcksdn authored Dec 5, 2023
2 parents dab2b9c + 9e9f7ca commit d27d8ed
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.msg.data.repository.user

import com.msg.model.remote.request.user.ChangePasswordRequest
import com.msg.model.remote.response.user.InquiryMyPageResponse
import kotlinx.coroutines.flow.Flow

interface UserRepository {
suspend fun changePassword(body: ChangePasswordRequest): Flow<Unit>
suspend fun inquiryMyPage(): Flow<InquiryMyPageResponse>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.msg.data.repository.user

import com.msg.model.remote.request.user.ChangePasswordRequest
import com.msg.model.remote.response.user.InquiryMyPageResponse
import com.msg.network.datasource.user.UserDataSource
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
Expand All @@ -11,4 +12,8 @@ class UserRepositoryImpl @Inject constructor(
override suspend fun changePassword(body: ChangePasswordRequest): Flow<Unit> {
return userDataSource.changePassword(body = body)
}

override suspend fun inquiryMyPage(): Flow<InquiryMyPageResponse> {
return userDataSource.inquiryMyPage()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.msg.domain.user

import com.msg.data.repository.user.UserRepository
import com.msg.model.remote.request.user.ChangePasswordRequest
import javax.inject.Inject

class ChangePasswordUseCase @Inject constructor(
private val userRepository: UserRepository
) {
suspend operator fun invoke(body: ChangePasswordRequest) = runCatching {
userRepository.changePassword(body = body)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.domain.user

import com.msg.data.repository.user.UserRepository
import javax.inject.Inject

class InquiryMyPageUseCase @Inject constructor(
private val userRepository: UserRepository
) {
suspend operator fun invoke() = runCatching {
userRepository.inquiryMyPage()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.msg.model.remote.response.user

import com.msg.model.remote.enumdatatype.Authority

data class InquiryMyPageResponse(
val name: String,
val email: String,
val phoneNumber: String,
val authority: Authority,
val organization: String
)
7 changes: 6 additions & 1 deletion core/network/src/main/java/com/msg/network/api/UserAPI.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.msg.network.api

import com.msg.model.remote.request.user.ChangePasswordRequest
import com.msg.model.remote.response.user.InquiryMyPageResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH

interface UserAPI {
@PATCH
@PATCH("user")
suspend fun changePassword(
@Body body: ChangePasswordRequest
)

@GET("user")
suspend fun inquiryMyPage(): InquiryMyPageResponse
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.msg.network.datasource.user

import com.msg.model.remote.request.user.ChangePasswordRequest
import com.msg.model.remote.response.user.InquiryMyPageResponse
import kotlinx.coroutines.flow.Flow

interface UserDataSource {
suspend fun changePassword(body: ChangePasswordRequest): Flow<Unit>
suspend fun inquiryMyPage(): Flow<InquiryMyPageResponse>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.msg.network.datasource.user

import com.msg.model.remote.request.user.ChangePasswordRequest
import com.msg.model.remote.response.user.InquiryMyPageResponse
import com.msg.network.api.UserAPI
import com.msg.network.util.BitgoeulApiHandler
import kotlinx.coroutines.Dispatchers
Expand All @@ -19,4 +20,12 @@ class UserDataSourceImpl @Inject constructor(
.sendRequest()
)
}.flowOn(Dispatchers.IO)

override suspend fun inquiryMyPage(): Flow<InquiryMyPageResponse> = flow {
emit(
BitgoeulApiHandler<InquiryMyPageResponse>()
.httpRequest { userAPI.inquiryMyPage() }
.sendRequest()
)
}
}

0 comments on commit d27d8ed

Please sign in to comment.