<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="certificateOfOrigin" nillable="true" type="CertificateOfOrigin" />
  <xs:complexType name="CertificateOfOrigin">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="version" nillable="true" type="xs:string">
        <xs:annotation>
          <xs:documentation>1.0</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="type" type="CertificateType">
        <xs:annotation>
          <xs:documentation>Optional certificate type (COO, EUR1, ...). If omitted defaults to COO.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="casDeclaration" type="CasDeclaration">
        <xs:annotation>
          <xs:documentation>References to a CAS declaration for which to request a certificate of origin.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="attachments" type="ArrayOfCertificateOfOriginAttachment">
        <xs:annotation>
          <xs:documentation>Documents to be attached to the COO request (commercial invoice pdf)</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="CertificateType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Unknown" />
      <xs:enumeration value="COO" />
      <xs:enumeration value="EUR1" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="CasDeclaration">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="functionRefNum" nillable="true" type="xs:string">
        <xs:annotation>
          <xs:documentation>Local reference number (LRN) of the CAS declaration for which to request a certificate of origin.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfCertificateOfOriginAttachment">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="attachment" nillable="true" type="CertificateOfOriginAttachment" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="CertificateOfOriginAttachment">
    <xs:annotation>
      <xs:documentation>Document to be added to a certificate of origin (commercial invoice PDF).</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="invoiceNumber" nillable="true" type="xs:string">
        <xs:annotation>
          <xs:documentation>Number of the commercial invoice</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="fileName" nillable="true" type="xs:string">
        <xs:annotation>
          <xs:documentation>Filename of the attachment, including a relevant extension.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="content" nillable="true" type="xs:base64Binary">
        <xs:annotation>
          <xs:documentation>The binary information of the attachment in base64 format.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" maxOccurs="1" name="contentType" nillable="true" type="xs:string">
        <xs:annotation>
          <xs:documentation>The mime type of the attachment (only application/pdf is allowed for now).</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>