<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://plm.marchex.com/service/account"
            xmlns="http://plm.marchex.com/service/account"
            xmlns:tns="http://plm.marchex.com/service/account">
    <xsd:annotation>
        <xsd:documentation xml:lang="en">
         Account schema for PLM-J
         &#169; 2006 Marchex, INC
        </xsd:documentation>
    </xsd:annotation>

    <xsd:simpleType name="email">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="[A-Za-z._-]+@[A-Za-z._-]+\.[a-zA-Z]+"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:element name="accounts">
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="account" type="tns:account" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>

    <xsd:element name="account" type="tns:account"/>

    <xsd:complexType name="account">
      <xsd:attribute name="id" use="optional" type="xsd:int"/>
      <!-- 1140220204: this is a soft requirement for some actions, actions
      that require it will throw faults upon it's absence -->
      <xsd:attribute name="name" use="optional" type="xsd:string"/>
      <xsd:attribute name="auto-renew" use="optional" type="xsd:decimal"/>
      <xsd:attribute name="daily-cap" use="optional" type="xsd:decimal"/>
      <xsd:attribute name="card-id" use="optional" type="xsd:int"/>
    </xsd:complexType>

    <xsd:element name="charge">
      <xsd:complexType>
        <xsd:attribute name="card-id" use="required" type="xsd:integer"/>
        <xsd:attribute name="amount" use="required" type="xsd:float"/>
      </xsd:complexType>
    </xsd:element>

    <xsd:element name="card">
      <xsd:complexType>
        <xsd:attribute name="card-id" use="required" type="xsd:integer"/>
        <xsd:attribute name="number" use="optional" value="xsd:string"/>
      </xsd:complexType>
    </xsd:element>

    <xsd:element name="user">
      <xsd:complexType>
        <xsd:attribute name="id" use="optional" type="xsd:int"/>
        <xsd:attribute name="email" use="required" type="tns:email"/>
        <xsd:attribute name="password" use="required" type="xsd:string"/>
        <xsd:attribute name="name" use="required" type="xsd:string"/>
        <xsd:sequence>
          <!-- 1140220204: This is the reason, our specification demands we
          accept nothing more than a list of ids when a user is created.
          Otherwise, we may likely return a list of accounts.  But we actually
          never return a user. -->
          <xsd:element name="account" type="tns:account" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
</xsd:schema>
