openapi: 3.0.3
info:
  title: Repzo API - MSL
  version: 1.0.0
  description: OpenAPI specification for Repzo MSL (Most Sold List) endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /msl:
    get:
      summary: Find MSLs
      operationId: findMSLs
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering MSLs
      responses:
        "200":
          description: A list of MSLs
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MSLFindResult"
    post:
      summary: Create an MSL
      operationId: createMSL
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MSLCreateBody"
      responses:
        "201":
          description: MSL created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MSLCreateResult"
  /msl/{id}:
    get:
      summary: Get an MSL by ID
      operationId: getMSL
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: MSL details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MSLGetResult"
    put:
      summary: Update an MSL
      operationId: updateMSL
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MSLUpdateBody"
      responses:
        "200":
          description: MSL updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MSLUpdateResult"
    delete:
      summary: Remove an MSL
      operationId: removeMSL
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: MSL removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MSLRemoveResult"
components:
  schemas:
    MSLFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MSL"
        meta:
          type: object
    MSLCreateBody:
      type: object
      properties:
        name:
          type: string
        client:
          type: string
        rep:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        disabled:
          type: boolean
    MSLCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/MSL"
    MSLGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/MSL"
    MSLUpdateBody:
      type: object
      properties:
        name:
          type: string
        client:
          type: string
        rep:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        disabled:
          type: boolean
    MSLUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/MSL"
    MSLRemoveResult:
      type: object
      properties:
        success:
          type: boolean
    MSL:
      type: object
      properties:
        _id:
          type: string
        name:
          type: string
        client:
          type: string
        rep:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        disabled:
          type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
