Source: customer/index.js

/**
 * Represents a customer in the order system.
 */
class Customer {
    /** 
     * Creates a new Customer instance.
     * 
     * @param {number} customerId - Unique identifier for the customer.
     * @param {string} name - Full name of the customer.
     * @param {string} email - Email address of the customer.
     * @param {string} phoneNumber - Contact number of the customer.
     * @param {string} address - Residential or shipping address of the customer.
     * @param {number} [loyaltyPoints=0] - Loyalty points accumulated by the customer (default is 0).
     */
    constructor(customerId,name, email,phoneNumber, address, loyaltyPoints = 0){
        this.customerId = customerId; 
        this.name = name;
        this.email = email;
        this.phoneNumber = phoneNumber;
        this.address = address;
        this.loyaltyPoints = loyaltyPoints;
    }
    /**
     * Updates the customer's contact information.
     * @param {string} [newEmail] - New email address (optional).
     * @param {string} [newPhoneNumber] - New phone number (optional).
     * @param {string} [newAddress] - New physical address (optional).
     */
    updateContactInfo(newEmail, newPhoneNumber, newAddress) {
        if (newEmail) this.email = newEmail;
        if (newPhoneNumber) this.phoneNumber = newPhoneNumber;
        if (newAddress) this.address = newAddress;
    }
    /**
     * Adds loyalty points to the customer.
     * @param {number} points - The number of points to add (must be positive).
     */
    addLoyaltyPoints(points) {
        if (points > 0) {
            this.loyaltyPoints += points;
        } else {
            console.log("Invalid points value. Points must be positive.");
        }
    }
    /**
     * Retrieves the customer's details.
     * @returns {Object} An object containing all customer details.
     */
    getCustomerDetails() {
        return {
            customerId: this.customerId,
            name: this.name,
            email: this.email,
            phoneNumber: this.phoneNumber,
            address: this.address,
            loyaltyPoints: this.loyaltyPoints
        };
    }
}

export default Customer