{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://validatapp.com/docs/schemas/channel.validation.result.v1.schema.json",
  "title": "channel.validation.result.v1",
  "description": "Respuesta de validación COD. Los clientes deben ignorar campos desconocidos y tratar enumeraciones desconocidas con seguridad.",
  "type": "object",
  "required": [
    "schema_version",
    "validation_ref",
    "audit_ref",
    "external_order_ref",
    "status",
    "core",
    "fingerprint",
    "address",
    "merchant_policy",
    "next_action",
    "buyer_message_key",
    "consumption",
    "idempotency"
  ],
  "properties": {
    "schema_version": {
      "const": "channel.validation.result.v1"
    },
    "validation_ref": {
      "type": "string"
    },
    "audit_ref": {
      "type": "string"
    },
    "external_order_ref": {
      "type": "string"
    },
    "status": {
      "enum": [
        "DECIDED",
        "INVALID_PHONE"
      ]
    },
    "core": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "action",
            "reason_code",
            "rule_version_ref"
          ],
          "properties": {
            "action": {
              "enum": [
                "ALLOW_COD",
                "REQUIRE_FREIGHT",
                "REQUIRE_PREPAID",
                "EXTRA_CONFIRMATION",
                "MANUAL_REVIEW",
                "WARN"
              ]
            },
            "reason_code": {
              "type": "string"
            },
            "rule_version_ref": {
              "type": "string"
            }
          }
        }
      ]
    },
    "fingerprint": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "level",
            "category",
            "policy_version",
            "evidence_state"
          ],
          "properties": {
            "level": {
              "enum": [
                "nuevo",
                "bueno",
                "con_devoluciones",
                "alto_riesgo",
                null
              ]
            },
            "category": {
              "enum": [
                "NO_HISTORY",
                "INSUFFICIENT_HISTORY",
                "CRITICAL",
                "EXCELLENT",
                "GOOD",
                "REGULAR",
                "RISKY"
              ]
            },
            "policy_version": {
              "type": "string"
            },
            "evidence_state": {
              "enum": [
                "VALIDATED",
                "DEGRADED",
                "NO_SOURCES"
              ]
            }
          }
        }
      ]
    },
    "address": {
      "type": "object",
      "required": [
        "gate",
        "validator"
      ],
      "properties": {
        "gate": {
          "enum": [
            "NOT_VALIDATED",
            "HOME_PASS",
            "PICKUP_VALIDATED",
            "SKIPPED_BY_POLICY",
            "BLOCKED"
          ]
        },
        "validator": {
          "enum": [
            "none",
            "office_collection"
          ]
        }
      }
    },
    "merchant_policy": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "effect",
            "version_ref"
          ],
          "properties": {
            "effect": {
              "enum": [
                "CONTINUE_COD_SUBJECT_TO_GATES",
                "REQUIRE_FREIGHT",
                "REQUIRE_PREPAID",
                "EXTRA_CONFIRMATION",
                "HUMAN_CONTROL"
              ]
            },
            "version_ref": {
              "type": "string"
            }
          }
        }
      ]
    },
    "next_action": {
      "enum": [
        "CONTINUE_COD",
        "CONFIRM_ADDRESS_VIA_CHAT",
        "OFFER_FREIGHT_ADVANCE",
        "REQUIRE_PREPAID",
        "EXTRA_CONFIRMATION",
        "HANDOFF_TO_HUMAN",
        "ASK_VALID_PHONE"
      ]
    },
    "buyer_message_key": {
      "type": "string"
    },
    "consumption": {
      "type": "object",
      "required": [
        "state",
        "meter"
      ],
      "properties": {
        "state": {
          "enum": [
            "CONSUMED",
            "ALREADY_COUNTED",
            "REPLAY_NOT_CHARGED",
            "NOT_CHARGED_INVALID_PHONE"
          ]
        },
        "meter": {
          "const": "huella_validations"
        }
      }
    },
    "idempotency": {
      "type": "object",
      "required": [
        "replayed"
      ],
      "properties": {
        "replayed": {
          "type": "boolean"
        }
      }
    }
  }
}
