| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /**
- * Represents a product with various attributes.
- *
- * @class
- * @property {string|null} name - The name of the product
- * @property {string|null} description - A description of the product
- * @property {string|null} author - The author or creator of the product
- * @property {string|null} image - An image URL or reference for the product
- * @property {number|null} stock_count - The current inventory count
- * @property {string|null} barcode - The unique barcode identifier
- */
- export class product {
- name;
- description;
- author;
- image;
- stock_count;
- barcode;
- thumbnail;
- on_stock;
- constructor(target) {
- this.name = null;
- this.description = null;
- this.author = null;
- this.image = null;
- this.stock_count = null;
- this.barcode = null;
- this.thumbnail = null;
- this.on_stock = null;
- if ("name" in target) this.name = target["name"];
- if ("description" in target) this.description = target["description"];
- if ("author" in target) this.author = target["author"];
- if ("image" in target) this.image = target["image"];
- if ("stock_count" in target) this.stock_count = target["stock_count"];
- if ("barcode" in target) this.barcode = target["barcode"];
- if ("thumbnail" in target) this.thumbnail = target["thumbnail"];
- if ("on_stock" in target) this.on_stock = target["on_stock"];
- }
- get dump() {
- const dumped = {
- "name": this.name,
- "description": this.description,
- "author": this.author,
- "image": this.image,
- "stock_count": this.stock_count,
- "barcode": this.barcode,
- "thumbnail": this.thumbnail
- };
- if (this.on_stock !== null) {
- dumped["on_stock"] = this.on_stock;
- }
- return dumped;
- }
- get ready() {
- if (this.name === null || this.description === null) return false;
- if (this.author === null || this.image === null) return false;
- if (this.stock_count === null || this.barcode === null) return false;
- if (this.thumbnail === null) return false;
- return true;
- }
- copy() {
- return new product(this.dump);
- }
- }
|