{
  "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])"
    },
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "version",
    "submissionID",
    "submissionStatus",
    "statusHistory",
    "receiptTimestamp"
  ],
  "additionalProperties": false,
  "properties": {
    "version": {
      "$ref": "#/definitions/text",
      "maxLength": 10
    },
    "submissionID": {
      "$ref": "#/definitions/uuid",
      "minLength": 36,
      "maxLength": 36
    },
    "submissionStatus": {
      "type": "string",
      "enum": [
        "FILE_ACKNOWLEDGED",
        "FILE_INTEGRITY_PASSED",
        "RECORD_SCAN_COMPLETED",
        "COMPLETED_INTEGRITY_ERROR",
        "COMPLETED",
        "COMPLETED_FILE_TIMEOUT",
        "INCOMPLETE_PROCESSING_FAILURE",
        "CANCELLED_BY_SUPPORT"
      ]
    },
    "statusHistory": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "FILE_ACKNOWLEDGED": {
          "$ref": "#/definitions/timestampType"
        },
        "FILE_INTEGRITY_PASSED": {
          "$ref": "#/definitions/timestampType"
        },
        "RECORD_SCAN_COMPLETED": {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_INTEGRITY_ERROR": {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED":  {
          "$ref": "#/definitions/timestampType"
        },
        "COMPLETED_FILE_TIMEOUT": {
          "$ref": "#/definitions/timestampType"
        },
        "INCOMPLETE_PROCESSING_FAILURE": {
          "$ref": "#/definitions/timestampType"
        },
        "CANCELLED_BY_SUPPORT": {
          "$ref": "#/definitions/timestampType"
        }
      }
    },
    "receiptTimestamp": {
      "$ref": "#/definitions/timestampType"
    },
    "completedTimestamp": {
      "$ref": "#/definitions/timestampType"
    },
    "receivedTIDsCount": {
      "$ref": "#/definitions/unsigned"
    },
    "successfulTIDsCount": {
      "$ref": "#/definitions/unsigned"
    },
    "rejectionItems": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "rejectionID": {
            "oneOf": [
              {"$ref": "#/definitions/unsigned"},
              {"type": "null"}
            ]
          },
		  "customerRecordID": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/definitions/unsigned"
                }
              },
              {
                "type":null
              }
            ]
          },
          "errorCode": {
            "$ref": "#/definitions/unsigned"
          },
          "rejectionTimestamp": {
            "$ref": "#/definitions/timestampType"
          }
        }
      }
    }
  }
}
