{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Schema for loan",
    "type": "object",
    "required": [
        "pid",
        "$schema",
        "state"
    ],
    "additionalProperties": false,
    "properties": {
        "$schema": {
            "type": "string",
            "title": "Schema"
        },
        "item": {
            "title": "Item",
            "type": "object",
            "properties": {
                "$ref": {
                    "title": "Item URI",
                    "type": "string",
                    "pattern": "^https://ils.rero.ch/api/items/.+?$",
                    "default": "https://ils.rero.ch/api/items/"
                }
            }
        },
        "extension_count": {
            "type": "integer",
            "title": "Loan extension count"
        },
        "pid": {
            "type": "string",
            "title": "Loan PID"
        },
        "transaction_date": {
            "type": "string",
            "format": "date-time",
            "title": "Loan date"
        },
        "patron_pid": {
            "type": "string",
            "title": "Patron PID"
        },
        "document_pid": {
            "type": "string",
            "title": "Document PID"
        },
        "item_pid": {
            "type": "string",
            "title": "Item PID"
        },
        "transaction_user_pid": {
            "type": "string",
            "title": "Transaction user PID"
        },
        "transaction_location_pid": {
            "type": "string",
            "title": "Transaction location PID"
        },
        "pickup_location_pid": {
            "type": "string",
            "title": "Request pickup location PID"
        },
        "request_expiry_date": {
            "type": "string",
            "format": "date-time",
            "title": "Request expiry date"
        },
        "start_date": {
            "type": "string",
            "format": "date-time",
            "title": "Transaction start date"
        },
        "end_date": {
            "type": "string",
            "format": "date-time",
            "title": "Transaction end date"
        },
        "organisation": {
            "title": "Organisation",
            "type": "object",
            "properties": {
                "$ref": {
                    "title": "Organisation URI",
                    "type": "string",
                    "pattern": "^https://ils.rero.ch/api/organisations/.*?$"
                }
            }
        },
        "state": {
            "type": "string",
            "title": "State name",
            "enum": [
                "CREATED",
                "PENDING",
                "ITEM_ON_LOAN",
                "ITEM_RETURNED",
                "ITEM_IN_TRANSIT_FOR_PICKUP",
                "ITEM_IN_TRANSIT_TO_HOUSE",
                "ITEM_AT_DESK",
                "CANCELLED"
            ],
            "form": {
                "options": [
                    {
                        "label": "CREATED",
                        "value": "CREATED"
                    },
                    {
                        "label": "PENDING",
                        "value": "PENDING"
                    },
                    {
                        "label": "ITEM_ON_LOAN",
                        "value": "ITEM_ON_LOAN"
                    },
                    {
                        "label": "ITEM_RETURNED",
                        "value": "ITEM_RETURNED"
                    },
                    {
                        "label": "ITEM_IN_TRANSIT_FOR_PICKUP",
                        "value": "ITEM_IN_TRANSIT_FOR_PICKUP"
                    },
                    {
                        "label": "ITEM_IN_TRANSIT_TO_HOUSE",
                        "value": "ITEM_IN_TRANSIT_TO_HOUSE"
                    },
                    {
                        "label": "ITEM_AT_DESK",
                        "value": "ITEM_AT_DESK"
                    },
                    {
                        "label": "CANCELLED",
                        "value": "CANCELLED"
                    }
                ]
            }
        },
        "trigger": {
            "type": "string",
            "title": "The name of the explicit action that triggered the transition to current state"
        }
    }
}