<?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: Basket Request Schema</xs:documentation>
    <xs:documentation>The basket request provides details of a basket to be validated.  It must provide enough information to identify the company the basket is coming from, and the date and store against which the basket will be validated.  Custom Attributes and their values can be added at to basket or item elements where they have been defined.</xs:documentation>
    <xs:documentation>Version 1.0 : 2014-07-14.  Initial schema creation.</xs:documentation>
    <xs:documentation>Version 1.1 : 2015-06-14.  Updated to include 'confirmed' flag.</xs:documentation>
    <xs:documentation>Version 1.2 : 2015-10-02.  Updated to include 'currencycode' attribute.</xs:documentation>
    <xs:documentation>Version 1.3 : 2017-01-09.  Updated to include max lengths and ensure sequence is not fixed and descriptions.</xs:documentation>
    <xs:documentation>Version 1.4 : 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="basket">
    <xs:complexType>
      <xs:all>
        <xs:element minOccurs="0" maxOccurs="1" name="coupons">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="coupon">
                <xs:complexType>
                  <xs:attribute name="code" use="required">
                    <xs:annotation>
                      <xs:documentation>The coupon code to be utilized by promotions.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:minLength value="1" />
                        <xs:maxLength value="1000" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:anyAttribute processContents="skip" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" maxOccurs="1" name="selectlists">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="selectlist">
                <xs:complexType>
                  <xs:all>
                    <xs:element minOccurs="0" maxOccurs="1" name="selection">
                      <xs:complexType>
                        <xs:attribute name="id" type="xs:integer" use="optional">
                          <xs:annotation>
                            <xs:documentation>The selected item's id, as provided with the select list</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                        <xs:attribute name="useexisting" type="xs:boolean" use="optional">
                          <xs:annotation>
                            <xs:documentation>Flag indicating whether to use an existing item from the basket where available.</xs:documentation>
                          </xs:annotation>
                        </xs:attribute>
                      </xs:complexType>
                    </xs:element>
                  </xs:all>
                  <xs:attribute name="promotionid" type="xs:integer" use="optional">
                    <xs:annotation>
                      <xs:documentation>The promotion id from the select list</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="1" maxOccurs="1" name="items">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="1" maxOccurs="unbounded" name="item">
                <xs:complexType>
                  <xs:attribute name="id" use="required">
                    <xs:annotation>
                      <xs:documentation>The unique id for the line in the basket.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:integer">
                        <xs:minInclusive value="1" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="productcode" use="required">
                    <xs:annotation>
                      <xs:documentation>The identifier for the product.  Can optionally be used in conjunction with the Variant Code, where the combination of the Product Code and Variant Code must be unique.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:minLength value="1" />
                        <xs:maxLength value="200" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="variantcode" use="optional">
                    <xs:annotation>
                      <xs:documentation>The Variant Code for the product where applicable.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:maxLength value="200" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="barcode" use="optional">
                    <xs:annotation>
                      <xs:documentation>A barcode reference for the product.  Not used in product identification.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:maxLength value="200" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="quantity" use="required">
                    <xs:annotation>
                      <xs:documentation>The quantity for the line</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="price" use="required">
                    <xs:annotation>
                      <xs:documentation>The price of each item on the line</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:decimal">
                        <xs:minInclusive value="0" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="manualdiscount" use="optional">
                    <xs:annotation>
                      <xs:documentation>Where applicable, any manual discount already applied to the line by the integrating system.</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                      <xs:restriction base="xs:decimal">
                        <xs:minInclusive value="0" />
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="isdelivery" type="xs:boolean" use="optional">
                    <xs:annotation>
                      <xs:documentation>Flag indicating whether the item is a delivery charge</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="alwaysexcluded" type="xs:boolean" use="optional">
                    <xs:annotation>
                      <xs:documentation>Flag indicating whether the item should always be excluded from promotions processing</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:attribute name="isgiftcard" type="xs:boolean" use="optional">
                    <xs:annotation>
                      <xs:documentation>Flag indicating whether the basket item is a gift card.</xs:documentation>
                    </xs:annotation>
                  </xs:attribute>
                  <xs:anyAttribute processContents="skip" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:all>
      <xs:attribute name="id" use="required">
        <xs:annotation>
          <xs:documentation>A unique reference for the basket.  Where a basket is submitted multiple times the reference should be persisted for all submissions.   Typically this would be an order or transaction unique reference.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="1" />
            <xs:maxLength value="100" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <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:attribute name="basketdate" type="xs:dateTime" use="optional">
        <xs:annotation>
          <xs:documentation>The sale date for the basket.  Where a basket is submitted multiple times, the basket date should be persisted for all submissions.  The basket date is used to establish which promotions are available to the basket.</xs:documentation>
        </xs:annotation>
      </xs:attribute>
      <xs:attribute name="store" use="optional">
        <xs:annotation>
          <xs:documentation>The Store from which the basket is being submitted.  Stores are part of the store hierarchy and the supported values for this attribute are managed as part of the hierarchy.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="storegroup" use="optional">
        <xs:annotation>
          <xs:documentation>The Store Group from which the basket is being submitted.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="channel" use="optional">
        <xs:annotation>
          <xs:documentation>The Channel from which the basket is being submitted.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="customergroup" use="optional">
        <xs:annotation>
          <xs:documentation>Where applicable, the group or segmentation of the customer.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="customerid" use="optional">
        <xs:annotation>
          <xs:documentation>The unique identifier for the customer.  An internal reference should be provided, not identifiable customer details.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="deliverymethod" use="optional">
        <xs:annotation>
          <xs:documentation>The currently selected delivery method for the basket</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="baskettotal" type="xs:decimal" use="optional">
        <xs:annotation>
          <xs:documentation>The total value of the basket being validated.  This is the total of all lines in the basket and a delivery price where applicable.</xs:documentation>
        </xs:annotation>
      </xs:attribute>
      <xs:attribute name="manualdiscount" use="optional">
        <xs:annotation>
          <xs:documentation>Where applicable, a manual discount that has been applied to the basket from the integrating system.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="deliveryprice" use="optional">
        <xs:annotation>
          <xs:documentation>The price for the currently selected delivery method for the basket.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="deliverymanualdiscount" use="optional">
        <xs:annotation>
          <xs:documentation>Where applicable, a manual discount that has been applied to the delivery from the integrating system.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="get_missed_promotions" type="xs:boolean" use="optional">
        <xs:annotation>
          <xs:documentation>A flag indicating whether to provide details on missed promotions </xs:documentation>
        </xs:annotation>
      </xs:attribute>
      <xs:attribute name="confirmed" type="xs:boolean" use="optional">
        <xs:annotation>
          <xs:documentation>A flag indicating whether the basket has been confirmed as a sale.  When promotions issue or utilize coupon codes for the basket being validated, those codes will not be confirmed as issued or used unless the basket Confirmed flag has a value of true.</xs:documentation>
        </xs:annotation>
      </xs:attribute>
      <xs:attribute name="currencycode" use="optional">
        <xs:annotation>
          <xs:documentation>The currency code for the basket being submitted.  Where required currency codes can be used in the criteria of promotions to ensure a promotion targets only the required currency.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="loyaltycardno" use="optional">
        <xs:annotation>
          <xs:documentation>Where applicable, the loyalty card number for the customer/contact.</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="1000" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:anyAttribute processContents="skip" />
    </xs:complexType>
  </xs:element>
</xs:schema>