Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to define how you're going to treat "credits" in your system; it matters whether or not you intend to define them as resources or as an attribute of your customer resource.</p> <p>In the examples below, I'm going to use XML to represent the resources/entities. This may work for you, but you'll need to have some consistent way of representing your resources in requests and responses - this will help you avoid using query parameters (e.g. <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a>?<em>foo=bar</em>) to define data that belongs in the request body.</p> <p>A couple of ways of representing credits:</p> <ol> <li><p>If a "credit" is <strong>an attribute</strong> of your "customer":</p> <pre><code>&lt;customer id="21"&gt; &lt;balance&gt;10&lt;/balance&gt;&lt;!-- aka credit --&gt; &lt;/customer&gt; </code></pre> <p>Then you might as well just GET the customer, update the credit/balance with your client, and then PUT the <code>&lt;customer&gt;</code> back to <code>/customer/21</code>.</p></li> <li><p>If a "credit" is <strong>its own resource</strong>:</p> <p>You can POST the following to <code>/credit</code>:</p> <pre><code>&lt;credit&gt; &lt;dateApplied&gt;2009-10-15 15:00:00&lt;/dateApplied&gt; &lt;customer href="/customer/21"/&gt; &lt;amount&gt;5&lt;/amount&gt; &lt;/credit&gt; </code></pre> <p>Or you can POST the following to <code>/customer/21/credits</code> (assuming that URI is a list of all of the <code>&lt;credit&gt;</code>s applied to the customer):</p> <pre><code>&lt;credit&gt; &lt;dateApplied&gt;2009-10-15 15:00:00&lt;/dateApplied&gt; &lt;amount&gt;5&lt;/amount&gt; &lt;/credit&gt; </code></pre> <p>This would "append" a new <code>&lt;credit&gt;</code> to the existing list. And also eliminates the need to provide the <code>&lt;customer&gt;</code> in the entity, since it's already present in the URI.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload