openapi: 3.0.3
info:
  title: Repzo API - Line Target
  version: 1.0.0
  description: OpenAPI specification for Repzo Line Target endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /line-target:
    get:
      summary: Find line targets
      operationId: findLineTargets
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering line targets
      responses:
        "200":
          description: A list of line targets
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetFindResult"
    post:
      summary: Create a line target
      operationId: createLineTarget
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LineTargetCreateBody"
      responses:
        "201":
          description: Line target created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetCreateResult"
    delete:
      summary: Remove many line targets matching the query
      operationId: removeManyLineTargets
      parameters:
        - in: query
          name: all
          schema:
            type: boolean
          description: When true, deletes all line targets matching the query
      responses:
        "200":
          description: Bulk delete result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetRemoveResult"
  /line-target/{id}:
    get:
      summary: Get a line target by ID
      operationId: getLineTarget
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Line target details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetGetResult"
    put:
      summary: Update a line target
      operationId: updateLineTarget
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LineTargetUpdateBody"
      responses:
        "200":
          description: Line target updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetUpdateResult"
    delete:
      summary: Remove a line target
      operationId: removeLineTarget
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Line target removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LineTargetRemoveResult"
components:
  schemas:
    LineTargetUser:
      type: object
      properties:
        _id:
          type: string
        name:
          type: string
        type:
          type: string
          enum: [rep, client]
        rep:
          type: string
        client:
          type: string
    LineTargetFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/LineTarget"
        meta:
          type: object
    LineTargetCreateBody:
      type: object
      required:
        - line
        - target
        - classification
      properties:
        line:
          type: string
        target:
          type: number
        classification:
          type: string
        user:
          $ref: "#/components/schemas/LineTargetUser"
    LineTargetCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/LineTarget"
    LineTargetGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/LineTarget"
    LineTargetUpdateBody:
      type: object
      properties:
        line:
          type: string
        target:
          type: number
        classification:
          type: string
        user:
          $ref: "#/components/schemas/LineTargetUser"
    LineTargetUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/LineTarget"
    LineTargetRemoveResult:
      type: object
      properties:
        deletedCount:
          type: number
        success:
          type: number
    LineTarget:
      type: object
      properties:
        _id:
          type: string
        line:
          type: string
        target:
          type: number
        classification:
          type: string
        user:
          $ref: "#/components/schemas/LineTargetUser"
        company_namespace:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
