{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ivans/json-schema/ivans-market-contract-code-detail-schema.json",
  "title": "MarketContractCodeDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ivans-market-contract-codes-api-openapi.yml#/components/schemas/MarketContractCodeDetail",
  "type": "object",
  "properties": {
    "uuid": {
      "type": "string",
      "format": "uuid",
      "readOnly": true
    },
    "parent": {
      "type": "string"
    },
    "nickname": {
      "type": "string",
      "maxLength": 128
    },
    "codeType": {
      "allOf": [
        {
          "$ref": "#/$defs/CodeTypeEnum"
        }
      ],
      "description": "[(1, 'Agency Id'), (2, 'Producer Id'), (3, 'Network Code')]",
      "minimum": -2147483648,
      "maximum": 2147483647
    },
    "code": {
      "type": "string",
      "maxLength": 128
    },
    "user": {
      "$ref": "#/$defs/SimpleUser"
    },
    "users": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SimpleUser"
      }
    },
    "lastModifiedBy": {
      "$ref": "#/$defs/SimpleUser"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "marketConfiguration": {
      "type": "string"
    },
    "accessStructures": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/StructureAccess"
      }
    },
    "contractSubcodes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MarketContractCodeDetail"
      }
    },
    "lastUsedOn": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "accessStructures",
    "code",
    "codeType",
    "contractSubcodes",
    "lastModifiedBy",
    "marketConfiguration",
    "updatedAt",
    "user",
    "users",
    "uuid"
  ],
  "$defs": {
    "CodeTypeEnum": {
      "enum": [
        1,
        2,
        3
      ],
      "type": "integer"
    },
    "MarketContractCodeDetail": {
      "type": "object",
      "properties": {
        "uuid": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "parent": {
          "type": "string"
        },
        "nickname": {
          "type": "string",
          "maxLength": 128
        },
        "codeType": {
          "allOf": [
            {
              "$ref": "#/$defs/CodeTypeEnum"
            }
          ],
          "description": "[(1, 'Agency Id'), (2, 'Producer Id'), (3, 'Network Code')]",
          "minimum": -2147483648,
          "maximum": 2147483647
        },
        "code": {
          "type": "string",
          "maxLength": 128
        },
        "user": {
          "$ref": "#/$defs/SimpleUser"
        },
        "users": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SimpleUser"
          }
        },
        "lastModifiedBy": {
          "$ref": "#/$defs/SimpleUser"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "marketConfiguration": {
          "type": "string"
        },
        "accessStructures": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/StructureAccess"
          }
        },
        "contractSubcodes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/MarketContractCodeDetail"
          }
        },
        "lastUsedOn": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "required": [
        "accessStructures",
        "code",
        "codeType",
        "contractSubcodes",
        "lastModifiedBy",
        "marketConfiguration",
        "updatedAt",
        "user",
        "users",
        "uuid"
      ]
    },
    "SimpleUser": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "integratorUserId": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "readOnly": true
        },
        "externalId": {
          "type": "string",
          "description": "Unique identifier from external system. Used to identify agents.",
          "maxLength": 64
        }
      },
      "required": [
        "id",
        "integratorUserId",
        "name"
      ]
    },
    "StructureAccess": {
      "type": "object",
      "properties": {
        "agency": {
          "$ref": "#/$defs/StructureChild"
        },
        "branch": {
          "$ref": "#/$defs/StructureChild"
        },
        "department": {
          "$ref": "#/$defs/StructureChild"
        },
        "businessUnit": {
          "$ref": "#/$defs/StructureChild"
        }
      },
      "required": [
        "agency",
        "branch",
        "businessUnit",
        "department"
      ]
    },
    "StructureChild": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "id",
        "name"
      ]
    }
  }
}