Skip to content

Commit

Permalink
Examples for API requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeiniesta committed Mar 18, 2012
1 parent b566a5f commit fb3d78f
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 17 deletions.
2 changes: 1 addition & 1 deletion content/api/v1/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

In order to access most parts of the Qoolife API, you'll need to authenticate your requests via HTTP Basic Authentication, passing a valid username and password.

You can signup as an user on [Qoolife.com](http://qoolife.com)
You can signup to get a user account on [Qoolife.com](https://qoolife.com)
10 changes: 10 additions & 0 deletions content/api/v1/hello.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ If you don't authenticate, it will return:
If you do authenticate, it will return:

{:hello => 'username'}

Example request:

<pre class="console">
curl -u 'user@example.com' https://qoolife.com/api/v1/hello
</pre>

Response:

{:hello => 'Joe'}
47 changes: 45 additions & 2 deletions content/api/v1/journal_entries/create.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
---
title: Qoolife API V1 Journal Entries Creation
---

# Journal Entries Creation

You can create a new journal entry for the authenticated user with:
You can create a new journal entry for the authenticated user submitting its data to:

<pre>
POST /api/v1/journal_entries
</pre>

<dl>
<dt>journal_entry[body]</dt>
<dd>Text for the entry body</dd>
<dt>journal_entry[date]</dt>
<dd>Date for the entry</dd>
<dt>journal_entry[private]</dt>
<dd>Boolean value to indicate if the entry will be marked as private. Can be 1 (true) or 0 (false). By default, it's false so you only need to include this param if you want to set it to true.</dd>
</dl>

Currently the API does not support creating measurements for the entries.

Example request:

<pre class="console">
curl -u 'user@example.com:sekret' -X POST -d "journal_entry[body]=a private entry for October 5th 15:35;journal_entry[date]=2012-10-05T15:35;journal_entry[private]=1" https://qoolife.com/api/v1/journal_entries
</pre>

Response:

<pre>
HTTP/1.1 201 Created

POST /api/v1/journal_entries
{
"id":609,
"user_id":1,
"author_id":1,
"body":"a private entry for October 5th 15:35",
"body_html":"&lt;p&gt;a private entry for October 5th 15:35&lt;/p&gt;",
"private":true,
"date":"2012-10-05T15:35:00+02:00",
"created_at":"2012-03-18T10:40:30+01:00",
"updated_at":"2012-03-18T10:40:30+01:00",
"comments_count":0,
"measurements":[]
}
</pre>
65 changes: 63 additions & 2 deletions content/api/v1/journal_entries/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
---
title: Qoolife API V1 Journal Entries Listing
---

# Journal Entries Listing

You can get all journal entries for the authenticated user with:
You can get all journal entries for the authenticated user from:

<pre>
GET /api/v1/journal_entries
</pre>

The response will be a JSON array with all the journal entries for the user, including an array of measurements for each individual entry.

Example request:

<pre class="console">
curl -v -u 'user@example.com:sekret' https://qoolife.com/api/v1/journal_entries
</pre>

Response:

<pre>
HTTP/1.1 200 OK

GET /api/v1/journal_entries
[
{
"id":202,
"author_id":1,
"user_id":1,
"body":"Id autem",
"body_html":"&lt;p&gt;Id autem&lt;/p&gt;",
"comments_count":0,
"private":false,
"date":"2011-07-18T09:41:00+02:00",
"created_at":"2011-07-19T09:41:47+02:00",
"updated_at":"2011-11-30T16:48:24+01:00",
"measurements":[
{
"created_at":"2011-07-19T09:41:47+02:00",
"date":"2011-07-18T09:41:00+02:00",
"float_value":68.0,
"id":99,
"int_value":null,
"journal_entry_id":202,
"text_value":"68.0",
"updated_at":"2011-11-30T16:48:24+01:00",
"user_id":1,
"variable_id":1
},
{
"created_at":"2011-07-19T09:41:47+02:00",
"date":"2011-07-18T09:41:00+02:00",
"float_value":null,
"id":100,
"int_value":0,
"journal_entry_id":202,
"text_value":null,
"updated_at":"2011-09-05T20:56:09+02:00",
"user_id":1,
"variable_id":3
}
]
}
]
</pre>
23 changes: 22 additions & 1 deletion content/api/v1/users/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,25 @@ title: Qoolife API V1 Users Login

You can get all info for the authenticated user from

GET /api/v1/users/info
<pre>
GET /api/v1/users/login
</pre>

Example request:

<pre class="console">
curl -v -u 'user@example.com:sekret' https://qoolife.com/api/v1/users/login
</pre>

Response:

<pre>
HTTP/1.1 200 OK

{
"id":1,
"email":"user@example.com",
"first_name":"First Name",
"last_name":"Last Name"
}
</pre>
6 changes: 6 additions & 0 deletions layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
.sidebar-nav {
padding: 9px 0;
}

.console {
background-color: #000;
color: #FFF;
font-weight: bold;
}
</style>
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">

Expand Down
8 changes: 7 additions & 1 deletion output/api/v1/authentication/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
.sidebar-nav {
padding: 9px 0;
}

.console {
background-color: #000;
color: #FFF;
font-weight: bold;
}
</style>
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">

Expand Down Expand Up @@ -73,7 +79,7 @@ <h1 id="authentication">Authentication</h1>

<p>In order to access most parts of the Qoolife API, you’ll need to authenticate your requests via HTTP Basic Authentication, passing a valid username and password.</p>

<p>You can signup as an user on <a href="http://qoolife.com">Qoolife.com</a></p>
<p>You can signup to get a user account on <a href="https://qoolife.com">Qoolife.com</a></p>
</div><!--/span-->
</div><!--/row-->

Expand Down
6 changes: 6 additions & 0 deletions output/api/v1/data-format/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
.sidebar-nav {
padding: 9px 0;
}

.console {
background-color: #000;
color: #FFF;
font-weight: bold;
}
</style>
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">

Expand Down
17 changes: 17 additions & 0 deletions output/api/v1/hello/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
.sidebar-nav {
padding: 9px 0;
}

.console {
background-color: #000;
color: #FFF;
font-weight: bold;
}
</style>
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">

Expand Down Expand Up @@ -84,6 +90,17 @@ <h1 id="hello">Hello</h1>
<p>If you do authenticate, it will return:</p>

<pre><code>{:hello =&gt; 'username'}
</code></pre>

<p>Example request:</p>

<pre class="console">
curl -u 'user@example.com' https://qoolife.com/api/v1/hello
</pre>

<p>Response:</p>

<pre><code>{:hello =&gt; 'Joe'}
</code></pre>
</div><!--/span-->
</div><!--/row-->
Expand Down
50 changes: 46 additions & 4 deletions output/api/v1/journal_entries/create/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<title>Qoolife API V1 Journal Entries Creation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
Expand All @@ -17,6 +17,12 @@
.sidebar-nav {
padding: 9px 0;
}

.console {
background-color: #000;
color: #FFF;
font-weight: bold;
}
</style>
<link href="/css/bootstrap-responsive.min.css" rel="stylesheet">

Expand Down Expand Up @@ -71,10 +77,46 @@
<div class="span10">
<h1 id="journal-entries-creation">Journal Entries Creation</h1>

<p>You can create a new journal entry for the authenticated user with:</p>
<p>You can create a new journal entry for the authenticated user submitting its data to:</p>

<pre>
POST /api/v1/journal_entries
</pre>

<dl>
<dt>journal_entry[body]</dt>
<dd>Text for the entry body</dd>
<dt>journal_entry[date]</dt>
<dd>Date for the entry</dd>
<dt>journal_entry[private]</dt>
<dd>Boolean value to indicate if the entry will be marked as private. Can be 1 (true) or 0 (false). By default, it's false so you only need to include this param if you want to set it to true.</dd>
</dl><p>Currently the API does not support creating measurements for the entries.</p>

<p>Example request:</p>

<pre class="console">
curl -u 'user@example.com:sekret' -X POST -d "journal_entry[body]=a private entry for October 5th 15:35;journal_entry[date]=2012-10-05T15:35;journal_entry[private]=1" https://qoolife.com/api/v1/journal_entries
</pre>

<p>Response:</p>

<pre>
HTTP/1.1 201 Created

<pre><code>POST /api/v1/journal_entries
</code></pre>
{
"id":609,
"user_id":1,
"author_id":1,
"body":"a private entry for October 5th 15:35",
"body_html":"&lt;p&gt;a private entry for October 5th 15:35&lt;/p&gt;",
"private":true,
"date":"2012-10-05T15:35:00+02:00",
"created_at":"2012-03-18T10:40:30+01:00",
"updated_at":"2012-03-18T10:40:30+01:00",
"comments_count":0,
"measurements":[]
}
</pre>
</div><!--/span-->
</div><!--/row-->

Expand Down
Loading

0 comments on commit fb3d78f

Please sign in to comment.