Skip to main content

ProductInventory

Class representing a product inventory.

Constructors​

new ProductInventory()​

new ProductInventory(): ProductInventory

Returns​

ProductInventory

Methods​

addProduct()​

addProduct(product): ProductDetails

Add a new product to the inventory.

Parameters​

ParameterTypeDescription
productProductDetailsThe product to be added.

Returns​

ProductDetails

The added product details.


getAllProducts()​

getAllProducts(): ProductDetails[]

Get all products in the inventory.

Returns​

ProductDetails[]

An array of all product details.


getProductById()​

getProductById(productId): undefined | ProductDetails

Get product details by ID.

Parameters​

ParameterTypeDescription
productIdstringThe ID of the product.

Returns​

undefined | ProductDetails

The product details with the specified ID.


getProductsByCategory()​

getProductsByCategory(category): ProductDetails[]

Get products by category.

Parameters​

ParameterTypeDescription
categoryProductCategoryThe product category.

Returns​

ProductDetails[]

An array of product details in the specified category.


removeProduct()​

removeProduct(productId): undefined | ProductDetails

Remove a product from the inventory.

Parameters​

ParameterTypeDescription
productIdstringThe ID of the product to be removed.

Returns​

undefined | ProductDetails

The removed product details.


updateProductDetails()​

updateProductDetails(productId, updatedDetails): undefined | ProductDetails

Update product details.

Parameters​

ParameterTypeDescription
productIdstringThe ID of the product to be updated.
updatedDetailsProductDetailsThe updated product details.

Returns​

undefined | ProductDetails

The updated product details.