dola vor 1 Jahr
Ursprung
Commit
7daf2a2a78

+ 6 - 5
app/src/main/java/com/sambath/kunkhmer/remote/LoginDataModel.kt

@@ -17,7 +17,7 @@ class LoginRequest(
 @JsonClass(generateAdapter = true)
 data class LoginResponse(
     @Json(name = "code")
-    val resultCode: String,
+    val resultCode: Int,
     @Json(name = "message")
     val message: LoginMessage,
     @Json(name = "data")
@@ -297,8 +297,8 @@ data class ResultSummary(
 data class LoginMessage(
     @Json(name = "code")
     val code: String,
-    @Json(name = "descriptions")
-    val description: String,
+    @Json(name = "description")
+    val description: String = "NA",
 )
 
 @JsonClass(generateAdapter = true)
@@ -379,10 +379,11 @@ data class LottoSet(
 
 @JsonClass(generateAdapter = true)
 data class User(
-    @Json(name = "user_name")
-    val userName: String,
     @Json(name = "_id")
     val id: String,
+    @Json(name = "user_name")
+    val userName: String,
+
 
 //    @Json(name = "role")
 //    val roles: String,

+ 1 - 1
app/src/main/java/com/sambath/kunkhmer/remote/service/ApiService.kt

@@ -6,7 +6,7 @@ import retrofit2.http.*
 
 interface ApiService {
 
-    @POST("/v1/user/login")
+    @POST("/v1/users/login")
     @Headers("No-Authentication: true")
     fun login(@Body loginRequest: LoginRequest): Single<LoginResponse>
 

+ 1 - 1
app/src/main/java/com/sambath/kunkhmer/screen/login/LoginViewModel.kt

@@ -29,7 +29,7 @@ class LoginViewModel(val apiService: ApiService, val prefHelper: PrefHelper) : B
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe({
                     Log.d("login", it.toString())
-                    if (it.resultCode == "1") {
+                    if (it.resultCode == 1) {
                         _state.value = prev().copy(isProgress = false, isLoginSuccess = true)
                         prefHelper.setUserToken(it.data?.token ?: "")
                         prefHelper.setChannelType(1)