Package net.gini.android.authorization
Class UserCenterAPICommunicator
- java.lang.Object
-
- net.gini.android.authorization.UserCenterAPICommunicator
-
public class UserCenterAPICommunicator extends java.lang.Object
The UserCenterAPIManager is responsible for communication with the Gini User Center API. This includes handling HTTP related error handling.
-
-
Constructor Summary
Constructors Constructor Description UserCenterAPICommunicator(com.android.volley.RequestQueue requestQueue, java.lang.String baseUrl, GiniApiType giniApiType, java.lang.String clientId, java.lang.String clientSecret, RetryPolicyFactory retryPolicyFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bolts.Task<android.net.Uri>
createUser(UserCredentials userCredentials, Session userCenterApiSession)
Creates a new Gini user.bolts.Task<java.lang.String>
getUserId(Session giniAPISession)
Returns the user id of the logged in user.bolts.Task<org.json.JSONObject>
getUserInfo(android.net.Uri userUri, Session userCenterApiSession)
bolts.Task<org.json.JSONObject>
loginClient()
Logs in this client to the Gini User Center API.bolts.Task<org.json.JSONObject>
loginUser(UserCredentials userCredentials)
Logs in a Gini user.bolts.Task<org.json.JSONObject>
updateEmail(java.lang.String userId, java.lang.String newEmail, java.lang.String oldEmail, Session userCenterApiSession)
Update the email of a user.
-
-
-
Constructor Detail
-
UserCenterAPICommunicator
public UserCenterAPICommunicator(com.android.volley.RequestQueue requestQueue, java.lang.String baseUrl, GiniApiType giniApiType, java.lang.String clientId, java.lang.String clientSecret, RetryPolicyFactory retryPolicyFactory)
-
-
Method Detail
-
loginClient
public bolts.Task<org.json.JSONObject> loginClient()
Logs in this client to the Gini User Center API. Uses the instance's client credentials to identify the client. Please note that this is used to login the client (in other words: the app) and not a Gini user. Please do not mix the different sessions.- Returns:
- A task which will resolve to a JSONObject representing the API's response, which is a valid access token for the Gini User Center API.
-
loginUser
public bolts.Task<org.json.JSONObject> loginUser(UserCredentials userCredentials)
Logs in a Gini user.- Parameters:
userCredentials
- The user's credentials.- Returns:
- A task which will resolve to a JSONObject representing the API's response, which is a valid access token for the Gini API.
-
createUser
public bolts.Task<android.net.Uri> createUser(UserCredentials userCredentials, Session userCenterApiSession) throws org.json.JSONException
Creates a new Gini user.- Parameters:
userCredentials
- The user's credentials.userCenterApiSession
- A valid session to do requests to the Gini User Center API.- Returns:
- A task which will resolve to a JSONObject representing the API's response, which is a user information.
- Throws:
org.json.JSONException
- If the user credentials can't be JSON serialized.
-
getUserInfo
public bolts.Task<org.json.JSONObject> getUserInfo(android.net.Uri userUri, Session userCenterApiSession)
-
getUserId
public bolts.Task<java.lang.String> getUserId(Session giniAPISession)
Returns the user id of the logged in user.- Parameters:
giniAPISession
- The session for the Gini API, which was returned when the user was logged in.- Returns:
- A task which will resolve to a String containing the user id.
-
updateEmail
public bolts.Task<org.json.JSONObject> updateEmail(java.lang.String userId, java.lang.String newEmail, java.lang.String oldEmail, Session userCenterApiSession) throws org.json.JSONException
Update the email of a user.- Parameters:
userId
- The user's id.newEmail
- A new email address.oldEmail
- The previous email address of the user.userCenterApiSession
- The session for the User Center API which was returned when the client was authenticated.- Returns:
- A task which will resolve to an empty JSONObject.
- Throws:
org.json.JSONException
- If the emails can't be JSON serialized.
-
-