|
16 | 16 | package com.pokegoapi.auth; |
17 | 17 |
|
18 | 18 | import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo; |
19 | | -import com.google.gson.Gson; |
20 | | -import com.google.gson.GsonBuilder; |
21 | 19 | import com.pokegoapi.exceptions.LoginFailedException; |
22 | 20 | import com.pokegoapi.util.Log; |
| 21 | +import com.squareup.moshi.Moshi; |
23 | 22 | import okhttp3.HttpUrl; |
24 | 23 | import okhttp3.OkHttpClient; |
25 | 24 | import okhttp3.Request; |
@@ -80,9 +79,9 @@ public AuthInfo login(String username, String password) throws LoginFailedExcept |
80 | 79 |
|
81 | 80 | Response response = client.newCall(request).execute(); |
82 | 81 |
|
83 | | - Gson gson = new GsonBuilder().create(); |
| 82 | + Moshi moshi = new Moshi.Builder().build(); |
84 | 83 |
|
85 | | - GoogleAuthJson googleAuth = gson.fromJson(response.body().string(), GoogleAuthJson.class); |
| 84 | + GoogleAuthJson googleAuth = moshi.adapter(GoogleAuthJson.class).fromJson(response.body().string()); |
86 | 85 | Log.d(TAG, "Get user to go to:" |
87 | 86 | + googleAuth.getVerificationUrl() |
88 | 87 | + " and enter code:" + googleAuth.getUserCode()); |
@@ -125,8 +124,8 @@ private GoogleAuthTokenJson poll(GoogleAuthJson json) throws URISyntaxException, |
125 | 124 |
|
126 | 125 | Response response = client.newCall(request).execute(); |
127 | 126 |
|
128 | | - Gson gson = new GsonBuilder().create(); |
129 | | - GoogleAuthTokenJson token = gson.fromJson(response.body().string(), GoogleAuthTokenJson.class); |
| 127 | + Moshi moshi = new Moshi.Builder().build(); |
| 128 | + GoogleAuthTokenJson token = moshi.adapter(GoogleAuthTokenJson.class).fromJson(response.body().string()); |
130 | 129 |
|
131 | 130 | if (token.getError() == null) { |
132 | 131 | return token; |
|
0 commit comments