-
Notifications
You must be signed in to change notification settings - Fork 2
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 #30 from eunjjungg/feat/setting
Feat/setting
- Loading branch information
Showing
16 changed files
with
775 additions
and
36 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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/shootit/greme/model/SettingServerModel.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.shootit.greme.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class UserCurrentInfo( | ||
@SerializedName("username") | ||
val username: String, | ||
@SerializedName("imageUrl") | ||
val imageUrl: String, | ||
@SerializedName("interestType") | ||
val interestType: List<Int>, | ||
@SerializedName("genderType") | ||
val genderType: Int, | ||
@SerializedName("area") | ||
val area: String, | ||
@SerializedName("purpose") | ||
val purpose: String, | ||
) | ||
|
||
data class UserInterestAndGenderInfo( | ||
@SerializedName("interestType") | ||
val interestType: List<Int>, | ||
@SerializedName("genderType") | ||
val genderType: Int | ||
) | ||
|
||
data class UserAreaAndPurposeInfo( | ||
@SerializedName("area") | ||
val area: String, | ||
@SerializedName("purpose") | ||
val purpose: String | ||
) |
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/com/shootit/greme/network/SettingInterface.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.shootit.greme.network | ||
|
||
import com.shootit.greme.model.UserAreaAndPurposeInfo | ||
import com.shootit.greme.model.UserCurrentInfo | ||
import com.shootit.greme.model.UserInterestAndGenderInfo | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
|
||
interface SettingInterface { | ||
|
||
// get current profile | ||
@GET("/user/profile") | ||
suspend fun getCurrentProfile() : Response<UserCurrentInfo> | ||
|
||
// set interest, gender | ||
@PATCH("/user/profile1") | ||
suspend fun setUserInterestAndGender(@Body data: UserInterestAndGenderInfo) : Response<Void> | ||
|
||
// set area, purpose | ||
@PATCH("/user/profile2") | ||
suspend fun setUserAreaAndPurpose(@Body data: UserAreaAndPurposeInfo) : Response<Void> | ||
} |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/shootit/greme/repository/SettingRepository.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,43 @@ | ||
package com.shootit.greme.repository | ||
|
||
import android.util.Log | ||
import com.shootit.greme.model.ChallengeActivityModel | ||
import com.shootit.greme.model.UserAreaAndPurposeInfo | ||
import com.shootit.greme.model.UserCurrentInfo | ||
import com.shootit.greme.model.UserInterestAndGenderInfo | ||
import com.shootit.greme.network.ConnectionObject | ||
|
||
class SettingRepository { | ||
|
||
companion object { | ||
private var instance: SettingRepository? = null | ||
|
||
fun getInstance(): SettingRepository? { | ||
if(instance == null) instance = SettingRepository() | ||
return instance | ||
} | ||
} | ||
|
||
suspend fun getCurrentProfile(): UserCurrentInfo? { | ||
val response = ConnectionObject | ||
.getSettingRetrofitService.getCurrentProfile() | ||
return if (response.isSuccessful) { | ||
response.body() as UserCurrentInfo | ||
} else { | ||
Log.d("challenge server err", response.errorBody()?.string().toString()) | ||
null | ||
} | ||
} | ||
|
||
suspend fun setUserInterestAndGender(userInterestAndGenderInfo: UserInterestAndGenderInfo): Boolean { | ||
val response = ConnectionObject | ||
.getSettingRetrofitService.setUserInterestAndGender(userInterestAndGenderInfo) | ||
return response.isSuccessful | ||
} | ||
|
||
suspend fun setUserAreaAndPurpose(userAreaAndPurposeInfo: UserAreaAndPurposeInfo): Boolean { | ||
val response = ConnectionObject | ||
.getSettingRetrofitService.setUserAreaAndPurpose(userAreaAndPurposeInfo) | ||
return response.isSuccessful | ||
} | ||
} |
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.