pawanpoudel/location_tester_user_service — pull request #3 by pawanpoudel (2013-10-04 15:00:54+00:00)
Title: Features/update user

This PR allows client code to update user information by PUTting valid data. Listed below are HTTP request and response body.

Valid PUT request
---------------------------
~~~shell
curl -X PUT -H "Content-Type: application/json" -d '{"email":"hisdudeness@example.com","bio":"Memeber of the SLF"}' http://localhost:9393/api/v1/users/the_dude
~~~

~~~json
{
"id": 16,
"name": "the_dude",
"email": "hisdudeness@example.com",
"bio": "Memeber of the SLF",
"created_at": "2013-10-04T00:39:20Z",
"updated_at": "2013-10-04T14:49:20Z"
}
~~~

PUT request for updating non-existent user
------------------------------------------------------------
~~~shell
curl -X PUT -H "Content-Type: application/json" -d '{"email":"donnie@example.com","bio":"Bowler"}' http://localhost:9393/api/v1/users/donnie
~~~

~~~json
{
"error": "User not found"
}
~~~

PUT request for updating non-existent attribute
-----------------------------------------------------------------
~~~shell
curl -X PUT -H "Content-Type: application/json" -d '{"job":"The bag man"}' http://localhost:9393/api/v1/users/the_dude
~~~

~~~json
{
"error": "unknown attribute: job"
}
~~~

Invalid PUT request (payload is missing)
---------------------------------------------------------
~~~shell
curl -X PUT http://localhost:9393/api/v1/users/the_dude
~~~

~~~json
{
"error": "Invalid request: A JSON text must at least contain two octets!"
}
~~~