{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://readium.org/lcp-specs/schema/status.schema.json",
  "title": "Readium LCP Status Document",
  "type": "object",
  "properties": {
    "id": {
      "description": "Unique identifier for the License Document associated to the Status Document.",
      "type": "string"
    },
    "status": {
      "description": "Current status of the License.",
      "type": "string",
      "enum": [
        "ready",
        "active",
        "revoked",
        "returned",
        "cancelled",
        "expired"
      ]
    },
    "message": {
      "description": "A message meant to be displayed to the User regarding the current status of the license.",
      "type": "string"
    },
    "updated": {
      "type": "object",
      "properties": {
        "license": {
          "description": "Time and Date when the License Document was last updated",
          "type": "string",
          "format": "date-time"
        },
        "status": {
          "description": "Time and Date when the Status Document was last updated",
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "license",
        "status"
      ]
    },
    "links": {
      "type": "array",
      "items": {
        "$ref": "link.schema.json"
      },
      "uniqueItems": true
    },
    "potential_rights": {
      "type": "object",
      "properties": {
        "end": {
          "description": "Date and time when the license ends",
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "description": "Identifies the type of event",
            "type": "string",
            "enum": [
              "register",
              "renew",
              "return",
              "revoke",
              "cancel"
            ]
          },
          "name": {
            "description": "Name of the client, as provided by the client during an interaction",
            "type": "string"
          },
          "id": {
            "description": "Identifies the client, as provided by the client during an interaction",
            "type": "string"
          },
          "timestamp": {
            "description": "Time and date when the event occurred",
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "required": [
    "id",
    "status",
    "message",
    "updated",
    "links"
  ],
  "allOf": [
    {
      "description": "An LCP Status Document MUST contain a link to a license",
      "type": "object",
      "properties": {
        "links": {
          "type": "array",
          "contains": {
            "type": "object",
            "properties": {
              "href": {
                "type": "string",
                "format": "uri"
              },
              "rel": {
                "anyOf": [
                  {
                    "type": "string",
                    "const": "license"
                  },
                  {
                    "type": "array",
                    "contains": {
                      "type": "string",
                      "const": "license"
                    }
                  }
                ]
              }
            }
          }
        }
      }
    }
  ]
}