<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="createorder_standard" targetNamespace="http://api.dmds.com/api/v1/requestschemas/createorder_standard" elementFormDefault="qualified" xmlns="http://api.dmds.com/api/v1/requestschemas/createorder_standard" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:productionService="http://api.dmds.com/api/v1/requestschemas/requestproductionservices_standard">
  <xs:element name="Order" type="Order" />
  <!-- Order element definition -->
  <xs:complexType name="Order">
    <xs:all minOccurs="0">
      <!-- Set this to true in order to still attempt to publish the order even if warning(s) occurred -->
      <xs:element name="PublishOrderOnWarning" type="xs:boolean" default="false" />
      <!-- Set this to true in order to still attempt to save the order in draft status even if error(s) occurred -->
      <xs:element name="SaveOrderAsDraftOnError" type="xs:boolean" default="false" />
      <!-- Set this to true in order to throw an error (preventing a save operation) if any warnings occur -->
      <xs:element name="ThrowErrorOnWarning" type="xs:boolean" default="false" />
      <!-- Set this to false in order to prevent an order with missing assets from publishing automatically once all assets become available -->
      <xs:element name="PublishWhenAvailable" type="xs:boolean" default="true" />
      <xs:element name="PriorityType">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {Standard, Priority, TrafficOnly, OneHourDelivery}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Standard" />
            <xs:enumeration value="Priority" />
            <xs:enumeration value="TrafficOnly" />
            <xs:enumeration value="OneHourDelivery" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <!-- An order name must be specified -->
      <xs:element name="OrderName" type="DMDSString" minOccurs="1" />
      <!-- Will default to the date-time of the request if not specified. Set to a date in the future if you do not wish for the order to be sent immediately -->
      <xs:element name="DeliveryDate" type="DMDSDateTimeFormat" />
      <xs:element name="Advertiser" type="DMDSString" />
      <xs:element name="Brand" type="DMDSString" />
      <xs:element name="Client" type="DMDSString" />
      <xs:element name="ContactName" type="DMDSString" />
      <xs:element name="ContactEmail" type="DMDSString" />
      <xs:element name="ContactPhone" type="DMDSString" />
      <xs:element name="Description" type="xs:string" />
      <xs:element name="EstimateNumber" type="DMDSString" />
      <xs:element name="Product" type="DMDSString" />
      <xs:element name="PONumber" type="DMDSString" />
      <xs:element name="JobNumber" type="DMDSString" />
      <xs:element name="Publisher" type="DMDSString2048" />
      <xs:element name="Website" type="DMDSString" />
      <xs:element name="Destinations" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Organization" type="Organization" minOccurs="0" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Videos" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="AdVideo" type="AdVideo" minOccurs="0" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <!-- See http://api.dmds.com/api/v1/requestschemas/productionservices_standard for definition of a Production Service -->
      <xs:element name="ProductionServices" nillable="true" type="productionService:ProductionServicesRequest" />
    </xs:all>
    <!-- The root Order element must have a requestType of "Standard" -->
    <xs:attribute name="requestType" use="required" fixed="Standard" />
  </xs:complexType>
  <!-- Organization type defintion -->
  <xs:complexType name="Organization">
    <xs:choice>
      <!-- Use any of the following identifiers to match the organization from the request to the organization in DMDS -->
      <xs:element name="OrganizationID" type="xs:integer" />
      <xs:element name="OrganizationName" type="DMDSString" />
      <!-- Custom fields below are only supported if your organization list has been pre-loaded into DMDS -->
      <xs:element name="CustomOrganizationID" type="DMDSString" />
      <xs:element name="CustomOrganizationName" type="DMDSString" />
    </xs:choice>
  </xs:complexType>
  <!-- AdVideo type definition -->
  <xs:complexType name="AdVideo">
    <xs:all minOccurs="0">
      <!-- Either the VideoID or ADID must be passed in order to match the video file to an existing video.
      If the video does not yet exist then an ADID must be provided to add a placeholder -->
      <xs:element name="VideoID" type="xs:integer" />
      <xs:element name="ADID" type="DMDSString" />
      <xs:element name="Brand" type="DMDSString" />
      <xs:element name="Title" type="DMDSString" />
      <xs:element name="Duration">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {5, 10, 15, 20, 30, 45, 60, 90, 120, 300}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:integer">
            <xs:enumeration value="5" />
            <xs:enumeration value="10" />
            <xs:enumeration value="15" />
            <xs:enumeration value="20" />
            <xs:enumeration value="30" />
            <xs:enumeration value="45" />
            <xs:enumeration value="60" />
            <xs:enumeration value="90" />
            <xs:enumeration value="120" />
            <xs:enumeration value="300" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="VideoFormat">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {NTSC SD, NTSC HD, PAL SD, PAL HD, Preview, Legacy}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="NTSC SD" />
            <xs:enumeration value="NTSC HD" />
            <xs:enumeration value="PAL SD" />
            <xs:enumeration value="PAL HD" />
            <xs:enumeration value="Preview" />
            <xs:enumeration value="Legacy" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="AFD">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {Center Cut, Letterbox}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Center Cut" />
            <xs:enumeration value="Letterbox" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="AudioConfig">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {Stereo, 5.1, Dolby, DigitalAudio, SAP}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Stereo" />
            <xs:enumeration value="5.1" />
            <xs:enumeration value="Dolby" />
            <xs:enumeration value="DigitalAudio" />
            <xs:enumeration value="SAP" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="ClosedCaption">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {Yes, No}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="" />
            <xs:enumeration value="Yes" />
            <xs:enumeration value="No" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="FrameRate">
        <xs:simpleType>
          <xs:annotation>
            <xs:documentation>Select one of the values: {13, 23.976, 24, 25, 29.97, 59.94}</xs:documentation>
          </xs:annotation>
          <xs:restriction base="xs:string">
            <xs:enumeration value="" />
            <xs:enumeration value="13" />
            <xs:enumeration value="23.976" />
            <xs:enumeration value="24" />
            <xs:enumeration value="25" />
            <xs:enumeration value="29.97" />
            <xs:enumeration value="59.94" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="SOM" type="DMDSLength" />
      <xs:element name="LOM" type="DMDSLength" />
    </xs:all>
  </xs:complexType>
  <!-- Data field definitions -->
  <xs:simpleType name="DMDSString">
    <xs:annotation>
      <xs:documentation>Defines custom DMDS string length for All string values</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0" />
      <xs:maxLength value="400" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DMDSString2048">
    <xs:annotation>
      <xs:documentation>Defines custom DMDS string length for SOME string values</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0" />
      <xs:maxLength value="2048" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DMDSDateTimeFormat">
    <xs:annotation>
      <xs:documentation>Defines custom DMDS date time format: YYYY-MM-DDTHH:mm:ss (eg 2013-01-01T14:00:00), note all DateTime strings must be EST, GMT -5</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:dateTime">
      <xs:pattern value="((000[1-9])|(00[1-9][0-9])|(0[1-9][0-9]{2})|([1-9][0-9]{3}))-((0[1-9])|(1[012]))-((0[1-9])|([12][0-9])|(3[01]))T(([01][0-9])|(2[0-3]))(:[0-5][0-9])(:00)" />
      <xs:maxInclusive value="2079-06-06T23:59:00" />
      <xs:minInclusive value="1900-01-01T00:00:00" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DMDSLength">
    <xs:annotation>
      <xs:documentation>The value must use the following mask, 99:99:99:99, ie, 00:00:01:23</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{2}" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>