generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature/#7 week04] #8
Open
0se0
wants to merge
15
commits into
develop
Choose a base branch
from
feature/#7-week04
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d5b8ded
#7 Chore: AndroidManifest.xml
0se0 9e8ad27
#7 Chore: Network dependencies
0se0 e3d474b
#7 Feature: User Service
0se0 b1af6ba
#7 Feature: ApiFactory
0se0 ba387b5
#7 Feature: ResponseDto
0se0 95d104a
#7 Feature: ResponseHobbyDto
0se0 3d55464
#7 Feature: RequestLoginDto
0se0 27b13a5
#7 Feature: RequestSignUpDto
0se0 c9c6566
#7 Feature: DataSource
0se0 d2cc362
#7 Feature: UserRepository
0se0 e0cc77e
#7 Update: WavveTextField
0se0 465839e
#7 Update: BottomNavigationBar
0se0 f8761a1
#7 Feature: Signup api
0se0 6b25e42
#7 Feature: Login api
0se0 44c44a5
#7 Feature: Mypage api
0se0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,51 @@ | ||
package org.sopt.and.data | ||
|
||
import android.content.Context | ||
import org.sopt.and.network.UserService | ||
import org.sopt.and.network.request.RequestLoginDto | ||
import org.sopt.and.network.request.RequestSignUpDto | ||
import org.sopt.and.network.response.ResponseDto | ||
import org.sopt.and.network.response.ResponseHobbyDto | ||
import retrofit2.Response | ||
|
||
class UserRepository(context: Context) { | ||
class UserRepository( | ||
private val userService: UserService, | ||
context: Context) { | ||
private val dataSource = DataSource(context.getSharedPreferences("UserPrefs", Context.MODE_PRIVATE)) | ||
|
||
fun saveUserInfo(email: String, password: String) { | ||
dataSource.saveUserInfo(email, password) | ||
suspend fun postSignUp(username: String, password: String, hobby: String): Response<ResponseDto> { | ||
val request = RequestSignUpDto(username, password, hobby) | ||
return userService.postSignUp(request) | ||
} | ||
|
||
fun getEmail(): String? { | ||
return dataSource.getEmail() | ||
suspend fun postLogin(username: String, password: String): Response<ResponseDto> { | ||
val request = RequestLoginDto(username, password) | ||
return userService.postLogin(request) | ||
} | ||
|
||
fun getPassword(): String? { | ||
return dataSource.getPassword() | ||
suspend fun getHobby(token: String): Response<ResponseHobbyDto> { | ||
return userService.getHobby(token) | ||
} | ||
|
||
fun saveUserInfo(username: String, password: String, hobby: String) { | ||
dataSource.saveUserInfo(username, password, hobby) | ||
} | ||
|
||
fun saveUserToken(token: String) { | ||
dataSource.saveUserToken(token) | ||
} | ||
|
||
fun getUsername(): String? = dataSource.getUsername() | ||
fun getPassword(): String? = dataSource.getPassword() | ||
fun getHobby(): String? = dataSource.getHobby() | ||
fun getToken(): String? = dataSource.getToken() | ||
|
||
fun isLoggedIn(): Boolean { | ||
return dataSource.isLoggedIn() | ||
} | ||
|
||
fun logout() { | ||
dataSource.clearUserCredentials() | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 간단하게 api 요청 코드를 작성할 수 있군요! 배워갑니당