{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://istointents.org/schemas/0.4/push-subscription.schema.json",
  "title": "Isto Intents push subscription",
  "description": "The structuredContent of intent_subscribe_events and intent_unsubscribe_events (push profile, draft 0.4). The endpoint secret is never echoed.",
  "type": "object",
  "required": [
    "specVersion",
    "type",
    "subscriptionId",
    "status",
    "expiresAt",
    "refreshBefore",
    "events"
  ],
  "properties": {
    "specVersion": {
      "const": "0.4"
    },
    "type": {
      "const": "push-subscription"
    },
    "subscriptionId": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{22,64}$"
    },
    "status": {
      "enum": [
        "awaiting_person_approval",
        "verifying",
        "active",
        "ended"
      ]
    },
    "approval": {
      "enum": [
        "on-consent-page",
        "sent-to-verified-channel"
      ]
    },
    "events": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "enum": [
          "intent.matches.delivered",
          "intent.status.changed",
          "interest.status.changed"
        ]
      }
    },
    "expiresAt": {
      "$ref": "https://istointents.org/schemas/0.1/common.schema.json#/$defs/timestamp"
    },
    "refreshBefore": {
      "$ref": "https://istointents.org/schemas/0.1/common.schema.json#/$defs/timestamp"
    }
  },
  "additionalProperties": false,
  "if": {
    "properties": {
      "status": {
        "const": "awaiting_person_approval"
      }
    }
  },
  "then": {
    "required": [
      "approval"
    ]
  }
}
