SudoSOS Back-end API / catalogue/products / ProductService
Class: ProductService ​
Wrapper for all Product related logic.
Constructors ​
Constructor ​
new ProductService(): ProductService;Returns ​
ProductService
Methods ​
createProduct() ​
static createProduct(product): Promise<ProductRevision>;Creates a new product.
If approve is false, then the newly created product resides in the Product table and has no revision, but it does have an updated product. To confirm the product the updated product has to be confirmed and a revision will be created.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
product | CreateProductParams | The product to be created. |
Returns ​
Promise<ProductRevision>
deleteProduct() ​
static deleteProduct(productId): Promise<void>;(Soft) delete a product
Parameters ​
| Parameter | Type | Description |
|---|---|---|
productId | number | - |
Returns ​
Promise<void>
getOptions() ​
static getOptions(params, user?): Promise<FindManyOptions<ProductRevision>>;Returns a FindManyOptions based on the given parameters
Parameters ​
| Parameter | Type | Description |
|---|---|---|
params | ProductFilterParameters | The parameters to filter on |
user? | User | The user to filter on |
Returns ​
Promise<FindManyOptions<ProductRevision>>
getProducts() ​
static getProducts(
filters?,
pagination?,
user?): Promise<[ProductRevision[], number]>;Parameters ​
| Parameter | Type |
|---|---|
filters | ProductFilterParameters |
pagination | PaginationParameters |
user? | User |
Returns ​
Promise<[ProductRevision[], number]>
propagateProductUpdate() ​
static propagateProductUpdate(productId): Promise<void>;Propagates the product update to all parent containers
All containers that contain the previous version of this product will be revised to include the new revision.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
productId | number | The product to propagate |
Returns ​
Promise<void>
revisionToBaseResponse() ​
static revisionToBaseResponse(revision): BaseProductResponse;Parameters ​
| Parameter | Type |
|---|---|
revision | ProductRevision |
Returns ​
revisionToResponse() ​
static revisionToResponse(revision): ProductResponse;Parameters ​
| Parameter | Type |
|---|---|
revision | ProductRevision |
Returns ​
updateProduct() ​
static updateProduct(update): Promise<ProductRevision>;Parameters ​
| Parameter | Type |
|---|---|
update | UpdateProductParams |
Returns ​
Promise<ProductRevision>