openapi: 3.0.3
info:
  title: Repzo API - Payments
  version: 1.0.0
  description: OpenAPI specification for Repzo Payments endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /payments:
    get:
      summary: Find payments
      operationId: findPayments
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering payments
      responses:
        "200":
          description: A list of payments
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentFindResult"
    post:
      summary: Create a payment
      operationId: createPayment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentCreateBody"
      responses:
        "201":
          description: Payment created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentCreateResult"
  /payments/{id}:
    get:
      summary: Get a payment by ID
      operationId: getPayment
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Payment details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentGetResult"
    put:
      summary: Update a payment
      operationId: updatePayment
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentUpdateBody"
      responses:
        "200":
          description: Payment updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentUpdateResult"
components:
  schemas:
    PaymentFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Payment"
        meta:
          type: object
    PaymentCreateBody:
      type: object
      properties:
        client:
          type: string
        rep:
          type: string
        amount:
          type: number
        paymentMethod:
          type: string
        reference:
          type: string
        description:
          type: string
        date:
          type: string
          format: date-time
    PaymentCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Payment"
    PaymentGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Payment"
    PaymentUpdateBody:
      type: object
      properties:
        client:
          type: string
        rep:
          type: string
        amount:
          type: number
        paymentMethod:
          type: string
        reference:
          type: string
        description:
          type: string
        date:
          type: string
          format: date-time
    PaymentUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Payment"
    Payment:
      type: object
      properties:
        _id:
          type: string
        client:
          type: string
        rep:
          type: string
        amount:
          type: number
        paymentMethod:
          type: string
        reference:
          type: string
        description:
          type: string
        date:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
