<?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: Validate Coupon Code - response schema</xs:documentation>
    <xs:documentation>Provides details for the requested coupon code.</xs:documentation>
    <xs:documentation>Version 1.0 : 2016-04-02.  Initial schema creation.</xs:documentation>
  </xs:annotation>
  <xs:element name="response">
    <xs:complexType>
      <xs:all>
        <xs:element minOccurs="0" maxOccurs="1" name="summary">
          <xs:complexType>
            <xs:all>
              <xs:element minOccurs="0" maxOccurs="1" name="action">
                <xs:annotation>
                  <xs:documentation>The Name of the API service action</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="id" type="xs:integer" use="optional">
                        <xs:annotation>
                          <xs:documentation>The Id of the API service action</xs:documentation>
                        </xs:annotation>
                      </xs:attribute>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="messages">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="0" maxOccurs="unbounded" name="message">
                      <xs:annotation>
                        <xs:documentation>The message text.</xs:documentation>
                      </xs:annotation>
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="code" type="xs:string" use="optional">
                              <xs:annotation>
                                <xs:documentation>The code associated with the message.</xs:documentation>
                              </xs:annotation>
                            </xs:attribute>
                            <xs:attribute name="for" type="xs:string" use="optional" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:all>
            <xs:attribute name="result" type="xs:boolean" use="optional">
              <xs:annotation>
                <xs:documentation>Flag indicating whether the process completed without errors.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" maxOccurs="1" name="coupon">
          <xs:complexType>
            <xs:all>
              <xs:element minOccurs="0" maxOccurs="1" name="name" type="xs:string">
                <xs:annotation>
                  <xs:documentation>The coupon name.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="reportingcode" type="xs:string">
                <xs:annotation>
                  <xs:documentation>Where available, the reporting code assigned to the coupon.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="numberseriesname" type="xs:string">
                <xs:annotation>
                  <xs:documentation>For Voucher type coupons only, and where 'generateusing' is set to 'IncrementNumberSeries', the name of the number series to be used when generating new codes.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="mask" type="xs:string">
                <xs:annotation>
                  <xs:documentation>For Voucher type coupons only, and where 'generateusing' is set to 'Mask', the mask to be used for generating codes.  Masks can contain constants and replacement characters - where replacement characters support the insertion of randomized alphanumeric, numeric or special characters.</xs:documentation>
                </xs:annotation>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="statistics">
                <xs:complexType>
                  <xs:attribute name="codescount" type="xs:integer" use="optional">
                    <xs:annotation>
                      <xs:documentation>The number of codes that are defined for the coupon.</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="issuingpromotionscount" type="xs:integer" use="optional">
                    <xs:annotation>
                      <xs:documentation>The number of promotions which may issue a code for the coupon (for Voucher type coupons only).</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="redeemingpromotionscount" type="xs:integer" use="optional">
                    <xs:annotation>
                      <xs:documentation>The number of promotions which may redeem a code for the coupon.</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="locksinuse" type="xs:boolean" use="optional">
                    <xs:annotation>
                      <xs:documentation>Flag indicating whether uses for codes of the coupon will be tracked and the code use locked until the transaction is confirmed, or the lock release time is exceeded.</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="lockreleasetime" type="xs:integer" use="optional">
                    <xs:annotation>
                      <xs:documentation>Where locks are in use - the time in minutes that a lock for a code will be held since the most recent submission.</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="created" type="xs:dateTime" use="optional" />
                  <xs:attribute name="createdby" type="xs:string" use="optional" />
                  <xs:attribute name="lastupdated" type="xs:dateTime" use="optional" />
                  <xs:attribute name="lastupdatedby" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="1" name="codes">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="0" maxOccurs="unbounded" name="code">
                      <xs:complexType>
                        <xs:all>
                          <xs:element minOccurs="0" maxOccurs="1" name="statistics">
                            <xs:complexType>
                              <xs:attribute name="usescount" type="xs:integer" use="optional">
                                <xs:annotation>
                                  <xs:documentation>Where available, the number of times the code has been confirmed as utilized against a basket.</xs:documentation>
                                </xs:annotation>
                              </xs:attribute>
                              <xs:attribute name="locksactive" type="xs:integer" use="optional">
                                <xs:annotation>
                                  <xs:documentation>Where locks are in use - the count of locks currently active for the code.</xs:documentation>
                                </xs:annotation>
                              </xs:attribute>
                              <xs:attribute name="created" type="xs:dateTime" use="optional" />
                              <xs:attribute name="createdby" type="xs:string" use="optional" />
                              <xs:attribute name="lastupdated" type="xs:dateTime" use="optional" />
                              <xs:attribute name="lastupdatedby" type="xs:string" use="optional" />
                            </xs:complexType>
                          </xs:element>
                        </xs:all>
                        <xs:attribute name="uses" type="xs:integer" use="optional" />
                        <xs:attribute name="code" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>The coupon code</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="status" use="optional">
                          <xs:annotation>
                            <xs:documentation>The status of the coupon code.  'CREATED' and 'ISSUED' statuses are only supported for Voucher type coupon codes.</xs:documentation>
                          </xs:annotation>
                          <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:attribute>
                        <xs:attribute name="validfrom" type="xs:dateTime" use="optional">
                          <xs:annotation>
                            <xs:documentation>The date and time from which the coupon code is valid for utilization by promotions.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="validto" type="xs:dateTime" use="optional">
                          <xs:annotation>
                            <xs:documentation>The date and time after which the coupon code is no longer valid for utilization by promotions.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="maximumuses" type="xs:integer" use="optional">
                          <xs:annotation>
                            <xs:documentation>Where applicable, the maximum number of times the coupon code may be utilized by promotions.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issueddate" type="xs:dateTime" use="optional">
                          <xs:annotation>
                            <xs:documentation>For Voucher type coupon codes, the date and time when the code was issued.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issuedby" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>For Voucher type coupon codes, the process which issued the code.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issuingbasketreference" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>For Voucher type coupon codes and where available, the id for the basket against which the voucher code was issued.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issuingstore" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>For Voucher type coupon codes and where available, the store attribute value provided with the basket against which the voucher code was issued.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="withdrawndate" type="xs:dateTime" use="optional">
                          <xs:annotation>
                            <xs:documentation>Where the code has been withdrawn, the date when the withdrawal took place.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="withdrawnby" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>Where the code has been withdrawn, the name of the user who withdrew the code.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="isredeemable" type="xs:boolean" use="optional">
                          <xs:annotation>
                            <xs:documentation>Flag indicating whether the code is available for use with promotions, based on current uses of the code and the current date and time.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issuedtocustomerid" type="xs:string" use="optional">
                          <xs:annotation>
                            <xs:documentation>Where the voucher was issued by a promotion against a basket, the customer reference/id from the basket.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="issuedbyusername" type="xs:string" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:all>
            <xs:attribute name="type" use="optional">
              <xs:annotation>
                <xs:documentation>The coupon type.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="SourceCode" />
                  <xs:enumeration value="Voucher" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="importexportkey" type="xs:string" use="optional">
              <xs:annotation>
                <xs:documentation>The allocated import/export key for the coupon.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="generateusing" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, the method used to generate new codes.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="NotSpecified">
                    <xs:annotation>
                      <xs:documentation>Voucher code generation type not specified, a GUID will be used</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="NewGuid">
                    <xs:annotation>
                      <xs:documentation>Voucher codes will be generated using a GUID</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="IncrementNumberSeries">
                    <xs:annotation>
                      <xs:documentation>Voucher codes will be generated using an incrementing number series</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="Mask">
                    <xs:annotation>
                      <xs:documentation>Mask</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="generateondemand" type="xs:boolean" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, a flag indicating whether codes can be automatically generated for the coupon, at the point when they are to be issued, where no unissued codes are available.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="maximumusesforgeneratedcodes" type="xs:integer" use="optional">
              <xs:annotation>
                <xs:documentation>For voucher type campaign/coupons, the maximum uses to be used for new codes when generating.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="issueonly" type="xs:boolean" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, a flag indicating whether codes may only be issued but never redeemed.  This configuration is typically used for integration with third party systems where those systems will redeem the codes.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="issuedcodevalidity" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, the validity period type to be used for codes at the point when they are issued.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="NotSpecified">
                    <xs:annotation>
                      <xs:documentation>Issued codes for this voucher do not have a validity period, they will always be valid</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="Always">
                    <xs:annotation>
                      <xs:documentation>Issued codes for this voucher will always be valid</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="FixedDateRange">
                    <xs:annotation>
                      <xs:documentation>Issued codes for this voucher will be valid between the dates specified</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PeriodOfHours">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid for the specified number of hours from the time of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PeriodOfDays">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid for the specified number of days from the time of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PeriodOfWeeks">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid for the specified number of weeks from the time of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PeriodOfMonths">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid for the specified number of months from the time of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="PeriodOfYears">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid for the specified number of years from the time of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="EndOfCurrentDay">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid until the end of the day of issue</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="EndOfCurrentWeek">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid until the end of the week in which they were issued</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="EndOfCurrentMonth">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid until the end of the month in which they were issued</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                  <xs:enumeration value="EndOfCurrentYear">
                    <xs:annotation>
                      <xs:documentation>Codes for this voucher will be valid until the end of the year in which they were issued</xs:documentation>
                    </xs:annotation>
                  </xs:enumeration>
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="issuedcodeperiod" type="xs:integer" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, where applicable the value to be used for the period type for codes at the point when they are issued.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="issuedcodevalidfrom" type="xs:dateTime" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, where applicable the valid from date and time of codes to be assigned at the point when they are issued.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
            <xs:attribute name="issuedcodevalidto" type="xs:dateTime" use="optional">
              <xs:annotation>
                <xs:documentation>For Voucher type coupons only, where applicable the valid to date and time of codes to be assigned at the point when they are issued.</xs:documentation>
              </xs:annotation>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
      </xs:all>
      <xs:anyAttribute processContents="skip" />
    </xs:complexType>
  </xs:element>
</xs:schema>