import { Action } from 'verbs.do';
const purchaseAction = new Action({
name: 'Purchase',
description: 'Customer purchases a product',
subject: { type: 'Customer', required: true },
object: { type: 'Product', required: true },
properties: {
quantity: { type: 'number', default: 1 },
price: { type: 'number', required: true },
discount: { type: 'number', default: 0 },
paymentMethod: { type: 'string', enum: ['credit', 'debit', 'paypal'] }
},
effects: [
{ type: 'decreaseInventory', target: 'object.id', amount: 'quantity' },
{ type: 'createOrder', data: { customerId: 'subject.id', productId: 'object.id' } }
],
logging: true,
analytics: true
});