Commit f2c027bc authored by Varun Patil's avatar Varun Patil

PATCH FCM ID in place of deprecated GET API

parent 6334fb91
...@@ -46,6 +46,7 @@ import app.insti.SessionManager; ...@@ -46,6 +46,7 @@ import app.insti.SessionManager;
import app.insti.api.EmptyCallback; import app.insti.api.EmptyCallback;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
import app.insti.api.model.UserFCMPatchRequest;
import app.insti.data.Body; import app.insti.data.Body;
import app.insti.data.Event; import app.insti.data.Event;
import app.insti.data.Notification; import app.insti.data.Notification;
...@@ -401,9 +402,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -401,9 +402,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() { FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override @Override
public void onSuccess(InstanceIdResult instanceIdResult) { public void onSuccess(InstanceIdResult instanceIdResult) {
String fcmId = instanceIdResult.getToken(); final String fcmId = instanceIdResult.getToken();
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = getRetrofitInterface();
retrofitInterface.getUserMe(getSessionIDHeader(), fcmId).enqueue(new Callback<User>() {
retrofitInterface.patchUserMe(getSessionIDHeader(), new UserFCMPatchRequest(fcmId)).enqueue(new Callback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
......
...@@ -13,6 +13,7 @@ import app.insti.api.model.ImageUploadRequest; ...@@ -13,6 +13,7 @@ import app.insti.api.model.ImageUploadRequest;
import app.insti.api.model.ImageUploadResponse; import app.insti.api.model.ImageUploadResponse;
import app.insti.api.model.LoginResponse; import app.insti.api.model.LoginResponse;
import app.insti.api.model.NewsFeedResponse; import app.insti.api.model.NewsFeedResponse;
import app.insti.api.model.UserFCMPatchRequest;
import app.insti.data.Event; import app.insti.data.Event;
import app.insti.data.HostelMessMenu; import app.insti.data.HostelMessMenu;
import app.insti.data.NewsArticle; import app.insti.data.NewsArticle;
...@@ -25,6 +26,7 @@ import retrofit2.Call; ...@@ -25,6 +26,7 @@ import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Header; import retrofit2.http.Header;
import retrofit2.http.PATCH;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.Path; import retrofit2.http.Path;
import retrofit2.http.Query; import retrofit2.http.Query;
...@@ -78,8 +80,8 @@ public interface RetrofitInterface { ...@@ -78,8 +80,8 @@ public interface RetrofitInterface {
@GET("user-me") @GET("user-me")
Call<User> getUserMe(@Header("Cookie") String sessionID); Call<User> getUserMe(@Header("Cookie") String sessionID);
@GET("user-me") @PATCH("user-me")
Call<User> getUserMe(@Header("Cookie") String sessionID, @Query("fcm_id") String fcmId); Call<User> patchUserMe(@Header("Cookie") String sessionID, @Body UserFCMPatchRequest userFCMPatchRequest);
@GET("user-me/ues/{eventID}") @GET("user-me/ues/{eventID}")
Call<Void> updateUserEventStatus(@Header("Cookie") String sessionID, @Path("eventID") String eventID, @Query("status") int status); Call<Void> updateUserEventStatus(@Header("Cookie") String sessionID, @Path("eventID") String eventID, @Query("status") int status);
......
package app.insti.api.model;
import com.google.gson.annotations.SerializedName;
public class UserFCMPatchRequest {
@SerializedName("fcm_id")
private String userFCMId;
public UserFCMPatchRequest(String userFCMId) {
this.userFCMId = userFCMId;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment