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/questionsetpackage:
    post:
      summary: created new question set package
      description: |
        **Overview**

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

        **Required Fields**

        - package_name
        - price
        - question_set_id

      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      requestBody:
        description: JSON object
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                package_name:
                  type: string
                  example: Package 1
                price:
                  type: number
                  example: 250
                question_set_id:
                  type: array
                  example: [1, 2, 3, 4, 5]
              required:
                - package_name
                - price
                - question_set_id
      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 question set package
      description: |
        **Overview**

        *This api is used to update question set package.*

        **Required Fields**

        - package_id
        - package_name
        - price
        - question_set_id

      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      requestBody:
        description: JSON object
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                package_id:
                  type: number
                  example: 3
                package_name:
                  type: string
                  example: Package 1
                price:
                  type: number
                  example: 250
                question_set_id:
                  type: array
                  example: [1, 2, 3, 4, 5]
              required:
                - package_id
                - price
                - question_set_id
      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 packages
      description: >-
        This api fetches the list of question set package from the database
      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: number
            required: true
        - in: query
          name: limit
          schema:
            type: number
            required: true
        - in: query
          name: status
          schema:
            type: number
            required: true
            default: 1
        - in: query
          name: package_name
          schema:
            type: string
            required: false           
      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:
                      [
                        {
                          package_id: 1,
                          question_set_id: [1, 2, 3, 4, 5],
                          price: 250,
                          status: 1,
                        },
                        {
                          package_id: 2,
                          question_set_id: [1, 2, 3, 4, 5, 6, 7],
                          price: 550,
                          status: 1,
                        },
                      ]
                  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/questionsetpackage/{package_id}:
    get:
      summary: Returns the list of question set associated with the package
      description: >-
        This api fetches the list of question set associated with the given package_id
      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: package_id
          schema:
            type: number
            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: array
                    example:
                      [
                        {
                          question_set_id: 1,
                          name: Set B,
                          price: 250,
                          expiry_duration: 3h,
                          status: 1,
                        },
                        {
                          question_set_id: 2,
                          name: Set C,
                          price: 250,
                          expiry_duration: 3h,
                          status: 1,
                        },
                      ]
                  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
    delete:
      summary: deletes question set with the given id
      description: >-
        This api delets question set from the database
      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: package_id
          schema:
            type: number
            required: true
            description: package_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/restorequestionsetpackage/{package_id}:
    put:
      summary: restores the deleted question set package with the given package_id
      description: >-
        This api restores the question set package
      tags: ["Question Set Package"]
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: package_id
          schema:
            type: number
            required: true
            description: package_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/questionset_package_count:
    get:
      summary: Returns the count of active PACKAGE set and inactive PACKAGE set
      description: >-
        This api fetches the count depending upon status, i.e count of active PACKAGE set and inactive PACKAGE set, If status === 1, it is Active PACKAGE set, If status === 0, it is inactive PACKAGE 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
