-
Notifications
You must be signed in to change notification settings - Fork 0
API: Positions
jorge-d edited this page Feb 4, 2013
·
1 revision
Route: POST /api/v1/positions
You must send your coordinates (latitude and longitude)
Example:
curl -X POST \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
-d 'position[latitude]=40.170479&position[longitude]=-8.838501' \
http://localhost:3001/api/v1/positions
Will produce the following output on success:
{
"address": null,
"created_at": "2013-02-04T17:53:11Z",
"id": 16,
"latitude": 40.170479,
"longitude": -8.838501,
"updated_at": "2013-02-04T17:53:11Z",
"user_id": 1
}
Or this one in case there is any error (with a status code of 400):
curl -X POST \ -H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
http://localhost:3001/api/v1/positions | json
{
"error": {
"latitude": [
"can't be blank",
"is not included in the list"
],
"longitude": [
"can't be blank",
"is not included in the list"
]
}
}
Route: GET /api/v1/positions
This will return all your past positions
Example:
curl -X GET \
-H "Accept: application/json" \
-d 'auth_token=sYcyvuHUopjT46iMhkU5' \
http://localhost:3001/api/v1/positions
[
{
"id": 1,
"user_id": 1,
"address": null,
"latitude": 48.81561,
"longitude": 2.363155,
"created_at": "2013-02-02T18:28:51Z"
},
{
"id": 2,
"user_id": 1,
"address": null,
"latitude": 53.424571,
"longitude": -6.243839,
"created_at": "2013-02-02T18:28:51Z"
},
{
"id": 3,
"user_id": 1,
"address": null,
"latitude": 53.34471,
"longitude": -6.262379,
"created_at": "2013-02-02T18:28:51Z"
},
{
"id": 4,
"user_id": 1,
"address": null,
"latitude": 53.332536,
"longitude": -6.279081,
"created_at": "2013-02-02T18:28:51Z"
}
]