Gastus API

Expenses

Show

GET /expenses/#{id}.xml

Returns a single expense.

Response

Status: 200 OK

<expense>
  <amount type="float">12.52</amount>
  <concept-id type="integer">49</concept-id>
  <created-at type="datetime">2007-08-10T18:38:12Z</created-at>
  <date type="date">2007-08-10</date>
  <description>Lunch with Cristina</description>
  <id type="integer">793</id>
  <updated-at type="datetime">2007-08-10T18:38:12Z</updated-at>
</expense>

List All

GET /expenses.xml

Returns a collection of expenses. Note that this request has no filter applied, so the response could be very long.

Response

Status: 200 OK

<expenses>
  <expense>
    ...
  </expense>

  <expense>
    ...
  </expense>
</expenses>

List Within Month

GET /expenses/#{year}/#{month}.xml

Returns a collection of expenses that belongs to month and year (Based on current time in user's timezone).

Response

Status: 200 OK

<expenses>
  <expense>
    ...
  </expense>

  <expense>
    ...
  </expense>
</expenses>

List Within Period

GET /expenses.xml?filter=#{period}

Returns a collection of expenses that belongs to period (Based on current time in user's timezone).
possible periods are:

Response

Status: 200 OK

<expenses>
  <expense>
    ...
  </expense>

  <expense>
    ...
  </expense>
</expenses>

List With Concept

GET /concepts/#{concept-id}/expenses.xml

Returns a collection of expenses that belongs to the concept referred in the URL.

Tip: You could combine Period and Concept List to, for example, List this month's expenses that belongs to some concept:
GET /concepts/#{concept-id}/expenses.xml?filter=this_month

Response

Status: 200 OK

<expenses>
  <expense>
    ...
  </expense>

  <expense>
    ...
  </expense>
</expenses>

List By Search Properties

GET /expenses/search.xml?#{search_properties}

Returns a collection of expenses that matchs the search properties. Possible properties are:

Examples:
GET /expenses/search.xml?initial_date=2007-08-01&description=Cristina - This would find expenses from 2007-08-01 matching description like Cristina.
GET /expenses/search.xml?final_cost=50&initial_date=2007-08-01 - This would find expenses from 2007-08-01 that costs below 50 Euro/Dollar/Whatever.

Response

Status: 200 OK

<expenses>
  <expense>
    ...
  </expense>

  <expense>
    ...
  </expense>
</expenses>

Create

POST /expenses.xml

Creates a new expense. The XML for the new expense is returned on a successful request with the timestamps recorded and ids for the expense.

Request

<expense>
    <date type="date">2007-08-10</date>
    <concept-id type="integer">49</concept-id>
    <amount type="float">12.52</amount>
    <description>Lunch with Cristina</description>
  </expense>

Response

Status: 201 Created
Location: http://test.gastus.com/expenses/#{new-expense-id}.xml

<expense>
  ...
</expense>

Update

PUT /expenses/#{id}.xml

Updates an existing expense with new details from the submitted XML.

Request

<expense>
      <date type="date">2007-08-10</date>
      <concept-id type="integer">49</concept-id>
      <amount type="float">12.52</amount>
      <description>Lunch with Cristina</description>
    </expense>

Response

Status: 200 OK

Destroy

DELETE /expenses/#{id}.xml

Destroys the expense at the referenced URL.

Response

Status: 200 OK