<?xml version="1.0" encoding="UTF-8"?>

<schema targetNamespace="http://namespace.com.ua/epp/balance-1.0"
        xmlns:balance="http://namespace.com.ua/epp/balance-1.0"
        xmlns="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified">

  <annotation>
    <documentation>
      The registry's own EPP extension for account figures: what a registrar has, and
      what it can spend.

      Two frames carry the same &lt;balance:infData&gt; — the answer to a
      &lt;balance:info&gt; query and the low-balance notice from the message queue —
      so one parser serves both. Only the notice also carries
      &lt;balance:threshold&gt;.

      Declare the namespace at login to use it. The manual's Balance page describes
      each figure and which one an operation is checked against:
      https://namespace.com.ua/for-developers
    </documentation>
  </annotation>

  <!--
  In <command><info>: the balance query. It takes no argument — the figures returned are always those
  of the account the session is logged in as.

  <contract> is accepted and ignored, for clients ported from another .UA interface that requires it.
  It must be in this namespace; the same element in any other namespace is a 2001.
  -->
  <element name="info" type="balance:infoType"/>

  <complexType name="infoType">
    <sequence>
      <element name="contract" type="balance:contractType" minOccurs="0"/>
    </sequence>
  </complexType>

  <simpleType name="contractType">
    <restriction base="token"/>
  </simpleType>

  <!--
  In <resData> of a <balance:info> reply, and in <resData> of the low-balance notice.

  The order below is the order the elements are sent in. Every one is optional because the notice
  sends only <balance> and <threshold>; the query reply sends the first three.
  -->
  <element name="infData" type="balance:infDataType"/>

  <complexType name="infDataType">
    <sequence>
      <element name="creditLimit" type="balance:amountType" minOccurs="0"/>
      <element name="balance" type="balance:amountType" minOccurs="0"/>
      <element name="availableCredit" type="balance:amountType" minOccurs="0"/>
      <!-- The low-balance notice only: the threshold that was crossed. Its absence is how a reader
           tells a plain balance report from a warning. -->
      <element name="threshold" type="balance:amountType" minOccurs="0"/>
    </sequence>
  </complexType>

  <!--
  A money amount as a decimal string ("12480.00", "0.00"), unrounded and unformatted. It is signed:
  <balance> is negative on an account drawn against its credit line.

  There is no currency attribute — the currency belongs to the account, not to an individual figure.
  -->
  <simpleType name="amountType">
    <restriction base="decimal"/>
  </simpleType>

</schema>
