openapi: 3.1.0
info:
  title: Tango Vendor (Supplier Sites) Inbound API
  version: "1.3"
  description: |
    Async REST API: client PUTs vendor / supplier-site records to Tango.
    Tango creates/updates supplier sites with addressing, payment, and bank
    information. Two-call pattern with `gu_id` polling.

    The `(supplier_number, supplier_site_number)` pair is the upsert key.
  x-direction: inbound
  x-source: Client System
  x-destination: Tango
servers:
  - url: https://api.tangoanalytics.com
    description: Production
  - url: https://testapi.tangoanalytics.com
    description: Test (SIT/UAT)
tags:
  - name: Vendors
  - name: Status
paths:
  /v1/suppliermgmt/suppliersites:
    put:
      summary: Submit vendor / supplier-site records (async)
      operationId: putVendorSitesBatch
      tags: [Vendors]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VendorBatchRequest"
      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:
    VendorBatchRequest:
      type: object
      required: [records]
      properties:
        records:
          type: array
          items:
            $ref: "#/components/schemas/VendorRecord"
    VendorRecord:
      type: object
      required:
        - supplier_site_name
        - supplier_site_number
        - supplier_site_type
        - Supplier_type
        - Supplier_number
        - primary_site
        - is_payee
        - Country
        - Status
      properties:
        supplier_site_name: { type: string, description: "NOTE: source mapping label has typo 'Suppler Site Name'." }
        supplier_site_number: { type: string }
        supplier_site_type:
          type: string
          description: Client-defined vendor types (Lessee, Payee, Tenant, etc.).
        Supplier_type:
          type: string
          enum: [LEASE, PROJECT, ALL]
          description: "Defaults to LEASE if blank. NOTE: PascalCase in source mapping."
        Supplier_number:
          type: string
          description: "NOTE: PascalCase in source mapping."
        primary_site:
          type: string
          enum: [Y, N]
        is_payee:
          type: string
          enum: [Y, N]
        payment_term: { type: string }
        supplier_rating: { type: number }
        Partner: { type: string }
        Prequalified: { type: string }
        address1: { type: string }
        address2: { type: string }
        address3: { type: string }
        City: { type: string }
        State: { type: string }
        Zip: { type: string }
        Country:
          type: string
          description: 3-letter country code (e.g., `USA`).
        Status:
          type: string
          enum: [A, I]
          description: "`A` = Active, `I` = Inactive."
        Email: { type: string, format: email }
        contact_person: { type: string }
        business_phone: { type: string }
        Fax: { type: string }
        cell_phone: { type: string }
        payment_method: { type: string }
        tax_id: { type: string }
        bank_routing: { type: string }
        bank_account: { type: string }
        payment_email: { type: string, format: email }
        payment_comments: { type: string }
        effective_date: { 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:
                    description: "Typically supplier_site_number (string or number)."
                    oneOf:
                      - { type: string }
                      - { type: integer }
                  error: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
