openapi: 3.0.3
info:
  title: Repzo API - Supplier
  version: 1.0.0
  description: OpenAPI specification for Repzo Supplier endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /supplier:
    get:
      summary: Find suppliers
      operationId: findSuppliers
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering suppliers
      responses:
        "200":
          description: A list of suppliers
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierFindResult"
    post:
      summary: Create a supplier
      operationId: createSupplier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SupplierCreateBody"
      responses:
        "201":
          description: Supplier created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierCreateResult"
  /supplier/{id}:
    get:
      summary: Get a supplier by ID
      operationId: getSupplier
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Supplier details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierGetResult"
    put:
      summary: Update a supplier
      operationId: updateSupplier
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SupplierUpdateBody"
      responses:
        "200":
          description: Supplier updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierUpdateResult"
    delete:
      summary: Remove a supplier
      operationId: removeSupplier
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Supplier removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierRemoveResult"
components:
  schemas:
    SupplierFindResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Supplier"
        meta:
          type: object
    SupplierCreateBody:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        address:
          type: object
        integration_meta:
          type: object
        disabled:
          type: boolean
    SupplierCreateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Supplier"
    SupplierGetResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Supplier"
    SupplierUpdateBody:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        address:
          type: object
        integration_meta:
          type: object
        disabled:
          type: boolean
    SupplierUpdateResult:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Supplier"
    SupplierRemoveResult:
      type: object
      properties:
        success:
          type: boolean
    Supplier:
      type: object
      properties:
        _id:
          type: string
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        address:
          type: object
        integration_meta:
          type: object
        disabled:
          type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
