@1amageek/tradable
Version:
Cloud Firestore model framework for TypeScript - Google
24 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayoutManager = void 0;
const FirebaseFirestore = require("@google-cloud/firestore");
class PayoutManager {
constructor(balanceTransaction, payout, user) {
this._BalanceTransaction = balanceTransaction;
this._Payout = payout;
this._Account = user;
}
update(payout, transactionResult, transaction) {
const payoutValue = payout.value();
payoutValue.updatedAt = FirebaseFirestore.FieldValue.serverTimestamp();
if (Object.keys(transactionResult).length > 0) {
payoutValue["transactionResults"] = FirebaseFirestore.FieldValue.arrayUnion(transactionResult);
}
const payoutReference = new this._Payout(payout.id, {}).reference;
const account = new this._Account(payout.account, {});
transaction.set(payoutReference, payoutValue, { merge: true });
transaction.set(account.payoutRequests.reference.doc(payout.id), payoutValue, { merge: true });
}
}
exports.PayoutManager = PayoutManager;
//# sourceMappingURL=PayoutManager.js.map