Package dev.getelements.elements.sdk.dao
Interface RewardIssuanceDao
- All Known Implementing Classes:
MongoRewardIssuanceDao
public interface RewardIssuanceDao
Manipulates the instances of
RewardIssuance, including the operations to ensure tha the rewards are properly
inserted into the database and credited to a user's inventory in an atomic way.-
Method Summary
Modifier and TypeMethodDescriptionvoidDeltes aRewardIssuancewith the supplied id.getOrCreateRewardIssuance(RewardIssuance rewardIssuance) Gets or creates an instance ofRewardIssuance.getRewardIssuance(User user, String context) Fetches the reward issuance for the given user and context.Fetches the instance ofRewardIssuance.default Pagination<RewardIssuance> getRewardIssuances(User user, int offset, int count) Gets all reward issuances for a given user.getRewardIssuances(User user, int offset, int count, List<RewardIssuance.State> states, List<String> tags) Gets all reward issuances for the given user, optionally specifying the allowableRewardIssuance.States and/or .redeem(RewardIssuance rewardIssuance) Redeems theRewardIssuance.updateExpirationTimestamp(RewardIssuance rewardIssuance, long expirationTimestamp) Updates the given issuance to a new expiration timestamp.
-
Method Details
-
getRewardIssuance
Fetches the instance ofRewardIssuance.- Parameters:
id- the id of theRewardIssuanceas specified byRewardIssuance.getId().- Returns:
- the reward issuance
-
getRewardIssuance
Fetches the reward issuance for the given user and context.- Parameters:
user-context-- Returns:
- the reward issuance
-
getRewardIssuances
Gets all reward issuances for a given user.- Parameters:
user- the useroffset- the offsetcount- the count- Returns:
- a
PaginationofRewardIssuance
-
getRewardIssuances
Pagination<RewardIssuance> getRewardIssuances(User user, int offset, int count, List<RewardIssuance.State> states, List<String> tags) Gets all reward issuances for the given user, optionally specifying the allowableRewardIssuance.States and/or .- Parameters:
offset- the offsetcount- the countstates- if non-empty, will include the requested states in the query. Otherwise states will be ignored in the query.tags- if non-empty, will include the requested set of tags in the query. Otherwise tags will be ignored in the query.- Returns:
- a
PaginationofRewardIssuance
-
getOrCreateRewardIssuance
Gets or creates an instance ofRewardIssuance. If created, the issuance will be set to a state ofRewardIssuance.State.ISSUED.- Parameters:
rewardIssuance- the instance ofRewardIssuanceto create- Returns:
- the
RewardIssuanceinstance
-
updateExpirationTimestamp
Updates the given issuance to a new expiration timestamp. If a negative value is provided, the value will be unset in the db.- Parameters:
rewardIssuance- the issuance to updateexpirationTimestamp- the expiration, in ms- Returns:
-
redeem
Redeems theRewardIssuance. Once redeemed, the reward will be placed into the associated user's inventory. This method will select anInventoryItemwith a priority of value zero to accept theRewardIssuance.Additionally this method must guarantee that applying the same
RewardIssuancemultiple times will only credit the user once.- Parameters:
rewardIssuance- the reward to redeem- Returns:
- the
InventoryItemto which thisRewardIssuancewas applied.
-
delete
Deltes aRewardIssuancewith the supplied id.- Parameters:
id- the id
-