openapi: 3.0.3
info:
  title: Repzo API - Warehouse
  version: 1.0.0
  description: OpenAPI specification for Repzo Warehouse endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /warehouse:
    get:
      summary: Find warehouses
      operationId: findWarehouses
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering warehouses
      responses:
        "200":
          description: A list of warehouses
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WarehouseFindResult"
    post:
      summary: Create a warehouse
      operationId: createWarehouse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WarehouseCreateBody"
      responses:
        "201":
          description: Warehouse created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WarehouseCreateResult"
  /warehouse/{id}:
    get:
      summary: Get a warehouse by ID
      operationId: getWarehouse
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Warehouse details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WarehouseGetResult"
    put:
      summary: Update a warehouse
      operationId: updateWarehouse
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WarehouseUpdateBody"
      responses:
        "200":
          description: Warehouse updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WarehouseUpdateResult"
    delete:
      summary: Remove a warehouse
      operationId: removeWarehouse
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Warehouse removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WarehouseRemoveResult"
components:
  schemas:
    WarehouseFindResult:
      type: object
      description: Result of finding warehouses
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WarehouseSchema"
        total_result:
          type: number
          description: Total number of warehouses
        current_count:
          type: number
          description: Count of warehouses 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 warehouses per page
        first_page_url:
          type: string
          description: URL for the first page
        last_page_url:
          type: string
          description: URL for the last page
        next_page_url:
          type: string
          nullable: true
          description: URL for the next page
        prev_page_url:
          type: string
          nullable: true
          description: URL for the previous page
        path:
          type: string
          description: Base URL path
    WarehouseSchema:
      type: object
      description: Warehouse schema
      properties:
        _id:
          type: string
          description: Unique identifier for the warehouse
        name:
          type: string
          description: Name of the warehouse
        location:
          type: object
          description: Geographic location of the warehouse
          properties:
            type:
              type: string
              enum: [Point]
              description: Type of geolocation
            coordinates:
              type: array
              items:
                type: number
              description: Coordinates [longitude, latitude]
        disabled:
          type: boolean
          description: Whether the warehouse is disabled
        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
    WarehouseCreateBody:
      type: object
      description: Body for creating a warehouse
      required:
        - name
        - company_namespace
      properties:
        name:
          type: string
          description: Name of the warehouse
        location:
          type: object
          description: Geographic location of the warehouse
          properties:
            type:
              type: string
              enum: [Point]
              description: Type of geolocation
            coordinates:
              type: array
              items:
                type: number
              description: Coordinates [longitude, latitude]
        disabled:
          type: boolean
          description: Whether the warehouse is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    WarehouseCreateResult:
      $ref: "#/components/schemas/WarehouseSchema"
      description: Result of creating a warehouse
    WarehouseGetResult:
      $ref: "#/components/schemas/WarehouseSchema"
      description: Result of getting a warehouse
    WarehouseUpdateBody:
      type: object
      description: Body for updating a warehouse
      properties:
        name:
          type: string
          description: Name of the warehouse
        location:
          type: object
          description: Geographic location of the warehouse
          properties:
            type:
              type: string
              enum: [Point]
              description: Type of geolocation
            coordinates:
              type: array
              items:
                type: number
              description: Coordinates [longitude, latitude]
        disabled:
          type: boolean
          description: Whether the warehouse is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        _id:
          type: string
          description: Unique identifier for the warehouse
        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
    WarehouseUpdateResult:
      $ref: "#/components/schemas/WarehouseSchema"
      description: Result of updating a warehouse
    WarehouseRemoveResult:
      $ref: "#/components/schemas/WarehouseSchema"
      description: Result of removing a warehouse
