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 aRequestUpdates
on the device. Only oneRequestUpdates
can 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. WhenRequestUpdates
are 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.Integer
getCommentCount(java.lang.String requestId)
Stores a comment count when this request was last readRequestUpdates
getRequestUpdates()
Gets the storedRequestUpdates
object, ornull
if there isn't one.long
getRequestUpdatesTimestamp()
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.boolean
hasStoredRequestUpdates()
Check to see whether there is anRequestUpdates
object in storage.void
markRequestAsRead(java.lang.String requestId)
Marks a request as read by removing it from the storedRequestUpdates
.void
setCommentCount(java.lang.String requestId, int commentCount)
Gets the comment count of when the request was last readvoid
setRequestUpdates(RequestUpdates requestUpdates)
Stores aRequestUpdates
in the storage, and records a timestamp of the event.void
storeRequestId(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 anRequestUpdates
object in storage.- Returns:
true
if there is anRequestUpdates
in storage,false
if 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
RequestUpdates
was stored, or -1 if there is no storedRequestUpdates
.
-
setRequestUpdates
void setRequestUpdates(RequestUpdates requestUpdates)
Stores aRequestUpdates
in the storage, and records a timestamp of the event.- Parameters:
requestUpdates
- theRequestUpdates
to 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 noRequestUpdates
stored, then this will have no effect.- Parameters:
requestId
- the ID of the request to remove fromRequestUpdates
-
getRequestUpdates
RequestUpdates getRequestUpdates()
Gets the storedRequestUpdates
object, ornull
if there isn't one.- Returns:
- the stored
RequestUpdates
, ornull
if there isn't one.
-
-