@chevre/domain
Version:
Chevre Domain Library for Node.js
52 lines (51 loc) • 3.04 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.call = call;
const factory = require("../../factory");
const accountingReport_1 = require("../../repo/accountingReport");
const action_1 = require("../../repo/action");
const credentials_1 = require("../../repo/credentials");
const paymentService_1 = require("../../repo/paymentService");
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
const product_1 = require("../../repo/product");
const project_1 = require("../../repo/project");
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
const task_1 = require("../../repo/task");
const voidPaymentByTask_1 = require("./payment/voidPaymentByTask");
/**
* タスク実行関数
*/
function call(data) {
return (_a) => __awaiter(this, [_a], void 0, function* ({ connection, redisClient, settings }) {
if (redisClient === undefined) {
throw new factory.errors.Argument('settings', 'redisClient required');
}
const paymentServiceId = data.object.object.id;
const credentialsExpireInSeconds = settings.movieticketReserve.credentialsExpireInSeconds;
const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== ''
&& typeof credentialsExpireInSeconds === 'number' && credentialsExpireInSeconds > 0;
yield (0, voidPaymentByTask_1.voidPaymentByTask)(data)({
accountingReport: new accountingReport_1.AccountingReportRepo(connection),
action: new action_1.ActionRepo(connection),
credentials: new credentials_1.CredentialsRepo(redisClient, {
scope: `${factory.service.paymentService.PaymentServiceType.MovieTicket}:${paymentServiceId}`,
expireInSeconds: (useCredentialsRepo) ? credentialsExpireInSeconds : 0
}),
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
paymentService: new paymentService_1.PaymentServiceRepo(connection),
paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
product: new product_1.ProductRepo(connection),
project: new project_1.ProjectRepo(connection),
task: new task_1.TaskRepo(connection)
}, settings);
});
}
;