<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    targetNamespace="http://services.mobile.de/schema/seller/seller-ad-1.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:types="http://services.mobile.de/schema/seller/types-1.0"
    xmlns:ad="http://services.mobile.de/schema/seller/seller-ad-1.1"
    xmlns:vehicle="http://services.mobile.de/schema/seller/vehicle-1.0"
    xmlns:price="http://services.mobile.de/schema/seller/price-1.0"
    xmlns:seller="http://services.mobile.de/schema/common/seller-3.0"
    elementFormDefault="qualified">

    <xs:import namespace="http://services.mobile.de/schema/seller/types-1.0" schemaLocation="types-1.0.xsd"/>
    <xs:import namespace="http://services.mobile.de/schema/seller/vehicle-1.0" schemaLocation="vehicle-1.0.xsd"/>
    <xs:import namespace="http://services.mobile.de/schema/seller/price-1.0" schemaLocation="price-1.0.xsd"/>
    <xs:import namespace="http://services.mobile.de/schema/common/seller-3.0" schemaLocation="../common/seller-3.0.xsd"/>

    <xs:element name="ad">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="creation-date" type="xs:dateTime" minOccurs="0"/>
                <xs:element name="modification-date" type="xs:dateTime" minOccurs="0"/>
                <xs:element name="renewal-date" type="xs:dateTime" minOccurs="0"/>
                <xs:element name="seller-inventory-key" type="types:stringValueType" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>A reference key used by the seller. Also known as internal-number or
                            internal-ID. If it is present, then it must be unique per seller. An empty string is treated
                            same as if the element was not present.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="description" type="xs:string" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Closer description of the vehicle</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="highlights" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Short notes highlighting key features of the vehicle</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="highlight" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>

                <xs:element name="mobile-features" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="feature" type="ad:mobile-feature-type" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="multimedia-id" type="types:stringValueType" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Deprecated. Do not use this.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="visibilities" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="visibility" type="ad:visibility-type" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element ref="vehicle:vehicle"/>
                <xs:element ref="ad:images" minOccurs="0"/>
                <xs:element ref="price:price"/>
                <xs:element ref="ad:extension" minOccurs="0" maxOccurs="1"/>
                <xs:element ref="seller:seller" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
            <xs:attribute name="id" use="optional" type="xs:long"/>
            <xs:attribute name="site" use="optional" type="ad:site-type"/>
            <xs:attribute name="customer-id" use="optional" type="xs:long"/>
            <xs:attribute name="blocked" use="optional" type="xs:boolean"/>
            <xs:attribute name="external-detail-page" use="optional" type="xs:string"/>
            <xs:attribute name="system-emails-suppressed" use="optional" type="xs:boolean">
                <xs:annotation>
                    <xs:documentation>When set to 'true' neither system nor marketing emails will be sent to seller.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="upload-sticky" use="optional" type="xs:boolean">
                <xs:annotation>
                    <xs:documentation>When set to 'true' then FTP uploads (or bulk uploads from within dealer area)
                        won't be able to change or delete this ad. Only Seller-API can change or delete it then. Don't
                        use this unless you know what you are doing. Only for dealer ads.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
        </xs:complexType>
    </xs:element>


    <xs:simpleType name="site-enum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="GERMANY"/>
            <xs:enumeration value="FRANCE"/>
            <xs:enumeration value="ITALY"/>
            <!-- append new sites here -->
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="site-type">
        <xs:union memberTypes="ad:site-enum xs:token"/>
    </xs:simpleType>

    <xs:element name="extension">
        <xs:complexType>
            <xs:sequence>
                <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>


    <xs:simpleType name="mobile-feature-enum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="PAGE_ONE_AD"/>
            <xs:enumeration value="EYE_CATCHER"/>
            <xs:enumeration value="TOP_OF_PAGE">
                <xs:annotation>
                    <xs:documentation>Bookable feature to highlight ads with a larger preview image and dealer contact
                        data at the top of each matching search result page.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="TOP_OF_PAGE_MOBILE">
                <xs:annotation>
                    <xs:documentation>Deprecated. Do not use this.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="RED_PENCIL">
                <xs:annotation>
                    <xs:documentation>Bookable feature indicating that the price of a vehicle was reduced, showing the
                        old price and the new price.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="KLEINANZEIGEN_EXPORT">
                <xs:annotation>
                    <xs:documentation>Bookable feature indicating that this ad should be exported to Kleinanzeigen.
                        Vehicle must be a car, have a milage above 1500km, minimum one picture and not be marked as "export only vehicle" and "visible for dealers only".
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="AD_TURBO">
                <xs:annotation>
                    <xs:documentation>See changelog for more details: https://services.mobile.de/manual/changelog.html#2018-01-19</xs:documentation>
                </xs:annotation>
        </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="mobile-feature-type">
        <xs:union memberTypes="ad:mobile-feature-enum xs:token"/>
    </xs:simpleType>


    <xs:simpleType name="visibility-enum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="RESERVED">
                <xs:annotation>
                    <xs:documentation>Visible only for owner</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="CLOSED_DOMAIN">
                <xs:annotation>
                    <xs:documentation>Visible only in closed domain not in public domain.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="DEALER_HOMEPAGE">
                <xs:annotation>
                    <xs:documentation>Visible as featured item on the dealers homepage ("Tagesangebot").
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="visibility-type">
        <xs:union memberTypes="ad:visibility-enum xs:token"/>
    </xs:simpleType>

    <xs:element name="images">
        <xs:annotation>
            <xs:documentation>Images of the vehicle</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="ad:image" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="image">
        <xs:annotation>
            <xs:documentation>TODO</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="ref" type="xs:string" use="required"/>
            <xs:attribute name="hash" type="xs:string" use="optional">
                <xs:annotation>
                    <xs:documentation>MD5 checksum of the original uploaded customer image</xs:documentation>
                </xs:annotation>
            </xs:attribute>
        </xs:complexType>
    </xs:element>

    <xs:element name="auto-panorama-exterior">
        <xs:annotation>
            <xs:documentation>Exterior auto panorama images of the vehicle</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="ad:image" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="auto-panorama-interior">
        <xs:annotation>
            <xs:documentation>Interior auto panorama image of the vehicle</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="1" ref="ad:image" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="duration-type">
        <xs:union memberTypes="ad:duration-enum xs:token"/>
    </xs:simpleType>

    <xs:simpleType name="duration-enum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="TWELVE_MONTHS"/>
            <xs:enumeration value="TWENTYFOUR_MONTHS"/>
            <xs:enumeration value="THIRTYSIX_MONTHS"/>
            <xs:enumeration value="FOURTYEIGHT_MONTHS"/>
            <xs:enumeration value="SIXTY_MONTHS"/>
            <xs:enumeration value="SEVENTYTWO_MONTHS"/>
            <xs:enumeration value="EIGHTYFOUR_MONTHS"/>
            <xs:enumeration value="NINETYSIX_MONTHS"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
