{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gloat/json-schema/gloat-candidacy-data-object-schema.json",
  "title": "Candidacy",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gloat-candidacy-api-openapi.yml#/components/schemas/candidacy_data_object",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/candidacy_id_data"
    },
    {
      "type": "object",
      "properties": {
        "candidacy_status": {
          "$ref": "#/$defs/candidacy_status_object"
        },
        "user_data": {
          "$ref": "#/$defs/basic_user_object"
        },
        "actions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/candidacy_action"
          }
        }
      }
    }
  ],
  "$defs": {
    "basic_user_object": {
      "type": "object",
      "title": "Basic User Data",
      "required": [
        "first_name",
        "last_name",
        "email"
      ],
      "properties": {
        "first_name": {
          "type": "string"
        },
        "last_name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        }
      }
    },
    "candidacy_action": {
      "type": "object",
      "title": "Candidacy Action",
      "properties": {
        "action": {
          "type": "string",
          "description": "candidacy action (2 letter code)"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "candidacy_id_data": {
      "type": "object",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "candidacy_id": {
              "type": "string"
            }
          },
          "required": [
            "candidacy_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "job_id": {
              "type": "string"
            },
            "user_id": {
              "type": "string"
            }
          },
          "required": [
            "job_id",
            "user_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "external_id": {
              "type": "string"
            }
          },
          "required": [
            "external_id"
          ],
          "additionalProperties": false
        }
      ]
    },
    "candidacy_status": {
      "type": "string",
      "title": "Candidacy Status",
      "enum": [
        "apply",
        "match",
        "reject",
        "invited-to-interview",
        "interview",
        "on-hold",
        "advanced",
        "phone-approach",
        "email-approach",
        "offer",
        "hired",
        "withdrew"
      ]
    },
    "candidacy_status_object": {
      "type": "object",
      "title": "Candidacy Status Object",
      "properties": {
        "status": {
          "$ref": "#/$defs/candidacy_status"
        },
        "changed_by": {
          "type": "string",
          "description": "external user id of actor"
        },
        "changed_by_user_data": {
          "$ref": "#/$defs/basic_user_object"
        },
        "description": {
          "type": "string"
        },
        "free_text": {
          "type": "string"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}