openapi: 3.0.3
info:
  title: Repzo API - Transfer
  version: 1.0.0
  description: OpenAPI specification for Repzo Transfer endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /transfer:
    get:
      summary: Find transfers
      operationId: findTransfers
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              fromWarehouse:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              toWarehouse:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              rep:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              status:
                type: string
                enum: [pending, in_transit, completed, cancelled]
              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, transferDate]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering transfers
      responses:
        "200":
          description: A list of transfers
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TransferFindResult"
    post:
      summary: Create a transfer
      operationId: createTransfer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TransferCreateBody"
      responses:
        "201":
          description: Transfer created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TransferCreateResult"
  /transfer/{id}:
    get:
      summary: Get a transfer by ID
      operationId: getTransfer
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Transfer details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TransferGetResult"
    put:
      summary: Update a transfer
      operationId: updateTransfer
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TransferUpdateBody"
      responses:
        "200":
          description: Transfer updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TransferUpdateResult"
components:
  schemas:
    TransferFindResult:
      type: object
      description: Result of finding transfers
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TransferSchema"
        total_result:
          type: number
          description: Total number of transfers
        current_count:
          type: number
          description: Count of transfers 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 transfers per page
    TransferSchema:
      type: object
      description: Transfer schema
      properties:
        _id:
          type: string
          description: Unique identifier for the transfer
        transferNumber:
          type: string
          description: Transfer reference number
        fromWarehouse:
          type: string
          description: Source warehouse ID
        toWarehouse:
          type: string
          description: Destination warehouse ID
        rep:
          type: string
          description: Representative ID who initiated the transfer
        transferDate:
          type: string
          format: date-time
          description: Date when transfer was initiated
        expectedDate:
          type: string
          format: date-time
          description: Expected delivery date
        completedDate:
          type: string
          format: date-time
          description: Date when transfer was completed
        status:
          type: string
          enum: [pending, in_transit, completed, cancelled]
          description: Status of the transfer
        items:
          type: array
          items:
            type: object
            properties:
              product:
                type: string
                description: Product ID
              variant:
                type: string
                description: Product variant ID
              requestedQuantity:
                type: number
                description: Requested quantity to transfer
              sentQuantity:
                type: number
                description: Actually sent quantity
              receivedQuantity:
                type: number
                description: Actually received quantity
              unitCost:
                type: number
                description: Unit cost of the item
          description: List of items being transferred
        totalValue:
          type: number
          description: Total value of the transfer
        reason:
          type: string
          description: Reason for the transfer
        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
    TransferCreateBody:
      type: object
      description: Body for creating a transfer
      required:
        - fromWarehouse
        - toWarehouse
        - items
      properties:
        fromWarehouse:
          type: string
          description: Source warehouse ID
        toWarehouse:
          type: string
          description: Destination warehouse ID
        rep:
          type: string
          description: Representative ID who initiated the transfer
        expectedDate:
          type: string
          format: date-time
          description: Expected delivery date
        items:
          type: array
          items:
            type: object
            properties:
              product:
                type: string
                description: Product ID
              variant:
                type: string
                description: Product variant ID
              requestedQuantity:
                type: number
                description: Requested quantity to transfer
              unitCost:
                type: number
                description: Unit cost of the item
          description: List of items being transferred
        reason:
          type: string
          description: Reason for the transfer
        notes:
          type: string
          description: Additional notes
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    TransferCreateResult:
      $ref: "#/components/schemas/TransferSchema"
      description: Result of creating a transfer
    TransferGetResult:
      $ref: "#/components/schemas/TransferSchema"
      description: Result of getting a transfer
    TransferUpdateBody:
      type: object
      description: Body for updating a transfer
      properties:
        expectedDate:
          type: string
          format: date-time
          description: Expected delivery date
        status:
          type: string
          enum: [pending, in_transit, completed, cancelled]
          description: Status of the transfer
        items:
          type: array
          items:
            type: object
            properties:
              product:
                type: string
                description: Product ID
              variant:
                type: string
                description: Product variant ID
              requestedQuantity:
                type: number
                description: Requested quantity to transfer
              sentQuantity:
                type: number
                description: Actually sent quantity
              receivedQuantity:
                type: number
                description: Actually received quantity
              unitCost:
                type: number
                description: Unit cost of the item
          description: List of items being transferred
        notes:
          type: string
          description: Additional notes
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    TransferUpdateResult:
      $ref: "#/components/schemas/TransferSchema"
      description: Result of updating a transfer
