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

# question set api
paths:
  /api/questionset:
    post:
      summary: created new question set
      description: |
        **Overview**

        *This api is used to create new question set.*

        **Required Fields**

        - name
        - price
        - expiry_duration

      tags: ["Question Set"]
      security:
        - BearerAuth: []
      requestBody:
        description: JSON object
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: Set A
                price:
                  type: number
                  example: 250
                expiry_duration:
                  type: string
                  example: 3h
              required:
                - name
                - price
                - expiry_duration
      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
    put:
      summary: updates existing question set
      description: |
        **Overview**

        *This api is used to update the existing question set.*

        **Required Fields**

        - question_set_id
        - name
        - price
        - expiry_duration

      tags: ["Question Set"]
      security:
        - BearerAuth: []
      requestBody:
        description: JSON object
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                question_set_id:
                  type: number
                  example: 2
                name:
                  type: string
                  example: Set A
                price:
                  type: number
                  example: 250
                expiry_duration:
                  type: string
                  example: 3h
              required:
                - question_set_id
                - name
                - price
                - expiry_duration
      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 updated successfully!!!
                required:
                  - status
                  - message
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error
    get:
      summary: Returns the list of question set
      description: >-
        This api fetches the list of question set from the database
      tags: ["Question Set"]
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: number
            required: true
        - in: query
          name: limit
          schema:
            type: number
            required: true
        - in: query
          name: questionSetName
          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:
                      [
                        {
                          question_set_id: 1,
                          name: Set A,
                          price: 250,
                          expiry_duration: 3h,
                        },
                        {
                          question_set_id: 2,
                          name: Set B,
                          price: 350,
                          expiry_duration: 3h,
                        },
                      ]
                  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
  paths:
  /api/questionset/{id}:
    delete:
      summary: deletes question set with the given id
      description: >-
        This api delets question set from the database
      tags: ["Question Set"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          schema:
            type: number
            required: true
            description: question_set_id
      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/restorequestionset/{id}:
    put:
      summary: restores the deleted question set with the given id
      description: >-
        This api restores the question set
      tags: ["Question Set"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          schema:
            type: number
            required: true
            description: question_set_id
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: >-
                      true
                  message:
                    type: string
                    example: >-
                      Data updated successfully!!!
                required:
                  - status
                  - message
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error
  /api/getallquestionset:
    get:
      summary: Returns the list of question set
      description: >-
        This api fetches the list of question set from the database
      tags: ["Question Set"]
      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:
                      [
                        {
                          question_set_id: 1,
                          name: Set A,
                          price: 250,
                          expiry_duration: 3h,
                        },
                        {
                          question_set_id: 2,
                          name: Set B,
                          price: 350,
                          expiry_duration: 3h,
                        },
                      ]
                  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/questionset_count:
    get:
      summary: Returns the count of active question set and inactive question set
      description: >-
        This api fetches the count depending upon status, i.e count of active question set and inactive question set, If status === 1, it is Active question set, If status === 0, it is inactive question set
      tags: ["Admin Home Page"]
      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:
                      [
                        {
                          status: 1,
                          count: 88,
                        },
                        {
                          status: 0,
                          count: 12,
                        },
                      ]
                required:
                  - status
                  - message
                  - data
        "400":
          description: Bad request error message
        "401":
          description: Unauthorized error message
        "500":
          description: Internal Server Error