@chevre/domain
Version:
Chevre Domain Library for Node.js
61 lines (60 loc) • 2.85 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withdraw = exports.transfer = exports.deposit = void 0;
exports.confirm = confirm;
const factory = require("../factory");
const DepositTransactionService = require("./accountTransaction/deposit");
exports.deposit = DepositTransactionService;
const TransferTransactionService = require("./accountTransaction/transfer");
exports.transfer = TransferTransactionService;
const WithdrawTransactionService = require("./accountTransaction/withdraw");
exports.withdraw = WithdrawTransactionService;
const factory_1 = require("./accountTransaction/factory");
/**
* 取引確定
*/
function confirm(params) {
return (repos) => __awaiter(this, void 0, void 0, function* () {
let transaction;
// 取引存在確認
// tslint:disable-next-line:no-single-line-block-comment
/* istanbul ignore else */
if (typeof params.id === 'string') {
transaction = yield repos.accountTransaction.findById({ typeOf: params.typeOf, id: params.id });
}
else if (typeof params.transactionNumber === 'string') {
// tslint:disable-next-line:no-single-line-block-comment
/* istanbul ignore next */
transaction = yield repos.accountTransaction.findByTransactionNumber({
typeOf: params.typeOf,
transactionNumber: params.transactionNumber
});
}
else {
// tslint:disable-next-line:no-single-line-block-comment
/* istanbul ignore next */
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
}
// 現金転送アクション属性作成
const moneyTransferActionAttributes = (0, factory_1.createMoneyTransferActionAttributes)({ transaction });
const potentialActions = {
moneyTransfer: moneyTransferActionAttributes
};
// 取引確定
return repos.accountTransaction.confirm({
typeOf: transaction.typeOf,
id: transaction.id,
// result: {},
potentialActions
});
});
}
;