openapi: 3.0.3
info:
  title: Repzo API - Checks
  version: 1.0.0
  description: OpenAPI specification for Repzo Checks endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /checks:
    get:
      summary: Find checks
      operationId: findChecks
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              client:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              rep:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              checkNumber:
                type: string
              status:
                type: string
                enum: [pending, cleared, bounced, cancelled]
              bank:
                type: string
              from_date:
                type: string
                format: date-time
              to_date:
                type: string
                format: date-time
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id, createdAt, updatedAt, amount, dueDate]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering checks
      responses:
        "200":
          description: A list of checks
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CheckFindResult"
    post:
      summary: Create a check
      operationId: createCheck
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CheckCreateBody"
      responses:
        "201":
          description: Check created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CheckCreateResult"
  /checks/{id}:
    get:
      summary: Get a check by ID
      operationId: getCheck
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Check details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CheckGetResult"
components:
  schemas:
    CheckFindResult:
      type: object
      description: Result of finding checks
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CheckSchema"
        total_result:
          type: number
          description: Total number of checks
        current_count:
          type: number
          description: Count of checks in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of checks per page
    CheckSchema:
      type: object
      description: Check schema
      properties:
        _id:
          type: string
          description: Unique identifier for the check
        client:
          type: string
          description: Client ID associated with the check
        rep:
          type: string
          description: Representative ID who received the check
        checkNumber:
          type: string
          description: Check number
        amount:
          type: number
          description: Check amount
        bank:
          type: string
          description: Bank name or ID
        accountNumber:
          type: string
          description: Account number
        issueDate:
          type: string
          format: date-time
          description: Date when check was issued
        dueDate:
          type: string
          format: date-time
          description: Due date of the check
        status:
          type: string
          enum: [pending, cleared, bounced, cancelled]
          description: Status of the check
        clearedDate:
          type: string
          format: date-time
          description: Date when check was cleared
        notes:
          type: string
          description: Additional notes
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    CheckCreateBody:
      type: object
      description: Body for creating a check
      required:
        - client
        - checkNumber
        - amount
        - bank
        - dueDate
      properties:
        client:
          type: string
          description: Client ID associated with the check
        rep:
          type: string
          description: Representative ID who received the check
        checkNumber:
          type: string
          description: Check number
        amount:
          type: number
          description: Check amount
        bank:
          type: string
          description: Bank name or ID
        accountNumber:
          type: string
          description: Account number
        issueDate:
          type: string
          format: date-time
          description: Date when check was issued
        dueDate:
          type: string
          format: date-time
          description: Due date of the check
        notes:
          type: string
          description: Additional notes
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    CheckCreateResult:
      $ref: "#/components/schemas/CheckSchema"
      description: Result of creating a check
    CheckGetResult:
      $ref: "#/components/schemas/CheckSchema"
      description: Result of getting a check
