{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "anyOf": [
        {
            "$ref": "#/definitions/smartvotes_command_set_rules"
        },
        {
            "$ref": "#/definitions/smartvotes_command_send_voteorder"
        },
        {
            "$ref": "#/definitions/smartvotes_command_confirm_votes"
        }
    ],
    "definitions": {
        "smartvotes_command_confirm_votes": {
            "description": "This command confirms that a vote order has been accomplished.",
            "properties": {
                "name": {
                    "enum": [
                        "confirm_votes"
                    ],
                    "type": "string"
                },
                "voteorders": {
                    "description": "Transaction id & num of operation in transaction of a voteorder.",
                    "items": {
                        "properties": {
                            "invalid": {
                                "type": "boolean"
                            },
                            "operation_num": {
                                "type": "number"
                            },
                            "transaction_id": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "invalid",
                            "operation_num",
                            "transaction_id"
                        ],
                        "type": "object"
                    },
                    "type": "array"
                }
            },
            "required": [
                "name",
                "voteorders"
            ],
            "type": "object"
        },
        "smartvotes_command_send_voteorder": {
            "description": "This command sends a voteorder.",
            "properties": {
                "name": {
                    "enum": [
                        "send_voteorder"
                    ],
                    "type": "string"
                },
                "voteorder": {
                    "$ref": "#/definitions/smartvotes_voteorder",
                    "description": "A voteorder to be sent."
                }
            },
            "required": [
                "name",
                "voteorder"
            ],
            "type": "object"
        },
        "smartvotes_command_set_rules": {
            "description": "This command sets the rules. It invalidates previous rules. For a voteorder\na binding set_rules command has to be determined. It is the newest set_rules command\nposted by the delegator to the Blockchain BEFORE the voteorder was sent.",
            "properties": {
                "name": {
                    "enum": [
                        "set_rules"
                    ],
                    "type": "string"
                },
                "rulesets": {
                    "description": "List of named rulesets.",
                    "items": {
                        "$ref": "#/definitions/smartvotes_ruleset"
                    },
                    "type": "array"
                }
            },
            "required": [
                "name",
                "rulesets"
            ],
            "type": "object"
        },
        "smartvotes_rule_authors": {
            "description": "A rule for specifying allowed or denied authors.",
            "properties": {
                "authors": {
                    "description": "List of authors checked using boolean OR.",
                    "items": {
                        "type": "string"
                    },
                    "type": "array"
                },
                "mode": {
                    "enum": [
                        "allow",
                        "deny"
                    ],
                    "type": "string"
                },
                "type": {
                    "enum": [
                        "authors"
                    ],
                    "type": "string"
                }
            },
            "required": [
                "authors",
                "mode",
                "type"
            ],
            "type": "object"
        },
        "smartvotes_rule_custom_rpc": {
            "description": "A rule, which allows using custom JSON-RPC for post validation. When user\nbrowses posts / votes / before sending a vote based on a voteorder - a call will be performed.\nRPC should return boolean true or false indicating potential vote validity.",
            "properties": {
                "rpc_host": {
                    "type": "string"
                },
                "rpc_method": {
                    "type": "string"
                },
                "rpc_path": {
                    "type": "string"
                },
                "rpc_port": {
                    "type": "number"
                },
                "type": {
                    "enum": [
                        "custom_rpc"
                    ],
                    "type": "string"
                }
            },
            "required": [
                "rpc_host",
                "rpc_method",
                "rpc_path",
                "rpc_port",
                "type"
            ],
            "type": "object"
        },
        "smartvotes_rule_tags": {
            "description": "A rule for specifying allowed, denied and required tags list.",
            "properties": {
                "mode": {
                    "description": "Rule mode.\n- allow => every post tag must be on the specified list\n- deny => none of the post tags can be on the specified list\n- require => the post should have all of the specified tags\n- any => the post should have at least one of the specified tags",
                    "enum": [
                        "allow",
                        "any",
                        "deny",
                        "require"
                    ],
                    "type": "string"
                },
                "tags": {
                    "description": "List of tags checked using boolean OR.",
                    "items": {
                        "type": "string"
                    },
                    "type": "array"
                },
                "type": {
                    "enum": [
                        "tags"
                    ],
                    "type": "string"
                }
            },
            "required": [
                "mode",
                "tags",
                "type"
            ],
            "type": "object"
        },
        "smartvotes_ruleset": {
            "description": "This is a named set of rules, which have to be fulfilled by an article supplied by a voter.\nThe delegator can define rulesets for several users, and several rulesets for each single user.\nRules in the ruleset are checked using AND boolean operator. They have to be all fulfilled for the vote to be cast.",
            "properties": {
                "action": {
                    "description": "Decide if an user can upvote posts, flag them, or both.",
                    "enum": [
                        "flag",
                        "upvote",
                        "upvote+flag"
                    ],
                    "type": "string"
                },
                "name": {
                    "description": "Unique name of a ruleset. A voter selects one of the rulesets available for him. This information is passed\nwith an voteorder.",
                    "type": "string"
                },
                "rules": {
                    "description": "Array of rules, that will be checked using AND boolean operator. An rule should implement smartvotes_rule type.\nsmartvotes_rule type simply connects the following rule types: smartvotes_rule_tags,\nsmartvotes_rule_authors, smartvotes_rule_custom_rpc.",
                    "items": {
                        "anyOf": [
                            {
                                "$ref": "#/definitions/smartvotes_rule_tags"
                            },
                            {
                                "$ref": "#/definitions/smartvotes_rule_authors"
                            },
                            {
                                "$ref": "#/definitions/smartvotes_rule_custom_rpc"
                            }
                        ]
                    },
                    "type": "array"
                },
                "total_weight": {
                    "description": "Total weight of all votes that a voter can cast daily.\nEg.: 10000 means a single 100% vote, or twenty 5% votes.\nIf you want to allow a voter to cast two 100% votes, total_weight should be a sum: 20000.",
                    "type": "number"
                },
                "voter": {
                    "description": "Voter's username.",
                    "type": "string"
                }
            },
            "required": [
                "action",
                "name",
                "rules",
                "total_weight",
                "voter"
            ],
            "type": "object"
        },
        "smartvotes_voteorder": {
            "description": "Schema for sending a single vote order.",
            "properties": {
                "author": {
                    "description": "Author of the post.",
                    "type": "string"
                },
                "delegator": {
                    "description": "Username of your delegator (a person, who allowed you to vote on his/her behalf.",
                    "type": "string"
                },
                "permlink": {
                    "description": "Permalink of the post.",
                    "type": "string"
                },
                "ruleset_name": {
                    "description": "Name of a Delegator's ruleset, against which this vote should be checked.",
                    "type": "string"
                },
                "type": {
                    "description": "Type of vote: an upvote or a flag.",
                    "enum": [
                        "flag",
                        "upvote"
                    ],
                    "type": "string"
                },
                "weight": {
                    "description": "Weight of the upvote or flag.",
                    "maximum": 10000,
                    "minimum": 0,
                    "type": "integer"
                }
            },
            "required": [
                "author",
                "delegator",
                "permlink",
                "ruleset_name",
                "type",
                "weight"
            ],
            "type": "object"
        }
    }
}

