openapi: 3.0.3
info:
  title: Mowiklip API
  description: Documentation for the apis supporting the mowiklip chrome plugin
  version: 3.0.0
servers:
- url: http://localhost:3000
  description: Local Server for development
schemes: [http,https]
tags:
- name: User methods
  description: All User endpoints
- name: Public methods
  description: All public endpoints
- name: Admin methods
  description: All admin endpoints
paths:
  /tags:
    get:
      tags:
        - tags
      summary: Returns a array of tag name on success.
      description: List of all tag names.
      responses:
        200:
          description: Successfull execution
          schema:
              type: object
              properties:
                  tag:
                    type: array
                    example: ["Fast Recall","Only Action","PG13"]
        404:
          description: Execution Failure
          schema:
              type: object
              example: {"status":"Tag name is empty"}
        500:
          description: Internal logic error
          schema:
            type: String
            example: "Internal Server Error"
  /edits/like/{id}:
    get:
      tags:
        - Public methods
      summary: Like a upload and get the current like count.
      description: give a dislike and the total like count.
      parameters:
        - name: id
          in: path
          description: Edit id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        200:
          description: Successfull execution
          content:
            text/plain:
              schema:
                type: integer
                example: 5
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"status":"Edit Unavailable"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /edits/dislike/{id}:
    get:
      tags:
        - Public methods
      summary: Dislike a upload and get the current dislike count.
      description: give a dislike and the total dislike count.
      parameters:
        - name: id
          in: path
          description: Edit id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        200:
          description: Successfull execution
          content:
            text/plain:
              schema:
                type: integer
                example: 5
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"status":"Edit Unavailable"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /edits/trackId/{trackId}:
    get:
      tags:
        - Public methods
      summary: list edits based on trackId.
      description: List all the public edits based on trackId.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit available for this trackId
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /edits/trackId/{trackId}/tag/{tag}:
    get:
      tags:
        - Public methods
      summary: list edits based on trackId.
      description: List all the public edits based on trackId.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
        - name: tag
          in: path
          description: tag from user
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit is available for this trackID
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /user/allEdits/{trackId}/{userId}:
    get:
      security:
        - bearerAuth: []
      tags:
        - User methods
      summary: list edits based on trackId.
      description: List all the public edits based on trackId.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
        - name: userId
          in: path
          description: userId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit is available for this trackId
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /user/tagEdits/{trackId}/{userId}/{tag}:
    get:
      security:
        - bearerAuth: []
      tags:
        - User methods
      summary: list all the edits based on trackId and tag.
      description: List all the edits based on trackId and tag.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
        - name: tag
          in: path
          description: tag from user
          required: true
          schema:
            type: string
        - name: userId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit available for this trackId
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /user/delEdit/{id}/{userId}:
    delete:
      security:
        - bearerAuth: []
      tags:
        - User methods
      summary: Delete a single edit from the user.
      description: Delete a single edit from the user using userID and edit id.
      parameters:
        - name: userId
          in: path
          description: userId from client
          required: true
          schema:
            type: string
        - name: id
          in: path
          description: id from client
          required: true
          schema:
            type: integer
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"Success"}
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"Data not available"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /user/upEdit/{id}/{userId}:
    patch:
      security:
        - bearerAuth: []
      tags:
        - User methods
      summary: Update personal edits.
      description: Update personal edits based on userId and id.
      parameters:
        - name: id
          in: path
          description: id from client
          required: true
          schema:
            type: integer
        - name: userId
          in: path
          description: userId from client
          required: true
          schema:
            type: string
      requestBody:
        description: 
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Klips'
              $ref: '#/components/schemas/Edits/tag'
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"Success"}
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"not found"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /user/newEdit:
    post:
      security:
        - bearerAuth: []
      tags:
        - User methods
      summary: Update personal edits.
      description: Update personal edits based on userId and id.
      requestBody:
        description: Edit body
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Editup'
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"Success"}
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"not found"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /admin/trackId/{trackId}/{adminId}:
    get:
      security:
        - bearerAuth: []
      tags:
        - Admin methods
      summary: list edits based on trackId.
      description: List all the public edits based on trackId.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
        - name: adminId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit available for this trackId
          schema:
              type: object
              example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /admin/trackId/{trackId}/tag/{tag}/{adminId}:
    get:
      security:
        - bearerAuth: []
      tags:
        - Admin methods
      summary: list all the edits based on trackId and tag.
      description: List all the edits based on trackId and tag.
      parameters:
        - name: trackId
          in: path
          description: trackId from Netflix
          required: true
          schema:
            type: string
        - name: tag
          in: path
          description: tag from user
          required: true
          schema:
            type: string
        - name: adminId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit available for this trackId
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /admin/edits/{adminId}:
    get:
      security:
        - bearerAuth: []
      tags:
        - Admin methods
      summary: list all the edits.
      description: List all the edits.
      parameters:
        - name: adminId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Editlist'
        401:
          $ref: '#/components/responses/UnauthorizedError'
        404:
          description: No edit available for this trackId
          content:
            application/json:
              schema:
                type: object
                example: []
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /admin/deleteAll/{userId}/{adminId}:
    delete:
      security:
        - bearerAuth: []
      tags:
        - Admin methods
      summary: Delete all the edits from a single user.
      description: Delete all the edits from a single user using userID.
      parameters:
        - name: adminId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
        - name: userId
          in: path
          description: userId from client
          required: true
          schema:
            type: string
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                type: object
                example: {"Status": "Successfull deletion"}
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"not a admin"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
  /admin/deleteOne/{id}/{adminId}:
    delete:
      security:
        - bearerAuth: []
      tags:
        - Admin methods
      summary: Delete all the edits from a single user.
      description: Delete all the edits from a single user using userID.
      parameters:
        - name: adminId
          in: path
          description: adminId from client
          required: true
          schema:
            type: string
        - name: id
          in: path
          description: id from client
          required: true
          schema:
            type: integer
      responses:
        200:
          description: Successfull execution
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"Success"}
        404:
          description: Execution Failure
          content:
            application/json:
              schema:
                type: object
                example: {"Status":"not a admin"}
        500:
          description: Internal logic error
          content:
            text/plain:
              schema:
                type: String
                example: "Internal Server Error"
