const AssetsService = require('../services/assets');
const AssetsDBApi = require('../db/api/assets');
const { createEntityRouter } = require('../factories/router.factory');

/**
 *  @swagger
 *  components:
 *    schemas:
 *      Assets:
 *        type: object
 *        properties:
 *          name:
 *            type: string
 *          cdn_url:
 *            type: string
 *          storage_key:
 *            type: string
 *          mime_type:
 *            type: string
 *          checksum:
 *            type: string
 *          width_px:
 *            type: integer
 *          height_px:
 *            type: integer
 *          size_mb:
 *            type: number
 *          duration_sec:
 *            type: number
 */

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

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

/**
 *  @swagger
 *  /api/assets/{id}:
 *    put:
 *      security:
 *        - bearerAuth: []
 *      tags: [Assets]
 *      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/Assets"
 *      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: [Assets]
 *      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: [Assets]
 *      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('assets', AssetsService, AssetsDBApi);
