openapi: 3.0.3
info:
  title: Repzo API - Contract
  version: 1.0.0
  description: OpenAPI specification for Repzo Contract endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /contract:
    get:
      summary: Find contracts
      operationId: findContracts
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering contracts
      responses:
        "200":
          description: A list of contracts
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractFindResult"
    post:
      summary: Create a contract
      operationId: createContract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractCreateBody"
      responses:
        "201":
          description: Contract created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractCreateResult"
  /contract/{id}:
    get:
      summary: Get a contract by ID
      operationId: getContract
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Contract details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractGetResult"
    put:
      summary: Update a contract
      operationId: updateContract
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractUpdateBody"
      responses:
        "200":
          description: Contract updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractUpdateResult"
    delete:
      summary: Remove a contract
      operationId: removeContract
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Contract removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContractRemoveResult"
components:
  schemas:
    ContractFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Contract"
        meta:
          type: object
    ContractCreateBody:
      type: object
      properties:
        title:
          type: string
        client:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        totalAmount:
          type: number
        currency:
          type: string
        status:
          type: string
        terms:
          type: string
        installments:
          type: array
          items:
            type: object
    ContractCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Contract"
    ContractGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Contract"
    ContractUpdateBody:
      type: object
      properties:
        title:
          type: string
        client:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        totalAmount:
          type: number
        currency:
          type: string
        status:
          type: string
        terms:
          type: string
        installments:
          type: array
          items:
            type: object
    ContractUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Contract"
    ContractRemoveResult:
      type: object
      properties:
        success:
          type: boolean
    Contract:
      type: object
      properties:
        _id:
          type: string
        title:
          type: string
        client:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        totalAmount:
          type: number
        currency:
          type: string
        status:
          type: string
        terms:
          type: string
        installments:
          type: array
          items:
            type: object
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
