const express = require("express");
const router = express.Router();
const authorize = require("../../../../../middlewares/authorize-sapps");
const accountService = require("./account.service");

router.post("/get-accounts", authorize(), getAccounts);
router.post("/get-option-accounts", authorize(), getOptionAccounts);
router.post("/import-all", authorize(), importAll);

module.exports = router;

function getAccounts(req, res, next) {
	accountService
		.getAccounts(req.body)
		.then((result) => res.json(result))
		.catch(next);
}

function getOptionAccounts(req, res, next) {
	accountService
		.getOptionAccounts(req.body)
		.then((result) => res.json(result))
		.catch(next);
}

function importAll(req, res, next) {
	accountService
		.importAll(req.body)
		.then((result) => res.json(result))
		.catch(next);
}
