{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://uqp.dev/spec/schemas/quote.json",
  "title": "Quote",
  "type": "object",
  "properties": {
    "pack_id": {
      "$ref": "common.json#/$defs/packId"
    },
    "pack_version": {
      "$ref": "common.json#/$defs/packVersion"
    },
    "answers": {
      "$ref": "common.json#/$defs/answers"
    },
    "artist_review_mode": {
      "$ref": "common.json#/$defs/reviewMode"
    },
    "price_range": {
      "$ref": "common.json#/$defs/priceRange"
    },
    "sessions": {
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "minimum": 0
        },
        "hours_per_session": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "count",
        "hours_per_session"
      ],
      "additionalProperties": false
    },
    "deposit": {
      "$ref": "common.json#/$defs/deposit"
    },
    "assumptions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "intermediates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "step": {
            "type": "string",
            "minLength": 1
          },
          "factor_id": {
            "type": "string",
            "minLength": 1
          },
          "input": {},
          "value": {},
          "skipped": {
            "const": true
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "step",
          "factor_id",
          "input",
          "value"
        ],
        "additionalProperties": false
      }
    },
    "review_status": {
      "enum": [
        "QUOTED",
        "ACCEPTED",
        "DECLINED",
        "EXPIRED"
      ]
    },
    "consent": {
      "$ref": "common.json#/$defs/consent"
    },
    "anonymized": {
      "type": "boolean"
    },
    "valid_until": {
      "type": "string",
      "format": "date-time"
    },
    "kind": {
      "const": "quote"
    },
    "binding": {
      "const": true
    },
    "confidence": {
      "enum": [
        "low",
        "medium",
        "high"
      ]
    },
    "client_approval": {
      "$ref": "common.json#/$defs/clientApproval"
    },
    "attribution": {
      "$ref": "common.json#/$defs/attribution"
    },
    "quantity": {
      "$ref": "common.json#/$defs/quantity"
    },
    "quantity_unit": {
      "$ref": "common.json#/$defs/quantityUnit"
    },
    "checkout_handoff": {
      "$ref": "common.json#/$defs/checkoutHandoff"
    },
    "id": {
      "$ref": "common.json#/$defs/identifier"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "pack_id",
    "pack_version",
    "answers",
    "artist_review_mode",
    "sessions",
    "deposit",
    "valid_until",
    "assumptions",
    "intermediates",
    "review_status",
    "consent",
    "anonymized",
    "price_range",
    "kind",
    "binding",
    "confidence"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "review_status": {
            "const": "ACCEPTED"
          }
        },
        "required": [
          "review_status"
        ]
      },
      "then": {
        "required": [
          "client_approval"
        ],
        "properties": {
          "client_approval": {}
        }
      }
    }
  ]
}
