Skip to content

Commit 159ec65

Browse files
committed
Refactor SignInResponse to Immutables. Add UserProfileChangeResponse because the object returned from REST API is not a SignInResponse (no refresh token).
1 parent bfcc843 commit 159ec65

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed
Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
package com.anotherdev.firebase.auth;
22

3-
@SuppressWarnings("WeakerAccess")
4-
public class SignInResponse {
3+
import androidx.annotation.Nullable;
54

6-
String idToken;
7-
String email;
8-
String refreshToken;
9-
String expiresIn;
10-
String localId;
5+
import com.google.gson.annotations.SerializedName;
116

7+
import org.immutables.gson.Gson;
8+
import org.immutables.value.Value;
129

13-
public String getIdToken() {
14-
return idToken;
15-
}
10+
@Value.Immutable
11+
@Value.Style(strictBuilder = true)
12+
@Gson.TypeAdapters
13+
public interface SignInResponse {
1614

17-
public String getEmail() {
18-
return email;
19-
}
15+
@SerializedName("idToken")
16+
String getIdToken();
2017

21-
public String getRefreshToken() {
22-
return refreshToken;
23-
}
18+
@Nullable
19+
@SerializedName("email")
20+
String getEmail();
21+
22+
@SerializedName("refreshToken")
23+
String getRefreshToken();
24+
25+
@SerializedName("expiresIn")
26+
String getExpiresIn();
27+
28+
@SerializedName("localId")
29+
String getLocalId();
2430

25-
public String getExpiresIn() {
26-
return expiresIn;
27-
}
2831

29-
public String getLocalId() {
30-
return localId;
32+
static ImmutableSignInResponse.Builder builder() {
33+
return ImmutableSignInResponse.builder();
3134
}
3235
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.anotherdev.firebase.auth;
2+
3+
@SuppressWarnings("WeakerAccess")
4+
public class UserProfileChangeResponse {
5+
6+
String localId;
7+
String email;
8+
String displayName;
9+
10+
11+
public String getLocalId() {
12+
return localId;
13+
}
14+
15+
public String getEmail() {
16+
return email;
17+
}
18+
19+
public String getDisplayName() {
20+
return displayName;
21+
}
22+
}

firebase-auth-rest/core/src/main/java/com/anotherdev/firebase/auth/rest/api/IdentityToolkitApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.anotherdev.firebase.auth.SignInResponse;
44
import com.anotherdev.firebase.auth.UserProfileChangeRequest;
5+
import com.anotherdev.firebase.auth.UserProfileChangeResponse;
56
import com.anotherdev.firebase.auth.rest.api.model.IdTokenRequest;
67
import com.anotherdev.firebase.auth.rest.api.model.SignInRequest;
78
import com.anotherdev.firebase.auth.rest.api.model.SignInWithCustomTokenRequest;
@@ -39,7 +40,7 @@ public interface IdentityToolkitApi {
3940
Single<JsonObject> getAccounts(@Body IdTokenRequest request);
4041

4142
@POST("v1/accounts:update")
42-
Single<SignInResponse> updateProfile(@Body UserProfileChangeRequest request);
43+
Single<UserProfileChangeResponse> updateProfile(@Body UserProfileChangeRequest request);
4344

4445
@POST("v1/accounts:update")
4546
Single<SignInResponse> updatePassword(@Body UserPasswordChangeRequest request);

0 commit comments

Comments
 (0)