Class: productService

productService()

ProductManager Manages a collection of products, allowing addition, deletion, update, and retrieval of products.

Constructor

new productService()

Creates an instance of ProductManager.
Source:

Members

products

Properties:
Name Type Description
products Array Array to store products.
Source:

Methods

addProduct(product)

Adds a new product to the collection.
Parameters:
Name Type Description
product Object The product object to add.
Source:

deleteProduct(productId)

Deletes a product by its ID.
Parameters:
Name Type Description
productId number | string The ID of the product to delete.
Source:

getAvailableProducts() → {Array}

Retrieves all available products.
Source:
Returns:
An array of available products.
Type
Array

getProductById(productId) → {Object|null}

Retrieves a product by its ID.
Parameters:
Name Type Description
productId number | string The ID of the product to retrieve.
Source:
Returns:
The product object if found, otherwise null.
Type
Object | null

getProductsByCategory(categoryId) → {Array}

Retrieves products by a specific category ID.
Parameters:
Name Type Description
categoryId number | string The ID of the category.
Source:
Returns:
An array of products in the specified category.
Type
Array

getSpecialProducts() → {Array}

Retrieves all special products.
Source:
Returns:
An array of special products.
Type
Array

listProducts() → {Array}

Lists all products in the collection.
Source:
Returns:
An array of all products.
Type
Array

updateProduct(productId, updates) → {boolean}

Updates a product's information by its ID.
Parameters:
Name Type Description
productId number | string The ID of the product to update.
updates Object An object containing the updated properties.
Source:
Returns:
True if the update was successful, otherwise false.
Type
boolean