<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="documents">
        <xs:complexType>
            <xs:sequence>
                <!-- Email address to receive validation/import errors and notifications -->
                <xs:element name="EmailAddress" type="xs:string" minOccurs="1">
                    <xs:annotation>
                        <xs:documentation>Email address to receive validation/import error notifications.</xs:documentation>
                    </xs:annotation>
                </xs:element>

                <xs:element name="document" minOccurs="1" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="FileReference" type="xs:string" minOccurs="1">
                                <xs:annotation>
                                    <xs:documentation>The Matter file reference (e.g. BRA1/0005). Used to resolve the Matter this document is filed against. The Matter must already exist.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="Description" type="xs:string" minOccurs="1">
                                <xs:annotation>
                                    <xs:documentation>A brief description of the document as it should appear in the Document Log.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="FileName" type="xs:string" minOccurs="1">
                                <xs:annotation>
                                    <xs:documentation>The name the file will be stored under, including its extension (e.g. Summons.pdf).</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:choice>
                                <xs:element name="FileContents" type="xs:base64Binary">
                                    <xs:annotation>
                                        <xs:documentation>The file contents encoded as base64. Use this for smaller files. Supply either FileContents or Url for each document, not both.</xs:documentation>
                                    </xs:annotation>
                                </xs:element>
                                <xs:element name="Url" type="xs:anyURI">
                                    <xs:annotation>
                                        <xs:documentation>A publicly reachable http(s) URL the file will be downloaded from when the import is run. The URL must stay available until the import has completed. Supply either FileContents or Url for each document, not both.</xs:documentation>
                                    </xs:annotation>
                                </xs:element>
                            </xs:choice>

                            <xs:element name="Date" type="xs:date" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The date (YYYY-MM-DD) of the Document Log entry. Defaults to the date the import is run.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="Time" type="xs:time" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The time (HH:MM:SS) of the Document Log entry. Defaults to the time the import is run.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="Employee" type="xs:string" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The name of the Employee this Document Log entry is allocated to. Must match an existing employee name. Defaults to the user who runs the import.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="Category" type="xs:string" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The Document Log Category name. Must match an existing category. Defaults to the default document category configured for the company.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="SubCategory" type="xs:string" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The Document Log Sub Category name. Must match an existing sub category.</xs:documentation>
                                </xs:annotation>
                            </xs:element>

                            <xs:element name="Direction" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The direction of the document. Values: 1 (Outgoing) or 2 (Incoming). Defaults to 2.</xs:documentation>
                                </xs:annotation>
                                <xs:simpleType>
                                    <xs:restriction base="xs:unsignedByte">
                                        <xs:enumeration value="1"/>
                                        <xs:enumeration value="2"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>

                        </xs:sequence>
                    </xs:complexType>
                </xs:element>

            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
