openapi: 3.1.0
info:
  title: Tango Asset Details Inbound API
  version: "0.4"
  description: |
    Async REST API: client system PUTs asset detail records to Tango. Tango
    acknowledges synchronously with a `gu_id`; client polls /v1/batch/status
    for processing outcomes.

    NOTE on direction: the source design doc's header lists
    `Source: tango / Destination: client system`, but the General Description
    says "post details of newly created/updated assets to Tango" — i.e. an
    inbound flow. This spec treats it as inbound (Client → Tango), matching
    the description. The header inconsistency is flagged in Open Questions.
  x-direction: inbound
  x-source: Client System
  x-destination: Tango
servers:
  - url: https://api.tangoanalytics.com
    description: Production (host TBD per source — placeholder)
  - url: https://testapi.tangoanalytics.com
    description: Test (host TBD per source — placeholder)
tags:
  - name: Assets
  - name: Status
paths:
  /v1/assetmgmt/batch/assets:
    put:
      summary: Submit asset detail records (async)
      description: |
        URL path is `<TBD>` per the source doc; `/v1/assetmgmt/batch/assets` is
        a placeholder consistent with other Tango batch endpoints. Confirm with
        the API team before generating client code.
      operationId: putAssetsBatch
      tags: [Assets]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AssetBatchRequest"
            examples:
              default:
                value:
                  records:
                    - asset_id: "123456"
                      asset_instance_id: "1234567"
                      asset_instance_number: "1234"
                      asset_instance_name: "Locker"
                      asset_master_number: "M1234"
                      description: "This is a Locker."
                      entity_number: "S123"
                      asset_class: "Security"
                      status: "Active"
                      asset_type: "Locker"
                      is_reservable: "Y"
      responses:
        "200":
          description: Accepted for async processing.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
  /v1/batch/status:
    get:
      summary: Poll processing status by gu_id
      operationId: getBatchStatus
      tags: [Status]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
        - in: query
          name: gu_id
          required: true
          schema: { type: string, format: uuid }
      responses:
        "200":
          description: Status payload.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StatusResponse"
