import express from 'express';
import controller from '../../controllers/admin/bankPolicies';

const router = express.Router();

// #region /api/admin/bankPolicies/insertUpdateBankPolicy apidoc
/**
 * @api {post} /api/admin/bankPolicies/insertUpdateBankPolicy insert/Update Bank Loan Policy
 * @apiVersion 1.0.0
 * @apiName insert/Update Bank Loan Policy
 * @apiDescription insert/Update Bank Loan Policy
 * @apiGroup Bank Policy - Admin
 * @apiParam  {Integer}         bankId                       Requires Bank Id
 * @apiParam  {Integer}         policies                      Requires policies
 * @apiParamExample {json} Request-Example:
 *     {
 *       "policies[id]": "1",
 *       "policies[banklLoanId]": "1",
 *       "policies[serviceId]":1,
 *       "policies[employmentTypeId]":1,
 *       "policies[cibilScore]":200,
 *       "policies[minIncome]":"10000",
 *       "policies[itrRequired]":true,
 *       "policies[vintage]":100,
 *       "policies[minTurnOver]":20000,
 *       "policies[maxTurnOver]":50000,
 *       "policies[tenure]":12,
 *       "policies[ROI]":10,
 *       "policies[minLoanAmount]":10000,
 *        "policies[maxLoanAmount]":500000
 *     }
 * @apiSuccess (200) {JSON} Result status, message, recordList, totalRecords.
 * @apiSuccessExample {json} Success-200-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          status: 200,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: 'insert/Update Bank Loan Policy',
 *           "recordList": {
 *             "fieldCount": 0,
 *             "affectedRows": 1,
 *             "insertId": <InsertedId>,
 *             "serverStatus": 2,
 *             "warningCount": 0,
 *             "message": "",
 *             "protocol41": true,
 *             "changedRows": 0
 *         },
 *          totalRecords: TotalRecords
 *     }
 * @apiError (500) {JSON} Result message, apiName, apiType, fileName, functionName, lineNumber, typeName, stack.
 * @apiErrorExample {json} Error-500-Response:
 *     HTTP/1.1 500 ERROR
 *     {
 *          status: <error status code>,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: <error message>,
 *          error: {
 *              apiName: <api name>,
 *              apiType: <api type>,
 *              fileName: <file name>,
 *              functionName: <function name>,
 *              lineNumber: <line number>,
 *              typeName: <type name>,
 *              stack: <stack>
 *          },
 *          value: <value if any>
 *     }
 * @apiError (401) {JSON} Result message, apiName, apiType, fileName, functionName, lineNumber, typeName, stack.
 * @apiErrorExample {json} Error-401-Response:
 *     HTTP/1.1 401 Unauthorized
 *     {
 *          status: 401,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: "Unauthorized request",
 *          error: {
 *              apiName: <api name>,
 *              apiType: <api type>,
 *              fileName: <file name>,
 *              functionName: <function name>,
 *              lineNumber: <line number>,
 *              typeName: <type name>,
 *              stack: <stack>
 *          },
 *          value: <value if any>
 *     }
 * @apiError (400) {JSON} Result message, apiName, apiType, fileName, functionName, lineNumber, typeName, stack.
 * @apiErrorExample {json} Error-400-Response:
 *     HTTP/1.1 400 Data not found
 *     {
 *          status: 400,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: "bankPolicies.insertUpdateBankPolicy() Error",
 *          error: {
 *              apiName: <api name>,
 *              apiType: <api type>,
 *              fileName: <file name>,
 *              functionName: <function name>,
 *              lineNumber: <line number>,
 *              typeName: <type name>,
 *              stack: <stack>
 *          },
 *          value: <value if any>
 */
// #endregion
router.post('/insertUpdateBankPolicy', controller.insertUpdateBankPolicy);

// #region /api/admin/bankPolicies/getBankPolicy apidoc
/**
 * @api {post} /api/admin/bankPolicies/getBankPolicy Get Bank Loan Policy
 * @apiVersion 1.0.0
 * @apiName Get Bank Loan Policy
 * @apiDescription Get Bank Loan Policy
 * @apiGroup Bank Policy - Admin
 * @apiParam  {Integer}         [startIndex]                    Optional startIndex
 * @apiParam  {Integer}         [fetchRecord]                 Optional fetchRecord
* @apiParam  {Integer}         [bankId]                 Optional bankId
 * @apiSuccess (200) {JSON} Result status, message, recordList, totalRecords.
 * @apiSuccessExample {json} Success-200-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          status: 200,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: 'Get Bank Loan Policy',
 *          recordList: Bank Policy,
 *          totalRecords: TotalRecords
 *     }
 * @apiError (500) {JSON} Result message, apiName, apiType, fileName, functionName, lineNumber, typeName, stack.
 * @apiErrorExample {json} Error-500-Response:
 *     HTTP/1.1 500 ERROR
 *     {
 *          status: <error status code>,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: <error message>,
 *          error: {
 *              apiName: <api name>,
 *              apiType: <api type>,
 *              fileName: <file name>,
 *              functionName: <function name>,
 *              lineNumber: <line number>,
 *              typeName: <type name>,
 *              stack: <stack>
 *          },
 *          value: <value if any>
 *     }
 * @apiError (401) {JSON} Result message, apiName, apiType, fileName, functionName, lineNumber, typeName, stack.
 * @apiErrorExample {json} Error-401-Response:
 *     HTTP/1.1 401 Unauthorized
 *     {
 *          status: 401,
 *          isDisplayMessage: <true/false>, // if the value is true then display message on screen
 *          message: "Unauthorized request",
 *          error: {
 *              apiName: <api name>,
 *              apiType: <api type>,
 *              fileName: <file name>,
 *              functionName: <function name>,
 *              lineNumber: <line number>,
 *              typeName: <type name>,
 *              stack: <stack>
 *          },
 *          value: <value if any>
 *     }
 */
// #endregion
router.post('/getBankPolicy', controller.getBankPolicy);

export = router;