{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rctp.dev/schemas/listing-terms.schema.json",
  "title": "Listing Terms",
  "description": "The seller's terms for one listing, as stored by the platform (Draft 0.5 6, A.2). NEVER sent to any agent, in any body, header, webhook, log or record (INV-1). terms_commitment = \"sha-256:\" + hex(SHA-256(JCS({\"salt\", \"terms\"}))) (binding 4.2).",
  "type": "object",
  "properties": {
    "listing_id": {
      "$ref": "common.schema.json#/$defs/ListingId"
    },
    "term_set": {
      "$ref": "common.schema.json#/$defs/TermSetId"
    },
    "terms": {
      "$ref": "#/$defs/TermValues"
    },
    "terms_commitment": {
      "$ref": "common.schema.json#/$defs/Digest"
    }
  },
  "additionalProperties": false,
  "required": [
    "listing_id",
    "term_set",
    "terms",
    "terms_commitment"
  ],
  "$defs": {
    "TermValues": {
      "type": "object",
      "properties": {
        "floor": {
          "$ref": "common.schema.json#/$defs/Money",
          "description": "PRIVATE. Lowest acceptable price; never stated (INV-1)"
        },
        "available_until": {
          "$ref": "common.schema.json#/$defs/Timestamp",
          "description": "After it the listing is closed; offers expire no later"
        },
        "fulfillment_options": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/FulfillmentOption"
          },
          "minItems": 1,
          "description": "UCP fulfillment method types (and options) an offer may choose from"
        },
        "payment_terms": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/PaymentTermId"
          },
          "minItems": 1,
          "uniqueItems": true,
          "description": "UCP payment term IDs an offer may choose from"
        },
        "release_condition": {
          "$ref": "common.schema.json#/$defs/ReleaseCondition"
        },
        "deliver_within_days": {
          "type": "integer",
          "minimum": 1,
          "maximum": 365,
          "description": "Days after funds_held before the buyer may reject with not_received"
        },
        "counterparty_requirements": {
          "$ref": "common.schema.json#/$defs/CounterpartyRequirements"
        },
        "deposit_pct": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "inspection_before_deposit": {
          "type": "boolean"
        },
        "required_observation": {
          "$ref": "common.schema.json#/$defs/RequiredObservation"
        }
      },
      "additionalProperties": false,
      "required": [
        "floor",
        "available_until"
      ],
      "description": "Values of a listing's terms, keyed by term name. Contains private terms: only listing-terms and terms-submission may use it (INV-1)."
    },
    "ProposedTerms": {
      "type": "object",
      "properties": {
        "floor": {
          "$ref": "common.schema.json#/$defs/Money",
          "description": "PRIVATE. The lowest price the seller proposes; never stated to any other agent (INV-1)"
        },
        "available_until": {
          "$ref": "common.schema.json#/$defs/Timestamp",
          "description": "After it the listing is closed; offers expire no later"
        },
        "fulfillment_options": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/FulfillmentOption"
          },
          "minItems": 1,
          "description": "UCP fulfillment method types (and options) an offer may choose from"
        },
        "payment_terms": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/PaymentTermId"
          },
          "minItems": 1,
          "uniqueItems": true,
          "description": "UCP payment term IDs an offer may choose from"
        },
        "release_condition": {
          "$ref": "common.schema.json#/$defs/ReleaseCondition"
        },
        "deliver_within_days": {
          "type": "integer",
          "minimum": 1,
          "maximum": 365,
          "description": "Days after funds_held before the buyer may reject with not_received"
        },
        "counterparty_requirements": {
          "$ref": "common.schema.json#/$defs/CounterpartyRequirements"
        },
        "deposit_pct": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "inspection_before_deposit": {
          "type": "boolean"
        },
        "required_observation": {
          "$ref": "common.schema.json#/$defs/RequiredObservation"
        }
      },
      "additionalProperties": false,
      "minProperties": 1,
      "description": "PRIVATE. Values the seller told their agent; shown pre-filled on the seller's confirmation and never stored or enforced until the seller confirms (INV-5); never returned to any agent (INV-1)"
    }
  }
}
