openapi: 3.0.3
info:
  title: Object Sync API Schemas
  description: OpenAPI specification for object-sync service data models
  version: 1.0.0

components:
  schemas:
    Asset:
      type: object
      description: Represents an asset in the system
      properties:
        id:
          type: string
          description: Unique identifier for the asset (global_id)
          example: "550e8400-e29b-41d4-a716-446655440000"
        name:
          type: string
          description: Asset name/serial number
          example: "ASSET-001"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        boxId:
          type: string
          description: Box global ID (optional)
          example: "770e8400-e29b-41d4-a716-446655440002"
          nullable: true
        disabled:
          type: boolean
          description: Whether the asset is disabled
          example: false
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the asset was created
          example: "2024-01-15T10:30:00Z"
        whenUpdated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the asset was last updated
          example: "2024-01-15T10:30:00Z"
        note:
          type: string
          description: Optional note about the asset
          example: "Main warehouse asset"
          nullable: true
        tags:
          type: array
          items:
            type: string
          description: Array of customer tags associated with the asset
          example: ["warehouse", "priority"]
          nullable: true
      required:
        - id
        - name
        - ownerId
        - whenCreated
        - whenUpdated

    Location:
      type: object
      description: Represents a GPS location record
      properties:
        id:
          type: integer
          format: int64
          description: Unique identifier for the location record
          example: 12345
        assetId:
          type: string
          description: Asset global ID
          example: "550e8400-e29b-41d4-a716-446655440000"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the location was recorded (GPS time)
          example: "2024-01-15T10:30:00Z"
        latitude:
          type: number
          format: double
          description: GPS latitude coordinate
          example: 64.1265
        longitude:
          type: number
          format: double
          description: GPS longitude coordinate
          example: -21.8174
        altitude:
          type: number
          format: double
          description: GPS altitude in meters (optional)
          example: 50.5
          nullable: true
        speed:
          type: number
          format: double
          description: Speed in the unit configured for the asset (optional)
          example: 25.5
          nullable: true
        heading:
          type: number
          format: double
          description: Heading/bearing in degrees (0-360) (optional)
          example: 180.5
          nullable: true
        zoneId:
          type: string
          description: Zone identifier where the location was recorded (optional)
          example: "zone-123"
          nullable: true
      required:
        - id
        - assetId
        - ownerId
        - whenCreated
        - latitude
        - longitude

    SensorData:
      type: object
      description: Represents sensor data from an asset
      properties:
        id:
          type: integer
          format: int64
          description: Unique identifier for the sensor data record
          example: 12345
        assetId:
          type: string
          description: Asset global ID
          example: "550e8400-e29b-41d4-a716-446655440000"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        sensorId:
          type: string
          description: Sensor identifier
          example: "sensor-001"
        sensorType:
          type: string
          description: Type of sensor
          example: "temperature"
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the sensor data was recorded
          example: "2024-01-15T10:30:00Z"
        when_received:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds when the data was received (optional)
          example: 1705315800000
          nullable: true
        value:
          type: string
          description: Sensor value (can be string representation of number or text)
          example: "25.5"
        type:
          type: string
          description: Data type of the sensor value
          example: "DECIMAL"
      required:
        - id
        - assetId
        - ownerId
        - sensorId
        - sensorType
        - whenCreated
        - value
        - type

    ReeferData:
      type: object
      description: Represents reefer (refrigerated container) data
      properties:
        id:
          type: integer
          format: int64
          description: Unique identifier for the reefer data record
          example: 12345
        assetId:
          type: string
          description: Asset global ID
          example: "550e8400-e29b-41d4-a716-446655440000"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the reefer data was recorded
          example: "2024-01-15T10:30:00Z"
        reeferClass:
          type: string
          description: Class/type of reefer unit
          example: "CARRIER"
        data:
          type: object
          description: JSON object containing reefer-specific data payload
          additionalProperties: true
          example:
            temperature: 4.5
            humidity: 60
            setpoint: 4.0
      required:
        - id
        - assetId
        - ownerId
        - whenCreated
        - reeferClass
        - data

    GensetData:
      type: object
      description: Represents generator set (genset) data
      properties:
        id:
          type: integer
          format: int64
          description: Unique identifier for the genset data record
          example: 12345
        assetId:
          type: string
          description: Asset global ID
          example: "550e8400-e29b-41d4-a716-446655440000"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        boxId:
          type: string
          description: Box global ID (optional)
          example: "770e8400-e29b-41d4-a716-446655440002"
          nullable: true
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the genset data was recorded
          example: "2024-01-15T10:30:00Z"
        gensetType:
          type: string
          description: Type/model of genset
          example: "CAT_C7"
        data:
          type: object
          description: JSON object containing genset-specific data payload
          additionalProperties: true
          example:
            fuelLevel: 75
            runtime: 1250
            voltage: 12.5
      required:
        - id
        - assetId
        - ownerId
        - whenCreated
        - gensetType
        - data

    GtoemData:
      type: object
      description: Represents GTOEM (Globetracker OEM) data
      properties:
        id:
          type: integer
          format: int64
          description: Unique identifier for the GTOEM data record
          example: 12345
        assetId:
          type: string
          description: Asset global ID
          example: "550e8400-e29b-41d4-a716-446655440000"
        ownerId:
          type: string
          description: Owner/customer global ID
          example: "660e8400-e29b-41d4-a716-446655440001"
        boxId:
          type: string
          description: Box global ID (optional)
          example: "770e8400-e29b-41d4-a716-446655440002"
          nullable: true
        whenCreated:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the GTOEM data was created (opaque_when_received)
          example: "2024-01-15T10:30:00Z"
        when_received:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds when the data was received (optional)
          example: 1705315800000
          nullable: true
        payloadType:
          type: integer
          format: int32
          description: Type identifier for the payload
          example: 1
        data:
          type: object
          description: JSON object containing GTOEM-specific data payload
          additionalProperties: true
          example:
            version: "1.0"
            firmware: "2.3.4"
            customField: "value"
      required:
        - id
        - assetId
        - ownerId
        - whenCreated
        - payloadType
        - data

