<commit_before>'use strict';

let adminService = require('../services/adminService');
let logger = require('../lib/logger');
let validator = require('../lib/inputValidator');
let adminValidator = require('../lib/adminValidator');
let adminType = require('../security/adminType');

function deleteAdmin(req, res) {
    let branchId = req.params.branchId;
    let adminId = req.params.adminId;

    if (!(validator.isValidUUID(branchId) && validator.isValidUUID(adminId))) {
        logger.error(`Failed deleting the admin with id:${adminId} and branchId: ${branchId}`);
        return res.sendStatus(400);
    }

    return adminService.delete(adminId)
    .then(() => {
        res.sendStatus(200);
    })
    .catch((error) => {
        logger.error(`Failed deleting the admin with id:${adminId} and branchId: ${branchId}}`, error);
        res.sendStatus(500);
    });
}

function parseAdmin(req) {
    let admin = {};
    if (req.body.name !== undefined ) { admin.name = req.body.name; }
    if (req.body.email !== undefined) { admin.email = req.body.email; }
    if (req.body.phoneNumber !== undefined) { admin.phoneNumber = req.body.phoneNumber; }
    if (req.body.password !== undefined) { admin.password = <PASSWORD>; }
    return admin;
}

function createSuperAdmin(req, res) {
    let newAdmin = parseAdmin(req);
    newAdmin.type = adminType.super;
    let validationErrors = adminValidator.isSuperAdminValid(newAdmin);

    if (validationErrors.length > 0) {
        logger.info('[create-new-admin-validation-error]', {errors: validationErrors});
        return res.status(400).json({ errors: validationErrors});
    }<commit_msg>Testing slack integration<commit_after>'use strict';

let adminService = require('../services/adminService');
let logger = require('../lib/logger');
let validator = require('../lib/inputValidator');
let adminValidator = require('../lib/adminValidator');
let adminType = require('../security/adminType');

function deleteAdmin(req, res) {
    let branchId = req.params.branchId;
    let adminId = req.params.adminId;

    if (!(validator.isValidUUID(branchId) && validator.isValidUUID(adminId))) {
        logger.error(`Failed deleting the admin with id:${adminId} and branchId: ${branchId}`);
        return res.sendStatus(400);
    }

    return adminService.delete(adminId)
    .then(() => {
        res.sendStatus(200);
    })
    .catch((error) => {
        logger.error(`Failed deleting the admin with id:${adminId} and branchId: ${branchId}}`, error);
        res.sendStatus(500);
    });
}



function parseAdmin(req) {
    let admin = {};
    if (req.body.name !== undefined ) { admin.name = req.body.name; }
    if (req.body.email !== undefined) { admin.email = req.body.email; }
    if (req.body.phoneNumber !== undefined) { admin.phoneNumber = req.body.phoneNumber; }
    if (req.body.password !== undefined) { admin.password = <PASSWORD>; }
    return admin;
}

function createSuperAdmin(req, res) {
    let newAdmin = parseAdmin(req);
    newAdmin.type = adminType.super;
    let validationErrors = adminValidator.isSuperAdminValid(newAdmin);

    if (validationErrors.length > 0) {
        logger.info('[create-new-admin-validation-error]', {errors: validationErrors});
        return res.status(400).json({ errors: validationErrors});
    }
{'fraction_non_alphanumeric': 0.15898058252427186, 'fraction_numerical': 0.007888349514563107, 'mean_word_length': 3.624123422159888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3858961', 'n_tokens_mistral': 996, 'n_tokens_neox': 975, 'n_words': 208}