openapi: 3.0.0
info:
  title: Question Set
  description: APIs for question set packages
  version: 1.0.0
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

# question set packages api
paths:
  /api/uploadbook:
    post:
      summary: uploads books in pdf format
      description: |
        **Overview**

        *This api is used to upload book in pdf format*

        **Required Fields**
        - book
        - book_name

      tags: ["Book"]
      security:
        - BearerAuth: []
      requestBody:
        description: form-data
        required: true
        content:
          application/form-data:
            schema:
              type: object
              properties:
                book_name:
                  type: string
                  example: book1
                book:
                  type: file
                  example: book.pdf
              required:
                - book
      responses:
        "201":
          description: Successful response containing status and message
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Data saved successfully!!!
                required:
                  - status
                  - message
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error

  /api/getbooklist:
    get:
      summary: Returns the list of available book
      description: >-
        This api fetches the list of available book
      tags: ["Book"]
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: >-
                      true
                  message:
                    type: string
                    example: >-
                      Data found successfully!!!
                  data:
                    type: array
                    example:
                      [
                        {
                          book_id: 1,
                          book_name: "1685339065732--Authentication and Authorization.pdf",
                        },
                        {
                          book_id: 2,
                          book_name: "1685339065732--Authentication and Authorization.pdf",
                        },
                      ]
                  total:
                    type: number,
                    example: 8
                required:
                  - status
                  - message
                  - data
                  - total
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error

  /api/getbookfile/{file_name}:
    get:
      summary: Returns the book file
      description: >-
        This api fetches the book file
      tags: ["Book"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: file_name
          schema:
            type: string
            required: true
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: >-
                      true
                  message:
                    type: string
                    example: >-
                      Data found successfully!!!
                  data:
                    type: pdf
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error

  /api/deletebook/{file_name}:
    delete:
      summary: deletes book with the given id
      description: >-
        This api deletes book with the given book_id
      tags: ["Book"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: file_name
          schema:
            type: string
            required: true
            description: file_name
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: >-
                      true
                  message:
                    type: string
                    example: >-
                      Data deleted successfully!!!
                required:
                  - status
                  - message
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error

  /api/uploadaudiobook:
    post:
      summary: uploads books in audio format
      description: |
        **Overview**

        *This api is used to upload book in audio format*

        **Required Fields**
        - book_name
        - audioBook

      tags: ["Audio Book"]
      security:
        - BearerAuth: []
      requestBody:
        description: form-data
        required: true
        content:
          application/form-data:
            schema:
              type: object
              properties:
                book_name:
                  type: string
                  example: book1
                book:
                  type: file
                  example: aduiobook.mp3
              required:
                - audioBook
                - book_name
      responses:
        "201":
          description: Successful response containing status and message
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Data saved successfully!!!
                required:
                  - status
                  - message
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error

  /api/getaudiobooklist:
    get:
      summary: Returns the list of audio books
      description: >-
        This api fetches the list of audio books from the database
      tags: ["Audio Book"]
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: number
            required: true
        - in: query
          name: limit
          schema:
            type: number
            required: true
        - in: query
          name: bookName
          schema:
            type: string
            required: false
        - in: query
          name: status
          schema:
            type: number
            required: true
            default: 1
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: >-
                      true
                  message:
                    type: string
                    example: >-
                      Data found successfully!!!
                  data:
                    type: array
                    example:
                      [
                        {
                          "book_id": 3,
                          "book_name": "test_audio_book",
                          "file_name": "1692166173579--Copy of Audio 6 (1_350).mp3",
                        },
                      ]
                  total:
                    type: number,
                    example: 1
                required:
                  - status
                  - message
                  - data
                  - total
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error
