import { RolesEndpointsController } from "../controllers/roles-endpoint.controller";
import { RolesEndpointsValidator } from "../validators/roles-endpoint.validator";
import { AbstractRoute } from "./abstract.route";

const express = require("express");
const router = express.Router();
const controller = new RolesEndpointsController();

class RolesEndpointsRoute extends AbstractRoute {
  constructor(_controller, _router) {
    super(_controller, _router, new RolesEndpointsValidator());
    this.customMethods = ["setPermissions", "avoidCheck"];
  }
  /**
   * Get all rolesEndpoints
   * @swagger
   * /roles-endpoints:
   *    get:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Get all rolesEndpoints"
   *      description: "List all rolesEndpoints with details"
   *      security:
   *        - bearerAuth: []
   *      operationId: "GETrolesEndpoints"
   *      produces:
   *      - "application/xml"
   *      - "application/json"
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - $ref: '#/components/parameters/pageParam'
   *      - $ref: '#/components/parameters/limitParam'
   *      - name: "sort"
   *        in: "query"
   *        description: "The type of sort of items to return."
   *        required: false
   *        schema:
   *          type: "string"
   *          enum: [endpoint, createdAt, role_id, -role_id, -endpoint, -createdAt]
   *      - name: "endpoint"
   *        in: "query"
   *        description: "Items with Endpoint"
   *        required: false
   *      - name: "role_id"
   *        in: "query"
   *        description: "Items with Role"
   *        required: false
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemsSchema'
   *        "204":
   *          description: "successful operation with empty respose"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemsSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  /**
   * Find rolesEndpoint by ID
   * @swagger
   * /roles-endpoints/{id}:
   *    get:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Find rolesEndpoint by ID"
   *      description: "Returns a single rolesEndpoint"
   *      security:
   *        - bearerAuth: []
   *      operationId: "GETrolesEndpoint"
   *      produces:
   *      - "application/xml"
   *      - "application/json"
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - name: "id"
   *        in: "path"
   *        description: "ID of rolesEndpoint to return"
   *        required: true
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "204":
   *          description: "successful operation with empty respose"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  /**
   * Add a rolesEndpoint
   * @swagger
   * /roles-endpoints:
   *    post:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Add a rolesEndpoint"
   *      description: "Add a rolesEndpoint"
   *      operationId: "ADDrolesEndpoint"
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      security:
   *        - bearerAuth: []
   *      requestBody:
   *        content:
   *          application/json:
   *            schema:
   *              $ref: "#/definitions/RolesEndpointsCreateItemSchema"
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "201":
   *          description: "Created successfully"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  /**
   * Update a rolesEndpoint
   * @swagger
   * /roles-endpoints/{id}:
   *    put:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Update a rolesEndpoints"
   *      description: "Update an existing rolesEndpoints"
   *      operationId: "UPDATErolesEndpoint"
   *      security:
   *        - bearerAuth: []
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - name: "id"
   *        in: "path"
   *        description: "ID of rolesEndpoint to update"
   *        required: true
   *      requestBody:
   *        content:
   *          application/json:
   *            schema:
   *              $ref: "#/definitions/RolesEndpointsUpdateItemSchema"
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  /**
   * Delete a rolesEndpoint
   * @swagger
   * /roles-endpoints/{id}:
   *    delete:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Delete a rolesEndpoint"
   *      description: "Delete an existing rolesEndpoint"
   *      operationId: "DELETErolesEndpoint"
   *      security:
   *        - bearerAuth: []
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - name: "id"
   *        in: "path"
   *        description: "ID of rolesEndpoint to delete"
   *        required: true
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsDeleteItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */

  /**
   * Set all permissions to a role
   * @swagger
   * /roles-endpoints/set-permissions/{id}:
   *    post:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Set permission to a role"
   *      description: "Set permission to a role"
   *      operationId: "SETpersmissionRoles"
   *      security:
   *        - bearerAuth: []
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - name: "id"
   *        in: "path"
   *        description: "ID of role to set permissions"
   *        required: true
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "201":
   *          description: "Created successfully"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  setPermissions() {
    this.router.post(
      "/set-permissions/:id",
      this.validator.setPermissions(),
      this.controller.setPermissions.bind(this.controller)
    );
  }
  /**
   * Avoid check to role
   * @swagger
   * /roles-endpoints/avoid-check/{id}:
   *    post:
   *      tags:
   *        - RolesEndpoints
   *      summary: "Avoid check to role"
   *      description: "Avoid check to role"
   *      operationId: "AVOIDcheckRolesEndpoint"
   *      security:
   *        - bearerAuth: []
   *      parameters:
   *      - $ref: '#/components/parameters/store'
   *      - name: "id"
   *        in: "path"
   *        description: "ID of endpoint to Avoid check"
   *        required: true
   *      responses:
   *        "200":
   *          description: "successful operation"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "201":
   *          description: "Created successfully"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/RolesEndpointsGetItemSchema'
   *        "401":
   *          description: "Not allow because you need a Authentication Token"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        '403':
   *          description: "Not allow because you need more permissions"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        "404":
   *          description: "RolesEndpoints not found"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   *        default:
   *          description: "Unexpected Error"
   *          content:
   *            application/json:
   *              schema:
   *                $ref: '#/definitions/ErrorSchema'
   */
  avoidCheck() {
    this.router.post(
      "/avoid-check/:id",
      this.validator.avoidCheck(),
      this.controller.avoidCheck.bind(this.controller)
    );
  }
}

export const rolesEndpointsRouter = new RolesEndpointsRoute(
  controller,
  router
).init();
