openapi: 3.1.0
info:
  title: Tango Create MAC Request Inbound API
  version: "0.6"
  description: |
    Async REST API: client PUTs new MAC (Move/Add/Change) requests to Tango.
    Tango creates new MAC request records in the Space Management module.

    Request-type semantics:
      - **Add**: from_property / from_building / from_floor / from_space are blank.
      - **Modify**: all from/to fields are filled.
      - **Remove**: to_property / to_building / to_floor / to_space are blank.
  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: MAC Requests}, {name: Status}]
paths:
  /v1/spacemgmt/batch/moverequest:
    put:
      summary: Create MAC requests (async)
      operationId: putMacRequests
      tags: [MAC Requests]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MacRequestBatch"
      responses:
        "200":
          description: Accepted.
          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:
    MacRequestBatch:
      type: object
      required: [records]
      properties:
        records:
          type: array
          items:
            $ref: "#/components/schemas/MacRequest"
    MacRequest:
      type: object
      required:
        - request_type
        - ext_request_number
        - requested_by
        - requested_for
      properties:
        request_type:
          type: string
          description: "Lookup. Values: MOVE_REQ / EXIT / NEW_HIRE / LOCKER_REQUEST."
          enum: [MOVE_REQ, EXIT, NEW_HIRE, LOCKER_REQUEST]
        ext_request_number:
          type: string
          description: "Client Integration ID. Identifies the record. Tango doc references it as `CLIENT_REQUEST_NUMBER` in validation #1 — same field."
        requested_by:
          type: string
          description: "Employee number of the request creator."
        requested_date:
          type: string
          description: "DATE in YYYY-MM-DD."
        requested_for:
          type: string
          description: "Person Number of the employee the request is for."
        from_property: { type: string, description: "Property Number. Blank for Add." }
        from_building: { type: string, description: "Store Number. Blank for Add." }
        from_floor: { type: string, description: "Blank for Add." }
        from_space: { type: string, description: "Blank for Add." }
        from_area:
          type: string
          description: "Area Number. NOTE: source data-mapping types as `VARHCAR` (typo for VARCHAR)."
        to_property: { type: string, description: "Property Number. Blank for Remove." }
        to_building: { type: string, description: "Store Number. Blank for Remove." }
        to_floor: { type: string, description: "Blank for Remove." }
        to_space: { type: string, description: "Blank for Remove." }
        to_area: { type: string }
        asset_number: { type: string }
        justification: { type: string }
        notes: { type: string }
        mac_group: { type: string }
        from_locker:
          type: string
          description: "Current locker. Field does not yet exist in Tango — must be added per source note."
        to_locker:
          type: string
          description: "New locker. Field does not yet exist in Tango — must be added per source note."
        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_lov1: { type: string }
        c_ext_lov2: { type: string }
        c_ext_lov3: { type: string }
        c_ext_lov4: { type: string }
        c_ext_lov5: { type: string }
        n_ext_lov1:
          type: number
          description: "NOTE: source data-mapping calls these `n_ext_lov*` (LoV = list of values) but they're typed NUMBER. Confusing naming — confirm wire format."
        n_ext_lov2: { type: number }
        n_ext_lov3: { type: number }
        n_ext_lov4: { type: number }
        n_ext_lov5: { type: number }
        d_ext_lov1: { type: string, description: "DATE. Naming inconsistency: should likely be d_ext_attr*." }
        d_ext_lov2: { type: string, description: "DATE." }
        d_ext_lov3: { type: string, description: "DATE." }
        d_ext_lov4: { type: string, description: "DATE." }
        d_ext_lov5: { type: string, description: "DATE." }
    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: string }
                  error: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
