{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.msadsnetwork.com/downloads/schemas/ivt-deduction.schema.json",
  "title": "IVT deduction record v0.1 (public draft)",
  "type": "object",
  "required": [
    "ver",
    "code",
    "event",
    "count",
    "amount",
    "currency",
    "period",
    "detected_by",
    "appeal",
    "reversible"
  ],
  "additionalProperties": false,
  "properties": {
    "ver": {
      "const": "0.1"
    },
    "code": {
      "anyOf": [
        {
          "enum": [
            "IVT-G-DC",
            "IVT-G-BOT",
            "IVT-G-PREFETCH",
            "IVT-G-DUP",
            "IVT-G-INVALIDUA",
            "IVT-S-TOKEN",
            "IVT-S-RATE",
            "IVT-S-PROXY",
            "IVT-S-EMU",
            "IVT-S-INJECT",
            "IVT-S-CLICKSPAM",
            "IVT-S-SDKSPOOF",
            "IVT-P-PROBATION",
            "IVT-P-POLICY",
            "IVT-P-CLIENT"
          ]
        },
        {
          "type": "string",
          "pattern": "^IVT-X-[A-Za-z0-9]+-[A-Z0-9-]+$"
        }
      ]
    },
    "event": {
      "enum": [
        "impression",
        "click",
        "conversion",
        "task"
      ]
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "amount": {
      "type": "string",
      "pattern": "^\\d+(\\.\\d{1,6})?$"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "period": {
      "type": "object",
      "required": [
        "from",
        "to"
      ],
      "properties": {
        "from": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "to": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "additionalProperties": false
    },
    "detected_by": {
      "type": "string",
      "minLength": 2
    },
    "evidence_url": {
      "type": "string",
      "pattern": "^https://"
    },
    "appeal": {
      "type": "object",
      "required": [
        "deadline"
      ],
      "anyOf": [
        {
          "required": [
            "url"
          ]
        },
        {
          "required": [
            "email"
          ]
        }
      ],
      "properties": {
        "url": {
          "type": "string",
          "pattern": "^https://"
        },
        "email": {
          "type": "string",
          "format": "email",
          "pattern": "@"
        },
        "deadline": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "additionalProperties": false
    },
    "reversible": {
      "type": "boolean"
    }
  }
}