Package dev.getelements.elements.sdk.dao
Interface InventoryItemDao
- All Known Implementing Classes:
MongoInventoryItemDao
public interface InventoryItemDao
Created by davidjbrooks on 11/11/18.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionadjustQuantityForItem
(User user, String itemNameOrId, int priority, int quantityDelta) Convenience method which allows for invokingadjustQuantityForItem(String, int)
without needing to create the item first.adjustQuantityForItem
(String inventoryItemId, int quantityDelta) Adjusts the quantity of the supplied item and user.createInventoryItem
(InventoryItem inventoryItem) Creates an inventory item.void
deleteInventoryItem
(String inventoryItemId) Deletes an inventory item.getInventoryItem
(String inventoryItemId) Gets the specific inventory item with the id, or throws aNotFoundException
if the inventory item can't be found.getInventoryItemByItemNameOrId
(User user, String itemNameOrId, int priority) Gets the primary (single) inventory item for with the item name or id, or throws aNotFoundException
if the item or inventory item can't be found.getInventoryItems
(int offset, int count) Gets inventory items specifying the offset and the count.getInventoryItems
(int offset, int count, User user, String search) Gets inventory items specifying the offset and the count, specifying a search filter.getUserPublicInventoryItems
(int offset, int count, User user) Gets inventory items for specified user, which are flagged publicVisiblesetQuantityForItem
(User user, String itemNameOrId, int priority, int quantity) Adjusts the quantity of the supplied item and user.updateInventoryItem
(String inventoryItemId, int quantity) Updates the specific inventory item with the id, or throws aNotFoundException
if the inventory item can't be found.
-
Field Details
-
SIMPLE_PRIORITY
static final int SIMPLE_PRIORITYThe priority for use by theInventoryItemDao
- See Also:
-
-
Method Details
-
getInventoryItem
Gets the specific inventory item with the id, or throws aNotFoundException
if the inventory item can't be found.- Returns:
- the
InventoryItem
that was requested, never null
-
getInventoryItems
Gets inventory items specifying the offset and the count.- Parameters:
offset
- the offsetcount
- the count- Returns:
- a
Pagination
ofInventoryItem
objects.
-
getUserPublicInventoryItems
Gets inventory items for specified user, which are flagged publicVisible- Parameters:
offset
- the offsetcount
- the count- Returns:
- a
Pagination
ofInventoryItem
objects.
-
getInventoryItems
Gets inventory items specifying the offset and the count, specifying a search filter.- Parameters:
offset
- the offsetcount
- the countuser
- theUser
that owns the itemssearch
- a query to filter the results- Returns:
- a
Pagination
ofInventoryItem
objects.
-
getInventoryItemByItemNameOrId
Gets the primary (single) inventory item for with the item name or id, or throws aNotFoundException
if the item or inventory item can't be found.- Parameters:
user
- theUser
that owns the itemitemNameOrId
- an item name or ID to limit the resultspriority
-- Returns:
- the
InventoryItem
that was requested, never null
-
updateInventoryItem
Updates the specific inventory item with the id, or throws aNotFoundException
if the inventory item can't be found. TheInventoryItem.getId()
is used to key the inventory item being updated.- Parameters:
inventoryItemId
-quantity
-- Returns:
- the
InventoryItem
as it was written into the database - Throws:
InvalidDataException
- if the state of the passed in InventoryItem is invalid
-
createInventoryItem
Creates an inventory item. The value ofInventoryItem.getId()
will be ignored.- Returns:
- the
InventoryItem
as it was written into the database - Throws:
InvalidDataException
- if the state of the passed in InventoryItem is invalidDuplicateException
- if the passed in Item has a name that already exists
-
setQuantityForItem
Adjusts the quantity of the supplied item and user.- Parameters:
user
- theUser
for which to adjust the item.itemNameOrId
- theItem.getName()
orItem.getId()
priority
- the priority of the item slotquantity
- the amount to adjust the quantity by- Returns:
- the updated
InventoryItem
-
adjustQuantityForItem
Adjusts the quantity of the supplied item and user.- Parameters:
inventoryItemId
- theItem.getName()
orItem.getId()
quantityDelta
- the amount to adjust the quantity by- Returns:
- the updated
InventoryItem
-
adjustQuantityForItem
InventoryItem adjustQuantityForItem(User user, String itemNameOrId, int priority, int quantityDelta) Convenience method which allows for invokingadjustQuantityForItem(String, int)
without needing to create the item first.- Parameters:
user
- the user object to adjustitemNameOrId
- the item name or identifierpriority
- the priority slotquantityDelta
- the quantity delta- Returns:
- the updated
InventoryItem
-
deleteInventoryItem
Deletes an inventory item.- Parameters:
inventoryItemId
- theInventoryItem
's id.
-