openapi: 3.0.0
info:
  title: Store Asset Part Unit API
  description: API for managing asset part unit storage operations
  version: 1.0.0
  contact:
    name: Repzo
    url: https://repzo.com

servers:
  - url: https://sv.api.repzo.me
    description: Production server
  - url: https://staging.sv.api.repzo.me
    description: Staging server

tags:
  - name: Store Asset Part Unit
    description: Operations related to storing asset part units

paths:
  /store-asset-part-unit:
    get:
      tags:
        - Store Asset Part Unit
      summary: Get all asset part unit storage records
      description: Retrieve a list of all asset part unit storage records with optional filtering and pagination
      parameters:
        - name: limit
          in: query
          description: Maximum number of records to return
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: offset
          in: query
          description: Number of records to skip for pagination
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: sort
          in: query
          description: Field to sort by
          required: false
          schema:
            type: string
        - name: order
          in: query
          description: Sort order (asc or desc)
          required: false
          schema:
            type: string
            enum: [asc, desc]
            default: desc
        - name: filter
          in: query
          description: Filter conditions in JSON format
          required: false
          schema:
            type: string
        - name: search
          in: query
          description: Search term for text fields
          required: false
          schema:
            type: string
      responses:
        "200":
          description: List of asset part unit storage records retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/StoreAssetPartUnit"
                  total:
                    type: integer
                    description: Total number of records
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    post:
      tags:
        - Store Asset Part Unit
      summary: Create a new asset part unit storage record
      description: Create a new asset part unit storage record with the provided data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StoreAssetPartUnitInput"
      responses:
        "201":
          description: Asset part unit storage record created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/StoreAssetPartUnit"
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

  /store-asset-part-unit/{id}:
    get:
      tags:
        - Store Asset Part Unit
      summary: Get asset part unit storage record by ID
      description: Retrieve a specific asset part unit storage record by its ID
      parameters:
        - name: id
          in: path
          required: true
          description: Asset part unit storage record ID
          schema:
            type: string
      responses:
        "200":
          description: Asset part unit storage record retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/StoreAssetPartUnit"
        "404":
          description: Asset part unit storage record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    put:
      tags:
        - Store Asset Part Unit
      summary: Update asset part unit storage record
      description: Update an existing asset part unit storage record with new data
      parameters:
        - name: id
          in: path
          required: true
          description: Asset part unit storage record ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StoreAssetPartUnitInput"
      responses:
        "200":
          description: Asset part unit storage record updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/StoreAssetPartUnit"
        "400":
          description: Bad request
        "404":
          description: Asset part unit storage record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    delete:
      tags:
        - Store Asset Part Unit
      summary: Delete asset part unit storage record
      description: Delete an existing asset part unit storage record
      parameters:
        - name: id
          in: path
          required: true
          description: Asset part unit storage record ID
          schema:
            type: string
      responses:
        "200":
          description: Asset part unit storage record deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Asset part unit storage record deleted successfully
        "404":
          description: Asset part unit storage record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

