The InventoryManager
is a public interface that contains all of the Inventory system functionality. Each method described below returns an integer status code. All successful return codes should be greater than or equal to zero, all failure codes should be less than zero. By default, the codes are:
Status Code | Description |
---|---|
| There was no problem performing the operation. |
| There was an unknown/generic problem performing the operation. |
| The operation could not be completed because there were not enough of the items in the inventory system. |
| The operation could not be completed because a specified item could not be found in the inventory system. |
The methods that effect a change on the backend system return an integer status code. Methods that inspect the backend system return the answer to the query. The status return codes listed above and any implementer-defined status codes usually should be used to convey a definitive answer concerning a method’s success.
When a method succeeds, an answer is prepared for return from the method. When a method fails, you can either return a failure code or throw an exception. In general, a method should return a failure code only if it is determined that the operation will not succeed. For example:
If it is determined that five items cannot be purchased because there are only 4 items in the store, the implementer should return INVENTORY_STATUS_INSUFFICIENT_SUPPLY. This indicates that the program determined that the purchase method could not succeed.
If a network error caused a connection to time out while the
InventoryManager
was querying the backend system, an exception should be thrown because the program was unable to determine whether the operation would succeed.
The following table lists all the methods provided by the InventoryManager
interface. In methods below, the pID
parameter would usually be a SKU ID.
Methods | Exception thrown |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For more information, see the Examples of Using the Inventory Manager section.