openapi: 3.0.3
info:
  title: Repzo API - Proforma
  version: 1.0.0
  description: OpenAPI specification for Repzo Proforma endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /proforma:
    get:
      summary: Find proformas
      operationId: findProformas
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering proformas
      responses:
        "200":
          description: A list of proformas
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProformaFindResult"
    post:
      summary: Create a proforma
      operationId: createProforma
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProformaCreateBody"
      responses:
        "201":
          description: Proforma created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProformaCreateResult"
  /proforma/{id}:
    get:
      summary: Get a proforma by ID
      operationId: getProforma
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Proforma details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProformaGetResult"
    put:
      summary: Update a proforma
      operationId: updateProforma
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProformaUpdateBody"
      responses:
        "200":
          description: Proforma updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProformaUpdateResult"
components:
  schemas:
    ProformaFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Proforma"
        meta:
          type: object
    ProformaCreateBody:
      type: object
      properties:
        serial:
          type: string
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        validUntil:
          type: string
          format: date-time
    ProformaCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Proforma"
    ProformaGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Proforma"
    ProformaUpdateBody:
      type: object
      properties:
        serial:
          type: string
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        validUntil:
          type: string
          format: date-time
    ProformaUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Proforma"
    Proforma:
      type: object
      properties:
        _id:
          type: string
        serial:
          type: string
        client:
          type: string
        rep:
          type: string
        warehouse:
          type: string
        items:
          type: array
          items:
            type: object
        total:
          type: number
        status:
          type: string
        validUntil:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