components:
  schemas:
    Klip:
      type: object
      title: Klip
      properties:
        id:
          type: integer
          description: id of klip
        startTime:
          type: integer
          description: start time of klip
        endTime:
          type: integer
          description: end time of klip
        type:
          type: string
          enum:
          - skip
          - mute
          - play
    Editup:
      type: object
      title: Schema for new Edit
      properties:
        name:
          type: string
          description: name of the edit
        description:
          type: string
          description: description of the edit
        author:
          type: string
          description: Name of the user
        userId:
          type: string
          description: userId for the user
        trackId:
          type: integer
          description: the unique key used by netflix to reference each video. Eg, 'https://www.netflix.com/watch/81088080?trackId=254015180.......' the trackId will be 81088080 and NOT 254015180
        isPrivate:
          type: boolean
          description: indicates whether its a private edit or not
        tags:
          type: string
          description: tag name to the edit
        klips:
          type: array
          items:
              $ref: '#/components/schemas/Klip'
    Editlist:
      type: object
      title: Schema for display Edit list
      properties:
        id:
          type: integer
          description: auto incremented edit id
        name:
          type: string
          description: name of the edit
        description:
          type: string
          description: description of the edit
        author:
          type: string
          description: Name of the user
        trackId:
          type: integer
          description: the unique key used by netflix to reference each video. Eg, 'https://www.netflix.com/watch/81088080?trackId=254015180.......' the trackId will be 81088080 and NOT 254015180
        createdDate:
          type: string
          format: date
          description: the date this edit was created by the user
        isPrivate:
          type: boolean
          description: indicates whether its a private edit or not
        tag:
          type: strins 
          description: tag name to the edit
        like:
          type: integer
          description: number of like to the edit
        dislike:
          type: integer
          description: number of dislike to the edit
        klips:
          type: array
          items:
              $ref: '#/components/schemas/Klip'
    UpdateEdit:
      type: object
      title: Schema for Edit Updates
      properties:
        name:
          type: string
          description: name of the edit
        description:
          type: string
          description: description of the edit
        isPrivate:
          type: boolean
          description: indicates whether its a private edit or not
        tags:
          type: string
          description: tag name to the edit
        klips:
          type: array
          items:
              $ref: '#/components/schemas/Klip'    
  responses:
    UnauthorizedError:
      description: Access token is missing or invalid
  securitySchemes:
    bearerAuth:            # arbitrary name for the security scheme
      type: http
      scheme: bearer
      bearerFormat: JWT 