@magic.batua/points
Version:
The Points module powers the loyalty points features of the Magic Batua platform.
35 lines • 1.28 kB
JavaScript
;
/**
* @module Transaction
* @overview Defines the points transactions logic and interfaces
*
* @author Animesh Mishra <hello@animesh.ltd>
* @copyright © 2018 Animesh Ltd. All Rights Reserved.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const mongodb_1 = require("mongodb");
const milliSecondsInAYear = 31557600000;
/**
* Operations such as issuance, redemptions, rollback, refund etc. are classified as Points
* Transactions and managed by the `Transaction` class.
*
* Each `transaction` carries a unique `_id`.
*/
class Transaction {
/**
* Initialises a Points `Transaction` instance.
*
* @param {InitTransaction} json See `Source/Transaction.ts` for definition
* of `InitTransaction`.
*/
constructor(json) {
this._id = json._id || new mongodb_1.ObjectID().toHexString();
this.points = json.points;
this.type = json.type;
this.date = json.date ? new Date(json.date) : new Date();
this.notes = json.notes;
this.expiryDate = json.expiryDate ? new Date(json.expiryDate) : new Date(Date.now() + milliSecondsInAYear);
}
}
exports.Transaction = Transaction;
//# sourceMappingURL=Transaction.js.map