-
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.
Merge pull request #54 from meongmory/feature/api-register-family
[feature/api-register-family] 펫 다이어리 생성 API 기본 틀 구현
- Loading branch information
Showing
21 changed files
with
323 additions
and
10 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
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
11 changes: 11 additions & 0 deletions
11
data/src/main/java/com/meongmoryteam/data/datasource/family/FamilyDataSource.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,11 @@ | ||
package com.meongmoryteam.data.datasource.family | ||
|
||
import com.meongmoryteam.data.model.request.family.RegisterFamilyCodeRequest | ||
import com.meongmoryteam.data.model.request.family.RegisterFamilyNameRequest | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyCodeRes | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyNameRes | ||
|
||
interface FamilyDataSource { | ||
suspend fun registerFamilyWithName(registerFamilyNameReq: RegisterFamilyNameRequest): Result<PostRegisterFamilyNameRes> | ||
suspend fun registerFamilyWithCode(familyId: String, registerFamilyCodeReq: RegisterFamilyCodeRequest): Result<PostRegisterFamilyCodeRes> | ||
} |
24 changes: 24 additions & 0 deletions
24
data/src/main/java/com/meongmoryteam/data/datasource/family/FamilyDataSourceImpl.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,24 @@ | ||
package com.meongmoryteam.data.datasource.family | ||
|
||
import com.meongmoryteam.data.model.request.family.RegisterFamilyCodeRequest | ||
import com.meongmoryteam.data.model.request.family.RegisterFamilyNameRequest | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyCodeRes | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyNameRes | ||
import com.meongmoryteam.data.service.family.FamilyApi | ||
import javax.inject.Inject | ||
|
||
class FamilyDataSourceImpl @Inject constructor( | ||
private val familyApi: FamilyApi | ||
) : FamilyDataSource { | ||
override suspend fun registerFamilyWithName(registerFamilyNameReq: RegisterFamilyNameRequest): Result<PostRegisterFamilyNameRes> { | ||
return runCatching { familyApi.postRegisterFamilyName(registerFamilyNameReq) } | ||
} | ||
|
||
override suspend fun registerFamilyWithCode( | ||
familyId: String, | ||
registerFamilyCodeReq: RegisterFamilyCodeRequest | ||
): Result<PostRegisterFamilyCodeRes> { | ||
return runCatching { familyApi.postRegisterFamilyCode(familyId, registerFamilyCodeReq) } | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/meongmoryteam/data/model/request/family/RegisterFamilyCodeRequest.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.meongmoryteam.data.model.request.family | ||
|
||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyCodeRequestEntity | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RegisterFamilyCodeRequest( | ||
val familyCode: String | ||
) | ||
|
||
fun RegisterFamilyCodeRequestEntity.toRegisterWithCodeRequest(): RegisterFamilyCodeRequest { | ||
return RegisterFamilyCodeRequest( | ||
familyCode = this.familyCode | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/meongmoryteam/data/model/request/family/RegisterFamilyNameRequest.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.meongmoryteam.data.model.request.family | ||
|
||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyCodeRequestEntity | ||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyNameRequestEntity | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RegisterFamilyNameRequest( | ||
val name: String | ||
) | ||
|
||
fun RegisterFamilyNameRequestEntity.toRegisterWithNameRequest(): RegisterFamilyNameRequest { | ||
return RegisterFamilyNameRequest( | ||
name = this.name) | ||
} |
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/meongmoryteam/data/model/response/family/PostRegisterFamilyCodeRes.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,22 @@ | ||
package com.meongmoryteam.data.model.response.family | ||
|
||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyCodeEntity | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PostRegisterFamilyCodeRes( | ||
val code: String, | ||
val data: String, | ||
val message: String, | ||
val status: Int, | ||
) | ||
|
||
fun PostRegisterFamilyCodeRes.toPostRegisterFamilyCodeEntity(): PostRegisterFamilyCodeEntity { | ||
return PostRegisterFamilyCodeEntity( | ||
code = this.code, | ||
data = this.data, | ||
message = this.message, | ||
status = this.status, | ||
) | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
data/src/main/java/com/meongmoryteam/data/model/response/family/PostRegisterFamilyNameRes.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,21 @@ | ||
package com.meongmoryteam.data.model.response.family | ||
|
||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyNameEntity | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PostRegisterFamilyNameRes( | ||
val code: String, | ||
val data: String, | ||
val message: String, | ||
val status: Int, | ||
) | ||
|
||
fun PostRegisterFamilyNameRes.toPostRegisterFamilyNameEntity(): PostRegisterFamilyNameEntity { | ||
return PostRegisterFamilyNameEntity( | ||
code = this.code, | ||
data = this.data, | ||
message = this.message, | ||
status = this.status, | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
data/src/main/java/com/meongmoryteam/data/repository/family/FamilyRepositoryImpl.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,32 @@ | ||
package com.meongmoryteam.data.repository.family | ||
|
||
import com.meongmoryteam.data.datasource.family.FamilyDataSource | ||
import com.meongmoryteam.data.model.request.family.toRegisterWithCodeRequest | ||
import com.meongmoryteam.data.model.request.family.toRegisterWithNameRequest | ||
import com.meongmoryteam.data.model.response.family.toPostRegisterFamilyCodeEntity | ||
import com.meongmoryteam.data.model.response.family.toPostRegisterFamilyNameEntity | ||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyCodeRequestEntity | ||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyNameRequestEntity | ||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyCodeEntity | ||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyNameEntity | ||
import com.meongmoryteam.domain.repository.family.FamilyRepository | ||
import javax.inject.Inject | ||
|
||
class FamilyRepositoryImpl @Inject constructor( | ||
private val familyDataSource: FamilyDataSource | ||
) : FamilyRepository { | ||
override suspend fun postRegisterWithName(registerFamilyNameRequestEntity: RegisterFamilyNameRequestEntity): Result<PostRegisterFamilyNameEntity> { | ||
return familyDataSource.registerFamilyWithName(registerFamilyNameRequestEntity.toRegisterWithNameRequest()) | ||
.map { it.toPostRegisterFamilyNameEntity() } | ||
} | ||
|
||
override suspend fun postRegisterWithCode( | ||
familyId: String, | ||
registerFamilyCodeRequestEntity: RegisterFamilyCodeRequestEntity | ||
): Result<PostRegisterFamilyCodeEntity> { | ||
return familyDataSource.registerFamilyWithCode( | ||
familyId, | ||
registerFamilyCodeRequestEntity.toRegisterWithCodeRequest() | ||
).map { it.toPostRegisterFamilyCodeEntity() } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
data/src/main/java/com/meongmoryteam/data/service/family/FamilyApi.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,22 @@ | ||
package com.meongmoryteam.data.service.family | ||
|
||
import com.meongmoryteam.data.model.request.family.RegisterFamilyCodeRequest | ||
import com.meongmoryteam.data.model.request.family.RegisterFamilyNameRequest | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyCodeRes | ||
import com.meongmoryteam.data.model.response.family.PostRegisterFamilyNameRes | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface FamilyApi { | ||
@POST("families") | ||
suspend fun postRegisterFamilyName( | ||
@Body registerFamilyNameRequest: RegisterFamilyNameRequest | ||
): PostRegisterFamilyNameRes | ||
|
||
@POST("families/{familyId}/invite") | ||
suspend fun postRegisterFamilyCode( | ||
@Path(value = "familyId") familyId: String, | ||
@Body registerFamilyCodeRequest: RegisterFamilyCodeRequest | ||
): PostRegisterFamilyCodeRes | ||
} |
5 changes: 5 additions & 0 deletions
5
...ain/java/com/meongmoryteam/domain/model/reqeust/family/RegisterFamilyCodeRequestEntity.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,5 @@ | ||
package com.meongmoryteam.domain.model.reqeust.family | ||
|
||
data class RegisterFamilyCodeRequestEntity ( | ||
val familyCode: String | ||
) |
5 changes: 5 additions & 0 deletions
5
...ain/java/com/meongmoryteam/domain/model/reqeust/family/RegisterFamilyNameRequestEntity.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,5 @@ | ||
package com.meongmoryteam.domain.model.reqeust.family | ||
|
||
data class RegisterFamilyNameRequestEntity( | ||
val name: String | ||
) |
8 changes: 8 additions & 0 deletions
8
.../main/java/com/meongmoryteam/domain/model/response/family/PostRegisterFamilyCodeEntity.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.meongmoryteam.domain.model.response.family | ||
|
||
data class PostRegisterFamilyCodeEntity( | ||
val code: String, | ||
val data: String, | ||
val message: String, | ||
val status: Int, | ||
) |
8 changes: 8 additions & 0 deletions
8
.../main/java/com/meongmoryteam/domain/model/response/family/PostRegisterFamilyNameEntity.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.meongmoryteam.domain.model.response.family | ||
|
||
data class PostRegisterFamilyNameEntity( | ||
val code: String, | ||
val data: String, | ||
val message: String, | ||
val status: Int, | ||
) |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/meongmoryteam/domain/repository/family/FamilyRepository.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,14 @@ | ||
package com.meongmoryteam.domain.repository.family | ||
|
||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyCodeRequestEntity | ||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyNameRequestEntity | ||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyCodeEntity | ||
import com.meongmoryteam.domain.model.response.family.PostRegisterFamilyNameEntity | ||
|
||
interface FamilyRepository { | ||
suspend fun postRegisterWithName(registerFamilyNameRequestEntity: RegisterFamilyNameRequestEntity): Result<PostRegisterFamilyNameEntity> | ||
suspend fun postRegisterWithCode( | ||
familyId: String, | ||
registerFamilyCodeRequestEntity: RegisterFamilyCodeRequestEntity | ||
): Result<PostRegisterFamilyCodeEntity> | ||
} |
14 changes: 14 additions & 0 deletions
14
...in/src/main/java/com/meongmoryteam/domain/usecase/family/PostRegisterFamilyCodeUseCase.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,14 @@ | ||
package com.meongmoryteam.domain.usecase.family | ||
|
||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyCodeRequestEntity | ||
import com.meongmoryteam.domain.repository.family.FamilyRepository | ||
import javax.inject.Inject | ||
|
||
class PostRegisterFamilyCodeUseCase @Inject constructor( | ||
private val familyRepository: FamilyRepository | ||
) { | ||
suspend operator fun invoke( | ||
familyId: String, | ||
registerFamilyCodeRequestEntity: RegisterFamilyCodeRequestEntity | ||
) = familyRepository.postRegisterWithCode(familyId, registerFamilyCodeRequestEntity) | ||
} |
12 changes: 12 additions & 0 deletions
12
...in/src/main/java/com/meongmoryteam/domain/usecase/family/PostRegisterFamilyNameUseCase.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.meongmoryteam.domain.usecase.family | ||
|
||
import com.meongmoryteam.domain.model.reqeust.family.RegisterFamilyNameRequestEntity | ||
import com.meongmoryteam.domain.repository.family.FamilyRepository | ||
import javax.inject.Inject | ||
|
||
class PostRegisterFamilyNameUseCase @Inject constructor( | ||
private val familyRepository: FamilyRepository | ||
) { | ||
suspend operator fun invoke(registerFamilyNameRequestEntity: RegisterFamilyNameRequestEntity) = | ||
familyRepository.postRegisterWithName(registerFamilyNameRequestEntity) | ||
} |
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
Oops, something went wrong.