{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Psyon organisational request simulation",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "kind": {
          "const": "membership"
        },
        "payload": {
          "type": "object",
          "properties": {
            "introductory_session_ids": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "attendance_verified": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "explicit_request": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "conduct_accepted": {
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          "required": [
            "introductory_session_ids",
            "attendance_verified",
            "explicit_request",
            "conduct_accepted"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "payload"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "const": "vote"
        },
        "payload": {
          "type": "object",
          "properties": {
            "decision_kind": {
              "enum": [
                "ordinary",
                "constitutional"
              ]
            },
            "eligible_voters": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "ballots": {
              "type": "object",
              "propertyNames": {
                "minLength": 1
              },
              "additionalProperties": {
                "enum": [
                  "yes",
                  "no",
                  "abstain"
                ]
              }
            },
            "notice_days": {
              "type": "integer",
              "minimum": 0
            },
            "voting_window_complete": {
              "type": "boolean"
            },
            "conflicts_reviewed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "mission_review_passed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "lawfulness_review_passed": {
              "type": [
                "boolean",
                "null"
              ]
            }
          },
          "required": [
            "decision_kind",
            "eligible_voters",
            "ballots",
            "notice_days",
            "voting_window_complete",
            "conflicts_reviewed",
            "mission_review_passed",
            "lawfulness_review_passed"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "payload"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "const": "publication"
        },
        "payload": {
          "type": "object",
          "properties": {
            "audience": {
              "enum": [
                "members",
                "public"
              ]
            },
            "publisher_id": {
              "type": "string",
              "minLength": 1
            },
            "reviewer_ids": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "subject_inventory_complete": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "independent_review_confirmed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "third_party_review_passed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "content_and_context_review_passed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "has_identifiable_minors": {
              "type": "boolean"
            },
            "research_use_requested": {
              "type": "boolean"
            },
            "contributors": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "withdrawn": {
                    "type": "boolean"
                  },
                  "permissions": {
                    "type": "object",
                    "properties": {
                      "recording": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "member_viewing": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "research": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "public_publication": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "recording",
                      "member_viewing",
                      "research",
                      "public_publication"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "id",
                  "withdrawn",
                  "permissions"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "audience",
            "publisher_id",
            "reviewer_ids",
            "subject_inventory_complete",
            "independent_review_confirmed",
            "third_party_review_passed",
            "content_and_context_review_passed",
            "has_identifiable_minors",
            "research_use_requested",
            "contributors"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "payload"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "const": "payment"
        },
        "payload": {
          "type": "object",
          "properties": {
            "beneficiary_id": {
              "type": "string",
              "minLength": 1
            },
            "approval_ids": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "authorised_approver_ids": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              },
              "uniqueItems": true
            },
            "approved_budget": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "amount_minor": {
              "type": "integer",
              "minimum": 1
            },
            "available_budget_minor": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "beneficiary_id",
            "approval_ids",
            "authorised_approver_ids",
            "approved_budget",
            "amount_minor",
            "available_budget_minor"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "payload"
      ],
      "additionalProperties": false
    }
  ]
}
