Package com.zendesk.sdk.storage
Interface RequestStorage
-
- All Superinterfaces:
- SdkStorage.UserStorage
public interface RequestStorage extends SdkStorage.UserStorage
Provides storage of Request IDs and Comment last read timestamps. Also defines the behaviour for storing, querying, and updating aRequestUpdateson the device. Only oneRequestUpdatescan be stored at a time. This was implemented to facilitate a time-based cache approach to querying for unread messages on a user's requests. WhenRequestUpdatesare stored usingRequestStorage.setRequestUpdates(RequestUpdates), the current timestamp is also recorded. This timestamp can be retrieved usingRequestStorage.getRequestUpdatesTimestamp(). The @linkRequestStorage.markRequestAsRead(String)method is called by the UI when a request is viewed, marking that request as "read" and removing it from the storedRequestUpdates.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description java.lang.IntegergetCommentCount(java.lang.String requestId)Stores a comment count when this request was last readRequestUpdatesgetRequestUpdates()Gets the storedRequestUpdatesobject, ornullif there isn't one.longgetRequestUpdatesTimestamp()Gets the timestamp in milliseconds for when the storedRequestUpdates(if any) was stored.java.util.List<java.lang.String>getStoredRequestIds()Get the request IDs stored on the device.booleanhasStoredRequestUpdates()Check to see whether there is anRequestUpdatesobject in storage.voidmarkRequestAsRead(java.lang.String requestId)Marks a request as read by removing it from the storedRequestUpdates.voidsetCommentCount(java.lang.String requestId, int commentCount)Gets the comment count of when the request was last readvoidsetRequestUpdates(RequestUpdates requestUpdates)Stores aRequestUpdatesin the storage, and records a timestamp of the event.voidstoreRequestId(java.lang.String requestId)Stores a request ID on the device-
Methods inherited from interface com.zendesk.sdk.storage.SdkStorage.UserStorage
clearUserData, getCacheKey
-
-
-
-
Method Detail
-
getStoredRequestIds
java.util.List<java.lang.String> getStoredRequestIds()
Get the request IDs stored on the device.- Returns:
- The list of request IDs stored on the device. If none are present or if storage was not initialised correctly it will return an empty list.
-
storeRequestId
void storeRequestId(java.lang.String requestId)
Stores a request ID on the device- Parameters:
requestId- The request ID to store on the device.
-
setCommentCount
void setCommentCount(java.lang.String requestId, int commentCount)Gets the comment count of when the request was last read- Parameters:
requestId- The request idcommentCount- The comment count when the request was last read
-
getCommentCount
java.lang.Integer getCommentCount(java.lang.String requestId)
Stores a comment count when this request was last read- Parameters:
requestId- The id of the request- Returns:
- The timestamp that the request was last read
-
hasStoredRequestUpdates
boolean hasStoredRequestUpdates()
Check to see whether there is anRequestUpdatesobject in storage.- Returns:
trueif there is anRequestUpdatesin storage,falseif not
-
getRequestUpdatesTimestamp
long getRequestUpdatesTimestamp()
Gets the timestamp in milliseconds for when the storedRequestUpdates(if any) was stored.- Returns:
- the timestamp in milliseconds for when the stored
RequestUpdateswas stored, or -1 if there is no storedRequestUpdates.
-
setRequestUpdates
void setRequestUpdates(RequestUpdates requestUpdates)
Stores aRequestUpdatesin the storage, and records a timestamp of the event.- Parameters:
requestUpdates- theRequestUpdatesto store.
-
markRequestAsRead
void markRequestAsRead(java.lang.String requestId)
Marks a request as read by removing it from the storedRequestUpdates. If the request ID is not already a key inRequestUpdates.getRequestsWithUpdates(), or there is noRequestUpdatesstored, then this will have no effect.- Parameters:
requestId- the ID of the request to remove fromRequestUpdates
-
getRequestUpdates
RequestUpdates getRequestUpdates()
Gets the storedRequestUpdatesobject, ornullif there isn't one.- Returns:
- the stored
RequestUpdates, ornullif there isn't one.
-
-