-
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.
✨ feature : Setting User Info API module 구현
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
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 | ||
|
||
interface SettingInterface { | ||
|
||
// get current profile | ||
@GET("/user/profile") | ||
fun getCurrentProfile() : Response<UserCurrentInfo> | ||
|
||
// set interest, gender | ||
@GET("/user/profile1") | ||
fun setUserInterestAndGender(@Body data: UserInterestAndGenderInfo) : Response<Void> | ||
|
||
// set area, purpose | ||
@GET("/user/profile2") | ||
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 | ||
} | ||
} |