generated from AND-SOPT-ANDROID/and-sopt-android-template
-
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.
- Loading branch information
Showing
9 changed files
with
151 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.sopt.and.data.api | ||
|
||
import org.sopt.and.data.dto.RequestLoginData | ||
import org.sopt.and.data.dto.RequestUserRegistrationData | ||
import org.sopt.and.data.dto.ResponseLogin | ||
import org.sopt.and.data.dto.ResponseUserRegistration | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
|
||
interface UserRegistrationService { | ||
@POST("/user") | ||
suspend fun postUserRegistration( | ||
@Body userRequest: RequestUserRegistrationData | ||
): Response<ResponseUserRegistration> | ||
} | ||
|
||
interface LoginService { | ||
@POST("/login") | ||
suspend fun postLogin( | ||
@Body loginRequeset: RequestLoginData | ||
): Response<ResponseLogin> | ||
} | ||
|
||
|
||
|
15 changes: 0 additions & 15 deletions
15
app/src/main/java/org/sopt/and/data/api/UserRegistrationService.kt
This file was deleted.
Oops, something went wrong.
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
24 changes: 24 additions & 0 deletions
24
app/src/main/java/org/sopt/and/data/repository/Auth/LoginRepository.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 org.sopt.and.data.repository.Auth | ||
|
||
import org.sopt.and.data.api.LoginService | ||
import org.sopt.and.data.dto.RequestLoginData | ||
import org.sopt.and.data.dto.ResponseLogin | ||
import javax.inject.Inject | ||
|
||
class LoginRepository @Inject constructor( | ||
private val apiService: LoginService | ||
) { | ||
suspend fun postLogin(requestData: RequestLoginData): Result<ResponseLogin> { | ||
return try { | ||
val response = apiService.postLogin(requestData) | ||
if (response.isSuccessful) { | ||
Result.success(response.body()!!) | ||
} else { | ||
val errorCode = response.errorBody()?.string() ?: "알수없슴" | ||
Result.failure(Exception("Error code : ${response.code()}, 에러 코드 : $errorCode")) | ||
} | ||
} catch (e: Exception) { | ||
Result.failure(e) | ||
} | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
.../repository/UserRegistrationRepository.kt → ...sitory/Auth/UserRegistrationRepository.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
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