components:
  schemas:
    StoreAssetPartUnit:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier for the storage record
          example: "60f7b1b3e4b0e8b3f8b3f8b3"
        storageNumber:
          type: string
          description: Unique storage number
          example: "STR-2023-001"
        assetPartUnit:
          type: string
          description: Asset part unit ID being stored
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        serialNumber:
          type: string
          description: Serial number of the part unit
          example: "SN-EP001-2023-001"
        storageType:
          type: string
          enum: [inventory, spare, buffer, quarantine, maintenance]
          description: Type of storage
          example: "inventory"
        storageReason:
          type: string
          description: Reason for storage
          example: "New inventory received"
        storedBy:
          type: string
          description: User who stored the part
          example: "60f7b1b3e4b0e8b3f8b3f8b5"
        authorizedBy:
          type: string
          description: User who authorized the storage
          example: "60f7b1b3e4b0e8b3f8b3f8b6"
        storageDate:
          type: string
          format: date-time
          description: Date when the part was stored
          example: "2023-01-15T10:00:00Z"
        expectedRetrievalDate:
          type: string
          format: date-time
          description: Expected retrieval date
          example: "2023-06-15T10:00:00Z"
        location:
          type: object
          properties:
            warehouse:
              type: string
              description: Warehouse ID
            section:
              type: string
              description: Section within warehouse
            shelf:
              type: string
              description: Shelf identifier
            position:
              type: string
              description: Position on shelf
            bin:
              type: string
              description: Bin identifier
            coordinates:
              type: object
              properties:
                x:
                  type: number
                  description: X coordinate
                y:
                  type: number
                  description: Y coordinate
                z:
                  type: number
                  description: Z coordinate (height)
        status:
          type: string
          enum: [stored, reserved, allocated, picked, expired]
          default: stored
          description: Current storage status
        condition:
          type: string
          enum: [new, good, fair, poor, damaged]
          description: Condition when stored
          example: "new"
        storageEnvironment:
          type: object
          properties:
            temperature:
              type: object
              properties:
                min:
                  type: number
                  description: Minimum temperature
                max:
                  type: number
                  description: Maximum temperature
                unit:
                  type: string
                  enum: [celsius, fahrenheit]
                  default: celsius
            humidity:
              type: object
              properties:
                min:
                  type: number
                  description: Minimum humidity percentage
                max:
                  type: number
                  description: Maximum humidity percentage
            specialRequirements:
              type: array
              items:
                type: string
                enum: [dry, cool, dark, ventilated, climate-controlled]
        preservationMethod:
          type: string
          enum: [none, plastic-wrap, desiccant, vacuum-seal, oil-coating]
          default: none
          description: Preservation method used
        lastInspectionDate:
          type: string
          format: date-time
          description: Last inspection date
        nextInspectionDate:
          type: string
          format: date-time
          description: Next scheduled inspection date
        reservedFor:
          type: object
          properties:
            workOrder:
              type: string
              description: Work order ID if reserved
            asset:
              type: string
              description: Asset ID if reserved
            project:
              type: string
              description: Project ID if reserved
            reservationDate:
              type: string
              format: date-time
              description: Reservation date
            reservedBy:
              type: string
              description: User who made the reservation
        tags:
          type: array
          items:
            type: string
          description: Storage tags for categorization
        barcode:
          type: string
          description: Storage barcode
        qrCode:
          type: string
          description: Storage QR code
        weight:
          type: number
          format: double
          minimum: 0
          description: Weight of the stored item
        dimensions:
          type: object
          properties:
            length:
              type: number
              format: double
              minimum: 0
            width:
              type: number
              format: double
              minimum: 0
            height:
              type: number
              format: double
              minimum: 0
            unit:
              type: string
              enum: [mm, cm, m, inch, ft]
              default: cm
        storageHistory:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
                format: date-time
              action:
                type: string
                enum: [stored, moved, inspected, reserved, released]
              performedBy:
                type: string
              fromLocation:
                type: string
              toLocation:
                type: string
              notes:
                type: string
        notes:
          type: string
          description: Additional notes
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
        createdAt:
          type: string
          format: date-time
          description: Record creation timestamp
          example: "2023-01-15T08:00:00Z"
        updatedAt:
          type: string
          format: date-time
          description: Record last update timestamp
          example: "2023-01-15T10:30:00Z"
      required:
        - storageNumber
        - assetPartUnit
        - storageType
        - storedBy
        - location

    StoreAssetPartUnitInput:
      type: object
      properties:
        storageNumber:
          type: string
          description: Unique storage number
          example: "STR-2023-001"
        assetPartUnit:
          type: string
          description: Asset part unit ID being stored
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        serialNumber:
          type: string
          description: Serial number of the part unit
          example: "SN-EP001-2023-001"
        storageType:
          type: string
          enum: [inventory, spare, buffer, quarantine, maintenance]
          description: Type of storage
          example: "inventory"
        storageReason:
          type: string
          description: Reason for storage
          example: "New inventory received"
        storedBy:
          type: string
          description: User who stored the part
          example: "60f7b1b3e4b0e8b3f8b3f8b5"
        authorizedBy:
          type: string
          description: User who authorized the storage
          example: "60f7b1b3e4b0e8b3f8b3f8b6"
        storageDate:
          type: string
          format: date-time
          description: Date when the part was stored
          example: "2023-01-15T10:00:00Z"
        expectedRetrievalDate:
          type: string
          format: date-time
          description: Expected retrieval date
          example: "2023-06-15T10:00:00Z"
        location:
          type: object
          properties:
            warehouse:
              type: string
              description: Warehouse ID
            section:
              type: string
              description: Section within warehouse
            shelf:
              type: string
              description: Shelf identifier
            position:
              type: string
              description: Position on shelf
            bin:
              type: string
              description: Bin identifier
            coordinates:
              type: object
              properties:
                x:
                  type: number
                  description: X coordinate
                y:
                  type: number
                  description: Y coordinate
                z:
                  type: number
                  description: Z coordinate (height)
        status:
          type: string
          enum: [stored, reserved, allocated, picked, expired]
          default: stored
          description: Current storage status
        condition:
          type: string
          enum: [new, good, fair, poor, damaged]
          description: Condition when stored
          example: "new"
        storageEnvironment:
          type: object
          properties:
            temperature:
              type: object
              properties:
                min:
                  type: number
                  description: Minimum temperature
                max:
                  type: number
                  description: Maximum temperature
                unit:
                  type: string
                  enum: [celsius, fahrenheit]
                  default: celsius
            humidity:
              type: object
              properties:
                min:
                  type: number
                  description: Minimum humidity percentage
                max:
                  type: number
                  description: Maximum humidity percentage
            specialRequirements:
              type: array
              items:
                type: string
                enum: [dry, cool, dark, ventilated, climate-controlled]
        preservationMethod:
          type: string
          enum: [none, plastic-wrap, desiccant, vacuum-seal, oil-coating]
          default: none
          description: Preservation method used
        lastInspectionDate:
          type: string
          format: date-time
          description: Last inspection date
        nextInspectionDate:
          type: string
          format: date-time
          description: Next scheduled inspection date
        reservedFor:
          type: object
          properties:
            workOrder:
              type: string
              description: Work order ID if reserved
            asset:
              type: string
              description: Asset ID if reserved
            project:
              type: string
              description: Project ID if reserved
            reservationDate:
              type: string
              format: date-time
              description: Reservation date
            reservedBy:
              type: string
              description: User who made the reservation
        tags:
          type: array
          items:
            type: string
          description: Storage tags for categorization
        barcode:
          type: string
          description: Storage barcode
        qrCode:
          type: string
          description: Storage QR code
        weight:
          type: number
          format: double
          minimum: 0
          description: Weight of the stored item
        dimensions:
          type: object
          properties:
            length:
              type: number
              format: double
              minimum: 0
            width:
              type: number
              format: double
              minimum: 0
            height:
              type: number
              format: double
              minimum: 0
            unit:
              type: string
              enum: [mm, cm, m, inch, ft]
              default: cm
        notes:
          type: string
          description: Additional notes
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
      required:
        - storageNumber
        - assetPartUnit
        - storageType
        - storedBy
        - location

  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

security:
  - ApiKeyAuth: []
