Skip to content

Commit 862ff13

Browse files
committed
Add userId for register
1 parent c4e64bb commit 862ff13

File tree

4 files changed

+39
-35
lines changed

4 files changed

+39
-35
lines changed

.idea/codeStyles/Project.xml

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pluto-kotlin-client-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'maven-publish'
55

66
buildscript {
77
ext.versionCode = 11
8-
ext.versionName = '0.3.2'
8+
ext.versionName = '0.4'
99
}
1010

1111
android {

pluto-kotlin-client-sdk/src/main/java/com/mushare/plutosdk/Pluto+Login.kt

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import retrofit2.Call
55
import retrofit2.Callback
66
import retrofit2.Response
77

8-
fun Pluto.registerByEmail(
9-
address: String,
8+
fun Pluto.register(
9+
userId: String,
10+
mail: String,
1011
password: String,
1112
name: String,
1213
success: () -> Unit,
1314
error: ((PlutoError) -> Unit)? = null,
1415
handler: Pluto.PlutoRequestHandler? = null
1516
) {
16-
plutoService.registerWithEmail(RegisterWithEmailPostData(address, password, name, appId), getLanguage()).apply {
17+
val postData = RegisterPostData(userId, mail, password, name, appId)
18+
plutoService.register(postData, getLanguage()).apply {
1719
enqueue(object : Callback<PlutoResponse> {
1820
override fun onFailure(call: Call<PlutoResponse>, t: Throwable) {
1921
t.printStackTrace()
@@ -81,23 +83,30 @@ fun Pluto.loginWithAccount(
8183
error?.invoke(PlutoError.badRequest)
8284
return
8385
}
84-
plutoService.loginWithAccount(LoginWithAccountPostData(address, password, deviceId, appId)).apply {
85-
enqueue(object : Callback<PlutoResponseWithBody<LoginResponse>> {
86-
override fun onFailure(call: Call<PlutoResponseWithBody<LoginResponse>>, t: Throwable) {
87-
t.printStackTrace()
88-
error?.invoke(PlutoError.badRequest)
89-
}
86+
plutoService.loginWithAccount(LoginWithAccountPostData(address, password, deviceId, appId))
87+
.apply {
88+
enqueue(object : Callback<PlutoResponseWithBody<LoginResponse>> {
89+
override fun onFailure(
90+
call: Call<PlutoResponseWithBody<LoginResponse>>,
91+
t: Throwable
92+
) {
93+
t.printStackTrace()
94+
error?.invoke(PlutoError.badRequest)
95+
}
9096

91-
override fun onResponse(call: Call<PlutoResponseWithBody<LoginResponse>>, response: Response<PlutoResponseWithBody<LoginResponse>>) {
92-
val plutoResponse = response.body()
93-
if (plutoResponse != null) {
94-
handleLogin(plutoResponse, success, error)
95-
} else {
96-
error?.invoke(parseErrorCodeFromErrorBody(response.errorBody(), gson))
97+
override fun onResponse(
98+
call: Call<PlutoResponseWithBody<LoginResponse>>,
99+
response: Response<PlutoResponseWithBody<LoginResponse>>
100+
) {
101+
val plutoResponse = response.body()
102+
if (plutoResponse != null) {
103+
handleLogin(plutoResponse, success, error)
104+
} else {
105+
error?.invoke(parseErrorCodeFromErrorBody(response.errorBody(), gson))
106+
}
97107
}
98-
}
99-
})
100-
}.also {
108+
})
109+
}.also {
101110
handler?.setCall(it)
102111
}
103112
}
@@ -120,7 +129,10 @@ fun Pluto.loginWithGoogle(
120129
error?.invoke(PlutoError.badRequest)
121130
}
122131

123-
override fun onResponse(call: Call<PlutoResponseWithBody<LoginResponse>>, response: Response<PlutoResponseWithBody<LoginResponse>>) {
132+
override fun onResponse(
133+
call: Call<PlutoResponseWithBody<LoginResponse>>,
134+
response: Response<PlutoResponseWithBody<LoginResponse>>
135+
) {
124136
val plutoResponse = response.body()
125137
if (plutoResponse != null) {
126138
handleLogin(plutoResponse, success, error)

pluto-kotlin-client-sdk/src/main/java/com/mushare/plutosdk/PlutoService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ interface PlutoService {
1111
): Call<PlutoResponseWithBody<RefreshAuthResponse>>
1212

1313
@POST("v1/user/register")
14-
fun registerWithEmail(
15-
@Body body: RegisterWithEmailPostData,
14+
fun register(
15+
@Body body: RegisterPostData,
1616
@Header("Accept-Language") language: String
1717
): Call<PlutoResponse>
1818

@@ -55,7 +55,8 @@ class RefreshAuthPostData(
5555
@field:SerializedName("app_id") var appId: String
5656
)
5757

58-
class RegisterWithEmailPostData(
58+
class RegisterPostData(
59+
@field:SerializedName("user_id") var userId: String,
5960
@field:SerializedName("mail") var mail: String,
6061
@field:SerializedName("password") var password: String,
6162
@field:SerializedName("name") var name: String,

0 commit comments

Comments
 (0)