API¶
-
class
API
¶ This API serves as the interface between the rest of the app and the CultureMesh servers. When another part of the app needs to request information, it calls API methods to obtain it. Similarly, API methods should be used to store, send, and update information. The API then handles requesting it from the CultureMesh servers.
Fields¶
API_URL_BASE¶
CURRENT_USER¶
FEED_ITEM_COUNT_SIZE¶
-
static final String
FEED_ITEM_COUNT_SIZE
¶ The number of items (e.g.
org.codethechange.culturemesh.models.Post
s orEvent
s to fetch with each paginated request
LOGIN_TOKEN¶
-
static final String
LOGIN_TOKEN
¶ Settings identifier for the currently cached login token for the user. May be missing or expired. Expiration is tracked using
API.TOKEN_REFRESH
.
SELECTED_NETWORK¶
SELECTED_USER¶
SETTINGS_IDENTIFIER¶
TOKEN_REFRESH¶
-
static final int
TOKEN_REFRESH
¶ Number of milliseconds to use a login token before refreshing it. Note that this is not how long the token is valid, just how often to refresh it. Refresh time must be shorter than the validity time.
See also:
API.LOGIN_TOKEN
TOKEN_RETRIEVED¶
-
static final String
TOKEN_RETRIEVED
¶ Settings identifier for when the current login token was retrieved. Stored as the number of milliseconds since the epoch.
See also:
API.LOGIN_TOKEN
Methods¶
genBasicAuth¶
-
static String
genBasicAuth
(String email, String password)¶ Generate from a username/email and password the string to put in the header of a request as the value of the
Authorization
token in order to perform Basic Authentication. For example:headers.put("Authorization", genBasicAuth(email, password))
. A login token can be used if it is passed as theemail
, in which case thepassword
is ignored by the server.Parameters: - email – Email or username of account to login as; can also be a login token
- password – Password to login with
Returns: Value that should be passed in the header as the value of
Authorization
genBasicAuth¶
-
static String
genBasicAuth
(String token)¶ Generate from a login token the string to put in the header of a request as the value of the
Authorization
token in order to perform Basic Authentication. For example:headers.put("Authorization", genBasicAuth(token))
.Parameters: - token – Login token to authenticate to server
Returns: Value that should be passed in the header as the value of
Authorization