Constructor
new CategoryService()
Creates a new CategoryService instance.
- Source:
Methods
addCategory(category)
Adds a new category to the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
category |
Category | The category to add. |
- Source:
deleteCategory(categoryId)
Deletes a category from the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
categoryId |
string | The ID of the category to delete. |
- Source:
getAvailableCategories() → {Array.<Category>}
Retrieves all available categories.
- Source:
Returns:
Array of available categories.
- Type
- Array.<Category>
getCategoryById(categoryId) → {Category|null}
Retrieves a category by its ID.
Parameters:
| Name | Type | Description |
|---|---|---|
categoryId |
string | The ID of the category to find. |
- Source:
Returns:
The found category or null if not found.
- Type
- Category | null
getRecommendedCategories() → {Array.<Category>}
Retrieves all recommended categories.
- Source:
Returns:
Array of recommended categories.
- Type
- Array.<Category>
listCategories() → {Array.<Category>}
Lists all categories in the collection.
- Source:
Returns:
Array of all categories.
- Type
- Array.<Category>
updateCategory(categoryId, updates) → {boolean}
Updates an existing category's information.
Parameters:
| Name | Type | Description |
|---|---|---|
categoryId |
string | The ID of the category to update. |
updates |
Object | An object containing updated properties. |
- Source:
Returns:
True if the category was updated, false otherwise.
- Type
- boolean