components:
  securitySchemes:
    xClientHeader: { type: apiKey, in: header, name: x-client }
    xApiKeyHeader: { type: apiKey, in: header, name: x-api-key }
  parameters:
    XClient:
      name: x-client
      in: header
      required: true
      schema: { type: string }
    XApiKey:
      name: x-api-key
      in: header
      required: true
      schema: { type: string }
  schemas:
    AssetBatchRequest:
      type: object
      required: [records]
      properties:
        records:
          type: array
          items:
            $ref: "#/components/schemas/AssetRecord"
    AssetRecord:
      type: object
      required:
        - asset_id
        - asset_instance_id
        - asset_instance_number
        - asset_master_number
      properties:
        asset_id: { type: number, description: "Tango asset ID." }
        asset_instance_id: { type: number, description: "Tango asset instance ID." }
        asset_instance_number: { type: string }
        asset_instance_name: { type: string }
        asset_master_number: { type: string }
        description: { type: string }
        entity_number:
          type: string
          description: Building or Location number.
        asset_class: { type: string, description: "Lookup." }
        serial_number: { type: string }
        tag_number: { type: string }
        manufacturer: { type: string }
        model_no: { type: string }
        date_in_service: { type: string, description: "MM/DD/YYYY." }
        warranty_exp_date: { type: string, description: "MM/DD/YYYY." }
        purchase_value: { type: number }
        net_book_value: { type: number }
        comments: { type: string }
        date_of_purchase: { type: string, description: "MM/DD/YYYY." }
        vendor: { type: string, description: "Vendor number; must exist in Tango." }
        warranty_start_date: { type: string, description: "MM/DD/YYYY." }
        lease_begin_date: { type: string, description: "MM/DD/YYYY." }
        lease_end_date: { type: string, description: "MM/DD/YYYY." }
        leasing_company:
          type: string
          description: |
            Source data-mapping table types as DATE (likely typo — sample data
            and field name suggest VARCHAR). Modelled as string here; flagged
            in Open Questions.
        monthly_lease_payment: { type: number }
        status: { type: string, description: "Lookup." }
        asset_type: { type: string, description: "Lookup." }
        model_name: { type: string }
        useful_life: { type: number }
        depreciation: { type: number }
        asset_owner: { type: string, description: "Lookup." }
        warranty_period: { type: number }
        associated_entity_type:
          type: string
          description: "Lookup. e.g., SPACE, BUILDING, FLOOR, STORE, PERSON."
        associated_entity_number:
          type: string
          description: |
            Must exist in Tango. The expected value depends on associated_entity_type
            (Location/Building/Floor/Space/Person number accordingly).
        used_by_entity_type: { type: string, description: "Lookup." }
        used_by_entity_number:
          type: string
          description: "Person number; must exist in Tango."
        " asset_condition":
          type: string
          description: |
            Lookup. NOTE: source JSON has a leading space in the field name
            (`" asset_condition"`). Preserved verbatim — confirm whether the
            wire format actually expects the leading space.
        replacement_cost: { type: string }
        is_reservable: { type: string, description: "Lookup (Y/N)." }
        c_ext_attr1:  { type: string }
        c_ext_attr2:  { type: string }
        c_ext_attr3:  { type: string }
        c_ext_attr4:  { type: string }
        c_ext_attr5:  { type: string }
        c_ext_attr6:  { type: string }
        c_ext_attr7:  { type: string }
        c_ext_attr8:  { type: string }
        c_ext_attr9:  { type: string }
        c_ext_attr10: { type: string }
        c_ext_attr11: { type: string }
        c_ext_attr12: { type: string }
        c_ext_attr13: { type: string }
        c_ext_attr14: { type: string }
        c_ext_attr15: { type: string }
        c_ext_attr16: { type: string }
        c_ext_attr17: { type: string }
        c_ext_attr18: { type: string }
        c_ext_attr19: { type: string }
        c_ext_attr20: { type: string }
        c_ext_attr21: { type: string }
        c_ext_attr22: { type: string }
        c_ext_attr23: { type: string }
        c_ext_attr24: { type: string }
        c_ext_attr25: { type: string }
        c_ext_attr26: { type: string }
        c_ext_attr27: { type: string }
        c_ext_lov1: { type: string, description: "Lookup." }
        c_ext_lov2: { type: string, description: "Lookup." }
        c_ext_lov3: { type: string, description: "Lookup." }
        c_ext_lov4: { type: string, description: "Lookup." }
        c_ext_lov5: { type: string, description: "Lookup." }
        n_ext_attr1:  { type: number }
        n_ext_attr2:  { type: number }
        n_ext_attr3:  { type: number }
        n_ext_attr4:  { type: number }
        n_ext_attr5:  { type: number }
        n_ext_attr6:  { type: number }
        n_ext_attr7:  { type: number }
        n_ext_attr8:  { type: number }
        n_ext_attr9:  { type: number }
        n_ext_attr10: { type: number }
        d_ext_attr1: { type: string, description: "MM/DD/YYYY." }
        d_ext_attr2: { type: string, description: "MM/DD/YYYY." }
        d_ext_attr3: { type: string, description: "MM/DD/YYYY." }
        d_ext_attr4: { type: string, description: "MM/DD/YYYY." }
        d_ext_attr5: { type: string, description: "MM/DD/YYYY." }
    AcceptedResponse:
      type: object
      required: [status, gu_id]
      properties:
        status: { type: string, enum: [OK, Error] }
        status_message: { type: string }
        gu_id: { type: string, format: uuid }
    StatusResponse:
      oneOf:
        - type: object
          properties:
            status: { type: string, const: PROCESSING }
        - type: object
          required: [status, total_records]
          properties:
            status: { type: string, const: COMPLETED }
            total_records: { type: integer }
            errors: { type: 'null' }
        - type: object
          required: [status, total_records, errors]
          properties:
            status: { type: string, const: ERROR }
            total_records: { type: integer }
            errors:
              type: array
              items:
                type: object
                required: [record_index, error]
                properties:
                  record_index: { type: integer }
                  record_key: { type: 'null' }
                  error: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
