const Page_elementsService = require('../services/page_elements');
const Page_elementsDBApi = require('../db/api/page_elements');
const { createEntityRouter } = require('../factories/router.factory');

/**
 *  @swagger
 *  components:
 *    schemas:
 *      Page_elements:
 *        type: object
 *        properties:
 *          name:
 *            type: string
 *          style_json:
 *            type: string
 *          content_json:
 *            type: string
 *          sort_order:
 *            type: integer
 *          x_percent:
 *            type: number
 *          y_percent:
 *            type: number
 *          width_percent:
 *            type: number
 *          height_percent:
 *            type: number
 *          rotation_deg:
 *            type: number
 */

/**
 *  @swagger
 * tags:
 *   name: Page_elements
 *   description: The Page_elements managing API
 */

/**
 *  @swagger
 *  /api/page_elements:
 *    post:
 *      security:
 *        - bearerAuth: []
 *      tags: [Page_elements]
 *      summary: Add new item
 *      requestBody:
 *        required: true
 *        content:
 *          application/json:
 *            schema:
 *              properties:
 *                data:
 *                  type: object
 *                  $ref: "#/components/schemas/Page_elements"
 *      responses:
 *        200:
 *          description: The item was successfully added
 *        401:
 *          $ref: "#/components/responses/UnauthorizedError"
 *        500:
 *          description: Some server error
 *    get:
 *      security:
 *        - bearerAuth: []
 *      tags: [Page_elements]
 *      summary: Get all page_elements
 *      responses:
 *        200:
 *          description: Page_elements list successfully received
 *        401:
 *          $ref: "#/components/responses/UnauthorizedError"
 *        500:
 *          description: Some server error
 */

/**
 *  @swagger
 *  /api/page_elements/{id}:
 *    put:
 *      security:
 *        - bearerAuth: []
 *      tags: [Page_elements]
 *      summary: Update the selected item
 *      parameters:
 *        - in: path
 *          name: id
 *          required: true
 *          schema:
 *            type: string
 *      requestBody:
 *        required: true
 *        content:
 *          application/json:
 *            schema:
 *              properties:
 *                id:
 *                  type: string
 *                data:
 *                  type: object
 *                  $ref: "#/components/schemas/Page_elements"
 *      responses:
 *        200:
 *          description: The item was successfully updated
 *        401:
 *          $ref: "#/components/responses/UnauthorizedError"
 *        404:
 *          description: Item not found
 *        500:
 *          description: Some server error
 *    delete:
 *      security:
 *        - bearerAuth: []
 *      tags: [Page_elements]
 *      summary: Delete the selected item
 *      parameters:
 *        - in: path
 *          name: id
 *          required: true
 *          schema:
 *            type: string
 *      responses:
 *        200:
 *          description: The item was successfully deleted
 *        401:
 *          $ref: "#/components/responses/UnauthorizedError"
 *        404:
 *          description: Item not found
 *        500:
 *          description: Some server error
 *    get:
 *      security:
 *        - bearerAuth: []
 *      tags: [Page_elements]
 *      summary: Get selected item
 *      parameters:
 *        - in: path
 *          name: id
 *          required: true
 *          schema:
 *            type: string
 *      responses:
 *        200:
 *          description: Selected item successfully received
 *        401:
 *          $ref: "#/components/responses/UnauthorizedError"
 *        404:
 *          description: Item not found
 *        500:
 *          description: Some server error
 */

module.exports = createEntityRouter('page_elements', Page_elementsService, Page_elementsDBApi);
