Skip to content

Commit

Permalink
Add refresh token api
Browse files Browse the repository at this point in the history
  • Loading branch information
adonese committed Jul 24, 2022
1 parent 84638c7 commit ae022e0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/main/java/com/tuti/api/TutiApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ public void SignIn(SignInRequest credentials, ResponseCallable<SignInResponse> o
sendRequest(RequestMethods.POST, serverURL + Operations.SIGN_IN, credentials, SignInResponse.class, TutiResponse.class, onResponse, onError, null);
}

/**
* RefreshToken used to refresh an existing token to keep user's session valid.
* @param credentials
* @param onResponse
* @param onError
*/
public void RefreshToken(SignInRequest credentials, ResponseCallable<SignInResponse> onResponse, ErrorCallable<TutiResponse> onError) {
sendRequest(RequestMethods.POST, serverURL + Operations.REFRESH_TOKEN, credentials, SignInResponse.class, TutiResponse.class, onResponse, onError, null);
}


public void Signup(SignUpRequest signUpRequest, ResponseCallable<SignUpResponse> onResponse, ErrorCallable<TutiResponse> onError) {
sendRequest(RequestMethods.POST, serverURL + Operations.SIGN_UP, signUpRequest, SignUpResponse.class, TutiResponse.class, onResponse, onError, null);
}
Expand Down
13 changes: 13 additions & 0 deletions lib/src/main/java/com/tuti/api/authentication/SignInRequest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package com.tuti.api.authentication;

import com.google.gson.annotations.SerializedName;

public class SignInRequest {
private String username;
private String password;

public String getOldToken() {
return oldToken;
}

public void setOldToken(String oldToken) {
this.oldToken = oldToken;
}

@SerializedName("authorization")
private String oldToken;

public String getUsername() {
return username;
}
Expand Down
11 changes: 11 additions & 0 deletions lib/src/main/java/com/tuti/api/data/TutiResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ public class TutiResponse {
private String message;
private String code;

public String getAuthorization() {
return authorization;
}

public void setAuthorization(String authorization) {
this.authorization = authorization;
}

private String authorization;


public String getStatus() {
return status;
}
Expand Down

0 comments on commit ae022e0

Please sign in to comment.