<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation>Title: Export Coupon Code details - request schema</xs:documentation>
    <xs:documentation>Retrieve details of codes defined against a coupon.</xs:documentation>
    <xs:documentation>A coupon key is required. The 'code' element can be optionally specified if the details of only one coupon code is required.</xs:documentation>
    <xs:documentation>If the 'earliestissuedate' is specified, only coupon codes that have been issued after the given date will be provided in the response.  Dates should be provided in the format YYYY-MM-DD. If a 'store' is specified, only coupon codes that have been issued by baskets originating from the specified store will be provided in the response.</xs:documentation>
    <xs:documentation>A list of Statuses can optionally be supplied.  If specified, only coupon codes which have one of the specified statuses will be provided in the response.</xs:documentation>
    <xs:documentation>Version 1.0 : 2015-10-12.  Initial schema creation.</xs:documentation>
    <xs:documentation>Version 1.1 : 2017-01-09.  Amended to include data lengths and status enumeration and descriptions.</xs:documentation>
    <xs:documentation>Version 1.2 : 2018-04-18.  Company key is now optional as it is provided in the REST url (though required for WCF).</xs:documentation>
  </xs:annotation>
  <xs:element name="export">
    <xs:complexType>
      <xs:all>
        <xs:element minOccurs="0" maxOccurs="1" name="pagination">
          <xs:complexType>
            <xs:all>
              <xs:element minOccurs="0" maxOccurs="1" name="page">
                <xs:annotation>
                  <xs:documentation>The page number of the page of results to be returned.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:integer">
                    <xs:minInclusive value="1" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="pagesize">
                <xs:annotation>
                  <xs:documentation>The number of items to be returned in a page.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:integer">
                    <xs:maxInclusive value="500" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:all>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" maxOccurs="1" name="filters">
          <xs:complexType>
            <xs:all>
              <xs:element minOccurs="1" maxOccurs="1" name="couponkey">
                <xs:annotation>
                  <xs:documentation>The unique coupon key assigned to the coupon.  The key is created automatically by Promo when creating your coupon.  To view the key navigate to the Coupon in the Promo Administration Portal.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:minLength value="1" />
                    <xs:maxLength value="200" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="code">
                <xs:annotation>
                  <xs:documentation>When required, supply a code and only the details for the specified code will be returned.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="100" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="earliestissuedate">
                <xs:annotation>
                  <xs:documentation>Where required, provide a date to indicate that only coupon codes that were issued after the supplied date should be returned.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:union>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:length value="0" />
                      </xs:restriction>
                    </xs:simpleType>
                    <xs:simpleType>
                      <xs:restriction base="xs:dateTime" />
                    </xs:simpleType>
                  </xs:union>
                </xs:simpleType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="statuses">
                <xs:annotation>
                  <xs:documentation>Where required, the coupon codes to be retrieved can be restricted to one or more statuses.</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="0" maxOccurs="unbounded" name="status">
                      <xs:simpleType>
                        <xs:restriction base="xs:string">
                          <xs:enumeration value="ACTIVE">
                            <xs:annotation>
                              <xs:documentation>The code (for a source code) is ACTIVE</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="CREATED">
                            <xs:annotation>
                              <xs:documentation>The code (for a Voucher) has been CREATED</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="ISSUED">
                            <xs:annotation>
                              <xs:documentation>The code (for a Voucher) has been ISSUED</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="REDEEMED">
                            <xs:annotation>
                              <xs:documentation>The code has been fully utilized and is REDEEMED</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="EXPIRED">
                            <xs:annotation>
                              <xs:documentation>The code has EXPIRED</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="WITHDRAWN">
                            <xs:annotation>
                              <xs:documentation>The code has been WITHDRAWN</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                          <xs:enumeration value="RESERVED">
                            <xs:annotation>
                              <xs:documentation>The code has been RESERVED</xs:documentation>
                            </xs:annotation>
                          </xs:enumeration>
                        </xs:restriction>
                      </xs:simpleType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="store">
                <xs:annotation>
                  <xs:documentation>Where required, provide a store to indicate that only coupon codes that were issued by the supplied store should be returned.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="1000" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="generatedcodesimportref">
                <xs:annotation>
                  <xs:documentation>Where required, provide an import reference allocated when a code generation operation is started. Only codes that were generated by the import job for the reference supplied will be returned.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="40" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:all>
            <xs:attribute name="matchexact" use="optional">
              <xs:annotation>
                <xs:documentation>Where required, a boolean value can be provided to indicate whether to look for exact matches for all specified criteria filters.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:union>
                  <xs:simpleType>
                    <xs:restriction base="xs:string">
                      <xs:length value="0" />
                    </xs:restriction>
                  </xs:simpleType>
                  <xs:simpleType>
                    <xs:restriction base="xs:boolean" />
                  </xs:simpleType>
                </xs:union>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="lowpriority" type="xs:boolean" use="optional">
              <xs:annotation>
                <xs:documentation>Flag for internal system use only</xs:documentation>
              </xs:annotation>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
      </xs:all>
      <xs:attribute name="companykey" use="optional">
        <xs:annotation>
          <xs:documentation>The company key assigned to your company.  To view the company key navigate to Configuration / Manage Company.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="200" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:anyAttribute processContents="skip" />
    </xs:complexType>
  </xs:element>
</xs:schema>