export class ProductItem { name?: string; type?: string; amount?: string; category?: string; quantity?: number; description?: string; subcategory?: string; referenceId?: string; constructor( name?: string, type?: string, amount?: string, category?: string, quantity?: number, description?: string, subcategory?: string, referenceId?: string ) { this.name = name; this.type = type; this.amount = amount; this.category = category; this.quantity = quantity; this.description = description; this.subcategory = subcategory; this.referenceId = referenceId; } } export function productItemArrayFromJson( jsonArray: { [key: string]: any }[] ): ProductItem[] { return jsonArray.map((json) => productItemFromJson(json)); } export function productItemArrayToJson( productItems: ProductItem[] ): { [key: string]: any }[] { return productItems.map((productItem) => productItemToJson(productItem)); } function productItemFromJson(json: { [key: string]: any }): ProductItem { return { name: json.name, type: json.type, amount: json.amount, category: json.category, quantity: json.quantity, description: json.description, subcategory: json.subcategory, referenceId: json.reference_id || json.referenceId, }; } function productItemToJson(productItem: ProductItem): { [key: string]: any; } { return { name: productItem.name, type: productItem.type, amount: productItem.amount, category: productItem.category, quantity: productItem.quantity, description: productItem.description, subcategory: productItem.subcategory, reference_id: productItem.referenceId, }; }