{
  "definitions": {
    "timestampType": {
      "type": "string",
      "pattern": "^[0-9]{8}([T ])[0-9]{6}(\\.[0-9]{3,9})?$"
    },
    "unsigned": {
      "type": "number",
      "multipleOf": 1,
      "minimum": 0,
      "maximum": 9223372036854775807
    },
    "text": {
      "type": "string",
      "pattern": "((?![|\"@,])[\\x20-\\x7E])"
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "version",
    "submissionID",
    "submitterUsername",
    "catSubmitterID",
    "catReporterCRD",
    "submissionStatus",
    "receiptTimestamp",
    "statusHistory"
  ],
  "additionalProperties": false,
  "properties": {
    "version": {
      "type": "string",
      "maxLength": 10,
      "enum": [
        "1.0.0",
        "2.0.0"
      ]
    },
    "submissionID": {
      "$ref": "#/definitions/unsigned"
    },
    "submitterUsername": {
      "type": "string",
      "maxLength": 200
    },
    "catSubmitterID": {
      "$ref": "#/definitions/unsigned"
    },
    "catReporterCRD": {
      "$ref": "#/definitions/unsigned"
    },
    "correspondentCRD": {
      "$ref": "#/definitions/unsigned"
    },
    "submissionStatus": {
      "type": "string",
      "enum": [
        "FILE_ACKNOWLEDGED",
        "FILE_INTEGRITY_PASSED",
        "RECORD_SCAN_COMPLETED",
        "COMPLETED_WITHOUT_REJECTIONS",
        "COMPLETED_WITH_REJECTIONS",
        "COMPLETED_INTEGRITY_ERROR",
        "COMPLETED_FILE_TIMEOUT",
        "INCOMPLETE_PROCESSING_FAILURE",
        "CANCELLED_BY_SUPPORT"
      ]
    },
    "receiptTimestamp": {
      "$ref": "#/definitions/timestampType"
    },
    "completedTimestamp": {
      "$ref": "#/definitions/timestampType"
    },
    "receivedFDIDRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "successfulFDIDRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "receivedNaturalRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "successfulNaturalRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "receivedLegalEntityRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "successfulLegalEntityRecordCount": {
      "$ref": "#/definitions/unsigned"
    },
    "receivedCorrectionActionCount": {
      "$ref": "#/definitions/unsigned"
    },
    "successfulCorrectionActionCount": {
      "$ref": "#/definitions/unsigned"
    },
    "statusHistory": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "FILE_ACKNOWLEDGED": {
          "$ref": "#/definitions/timestampType"
        },
        "FILE_INTEGRITY_PASSED": {
          "$ref": "#/definitions/timestampType"
        },
        "RECORD_SCAN_COMPLETED": {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_WITHOUT_REJECTIONS":  {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_WITH_REJECTIONS":  {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_INTEGRITY_ERROR": {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_FILE_TIMEOUT": {
          "$ref": "#/definitions/timestampType"
        },
        "INCOMPLETE_PROCESSING_FAILURE": {
          "$ref": "#/definitions/timestampType"
        },
        "CANCELLED_BY_SUPPORT": {
          "$ref": "#/definitions/timestampType"
        }
      }
    },
    "rejectionItems": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "rejectionID",
          "errorCode",
          "rejectionTimestamp"
        ],
        "additionalProperties": false,
        "properties": {
          "rejectionID": {
            "$ref": "#/definitions/unsigned"
          },
          "firmDesignatedID": {
            "$ref": "#/definitions/text",
            "maxLength": 40
          },
          "fdidRecordID": {
            "$ref": "#/definitions/unsigned"
          },
          "largeTraderRecordID": {
            "$ref": "#/definitions/unsigned"
          },
          "customerRejectionEventID": {
            "$ref": "#/definitions/text",
            "maxLength": 100
          },
		  "customerRecordID": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/definitions/unsigned"
                }
              },
              {
                "type":null
              }
            ]
          },
          "addrType": {
            "type": "string",
            "enum": ["ADDRESS1","ADDRESS2","ADDRESS3","ADDRESS4"]
          },
          "authTraderNameID": {
            "$ref": "#/definitions/unsigned"
          },
          "errorCode": {
            "$ref": "#/definitions/unsigned"
          },
          "rejectionTimestamp": {
            "$ref": "#/definitions/timestampType"
          }
        }
      }
    },
    "failedCorrectionItems": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "failedRejectionID",
          "warningCode"
        ],
        "additionalProperties": false,
        "properties": {
          "failedRejectionID": {
            "$ref": "#/definitions/unsigned"
          },
          "warningCode": {
            "$ref": "#/definitions/unsigned"
          }
        }
      }
    }
  }
}
