{
  "$id": "https://www.nsla.org/schemas/Filing(bundled)",
  "$defs": {
    "Filing": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Filing",
      "title": "Filing",
      "description": "Top level batch filing JSON object.",
      "type": "object",
      "properties": {
        "SubmissionContact": {
          "$ref": "/schemas/SubmissionContact"
        },
        "Brokerage": {
          "$ref": "/schemas/ReportingBrokerage"
        },
        "Policies": {
          "type": "array",
          "items": {
            "$ref": "/schemas/Policies"
          }
        }
      },
      "required": [
        "SubmissionContact",
        "Brokerage",
        "Policies"
      ]
    },
    "SubmissionContact": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/SubmissionContact",
      "title": "Submission Contact",
      "description": "Submission contact for filer of the batch.",
      "type": "object",
      "properties": {
        "FullName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "Email": {
          "type": "string",
          "minLength": 1,
          "maxLength": 250
        },
        "Address": {
          "$ref": "/schemas/Address"
        }
      },
      "required": [
        "FullName",
        "Email",
        "Address"
      ]
    },
    "ReportingBrokerage": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/ReportingBrokerage",
      "title": "Reporting Brokerage",
      "description": "Reporting Brokerage information.",
      "type": "object",
      "properties": {
        "LicenseNumber": {
          "type": "string",
          "minLength": 1,
          "maxLength": 7
        },
        "BrokerageName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "required": [
        "LicenseNumber",
        "BrokerageName"
      ]
    },
    "Policies": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Policies",
      "title": "Policies",
      "description": "Policy section.",
      "type": "object",
      "properties": {
        "PolicyNumber": {
          "type": "string",
          "minLength": 1,
          "maxLength": 50
        },
        "Broker": {
          "$ref": "/schemas/Broker"
        },
        "DescriptionOfCoverage": {
          "type": "string",
          "minLength": 1,
          "maxLength": 250
        },
        "Insured": {
          "$ref": "/schemas/Insured"
        },
        "Insurers": {
          "type": "array",
          "items": {
            "$ref": "/schemas/PolicyInsurer"
          }
        },
        "IsMasterPolicy": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "IsMultiState": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "IsCourtesy": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "IsLayered": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "IsParticipating": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "IsEcp": {
          "enum": [ 0, 1 ],
          "default": 0
        },
        "CoverageCode": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4
        },
        "DSSAcknowledged": {
            "enum": [ 0, 1, 2 ],
            "default": 0
        },
        "Notes": {
          "type": "string",
          "maxLength": 4000
        },
        "Transactions": {
          "type": "array",
          "items": {
            "$ref": "/schemas/Transactions"
          }
        }
      },
      "required": [
        "PolicyNumber",
        "Broker",
        "DescriptionOfCoverage",
        "Insured",
        "Insurers",
        "CoverageCode",
        "Transactions"
      ]
    },
    "Address": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Address",
      "title": "Address",
      "description": "Address information section.",
      "type": "object",
      "properties": {
        "Street": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "StreetLine2": {
          "type": "string",
          "minLength": 0,
          "maxLength": 100
        },
        "City": {
          "type": "string",
          "minLength": 1,
          "maxLength": 50
        },
        "State": {
          "type": "string",
          "minLength": 1,
          "maxLength": 50,
          "description": "Two letter USA State abbreviation, or Canadian province."
        },
        "ZipCode": {
          "type": "string",
          "minLength": 5,
          "maxLength": 10
        },
        "County": {
          "type": "string",
          "minLength": 0,
          "maxLength": 30
        },
        "Country": {
          "enum": [ "USA", "CANADA", "usa", "canada", "Canada", "" ],
          "description": "Defaults to USA when blank, currently USA and Canada are the only accepted values."
        }
      },
      "required": [
        "Street",
        "City",
        "State",
        "ZipCode"
      ]
    },
    "Broker": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Broker",
      "title": "Broker",
      "description": "Broker information section.",
      "type": "object",
      "properties": {
        "FirstName": {
          "type": "string",
          "minLength": 0,
          "maxLength": 50
        },
        "LastName": {
          "type": "string",
          "minLength": 0,
          "maxLength": 50
        },
        "LicenseNumber": {
          "type": "string",
          "minLength": 1,
          "maxLength": 7
        }
      },
      "required": [
        "LicenseNumber"
      ]
    },
    "Insured": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Insured",
      "title": "Insured",
      "description": "Insured section.",
      "type": "object",
      "properties": {
        "NameInsured": {
          "type": "string",
          "minLength": 1,
          "maxLength": 295
        },
        "InsuredAddress": {
          "$ref": "/schemas/Address"
        },
        "LocationOfRiskAddress": {
          "$ref": "/schemas/Address"
        },
        "IsInsuredAddressSameAsLocation": {
          "enum": [ 0, 1 ],
          "default": 0
        }
      },
      "required": [
        "NameInsured",
        "InsuredAddress"
      ]
    },
    "PolicyInsurer": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/PolicyInsurer",
      "title": "Policy Insurer",
      "description": "Policy Insurer allocations.",
      "type": "object",
      "properties": {
        "InsurerNAIC": {
          "type": "string",
          "minLength": 1,
          "maxLength": 10
        },
        "InsurerName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "AllocationPercentage": {
          "description": "This must be a number between 1 and 100. The maximum precision is to 4 decimal points.",
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 100
        }
      },
      "required": [
        "InsurerNAIC",
        "InsurerName",
        "AllocationPercentage"
      ]
    },
    "Transactions": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Transactions",
      "title": "Transactions",
      "description": "Transactions for a batch policy.",
      "type": "object",
      "properties": {
        "TransactionType": {
          "enum": [ 1, 2, 3, 4, 5, 6, 7, 8 ],
          "enumDescriptions": {
            "1": "NEW BUSINESS",
            "2": "ADDITIONAL PREMIUM",
            "3": "RETURN PREMIUM",
            "4": "CANCELLATION",
            "5": "RENEWAL",
            "6": "REINSTATEMENT",
            "7": "ADDITIONAL PREMIUM AUDIT",
            "8": "RETURN PREMIUM AUDIT"
          }
        },
        "EffectiveDate": {
          "$ref": "/schemas/DateString"
        },
        "ExpirationDate": {
          "$ref": "/schemas/DateString"
        },
        "Fees": {
          "type": "number",
          "minimum": -9999999999,
          "maximum": 9999999999
        },
        "Premium": {
          "type": "number",
          "minimum": -9999999999,
          "maximum": 9999999999
        },
        "Documents": {
          "type": "array",
          "items": {
            "$ref": "/schemas/Documents"
          }
        }
      },
      "required": [
        "TransactionType",
        "EffectiveDate",
        "Fees",
        "Premium"
      ]
    },
    "Documents": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/Documents",
      "title": "Documents",
      "description": "Transaction documents information.",
      "type": "object",
      "properties": {
        "DocumentFileName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 250
        }
      },
      "required": [
        "DocumentFileName"
      ]
    },
    "DateString": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://www.nsla.org/schemas/DateString",
      "title": "Date String",
      "description": "Date represented as a string YYYYMMDD, ie: 20240529 is May 29th, 2024.",
      "type": "string",
      "pattern": "^(|[0-9]{8})$"
    }
  },
  "$ref": "https://www.nsla.org/schemas/Filing"
}