<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="createorder_radio" targetNamespace="http://api.dmds.com/api/v1/requestschemas/createorder_radio" elementFormDefault="qualified" xmlns="http://api.dmds.com/api/v1/requestschemas/createorder_radio" 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="Audios" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="AdAudio" type="AdAudio" minOccurs="0" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <!-- See http://api.dmds.com/api/v1/requestschemas/requestproductionservices_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 "radio" -->
    <xs:attribute name="requestType" use="required" fixed="radio" />
  </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>
  <!-- AdAudio type definition -->
  <xs:complexType name="AdAudio">
    <xs:all minOccurs="0">
      <!-- Either the AudioID or ADID must be passed in order to match the Audio file to an existing Audio.
      If the Audio does not yet exist then an ADID must be provided to add a placeholder -->
      <xs:element name="AudioID" type="xs:integer" />
      <xs:element name="ADID" type="DMDSString" />
      <xs:element name="Brand" type="DMDSString" />
      <xs:element name="Title" type="DMDSString" />
    </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:schema>