To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorRESTfulness
The backend provides RESTfull APIs to handle any JSON object
- Background
-
- Given
- client is authenticated
- And
- client accepts JSON
- Scenarios
-
- Adding one object
- Getting one object
- Overriding an object (replacing while keeping the '_id')
- Mutating an object
- Deleting one object
- Getting the list of objects
- Adding one object
-
- When
-
client requests POST /api/buildings with JSON:
{ "label": "Town Hall", "level": 3, "elixir_storage": 398, "elixir_storage_max": 1000, "gold_storage": 236, "gold_storage_max": 1000, "health": 1850, "health_max": 1850 }
- Then
- response status should be 200
- And
- the JSON response should have "id"
- Getting one object
-
- Given
-
the system knows this Building JSON:
{ "_id" : "541816f042e7d8204d000001", "label" : "Town Hall", "level" : 3, "elixir_storage" : 398, "elixir_storage_max" : 1000, "gold_storage" : 236, "gold_storage_max" : 1000, "health" : 1850, "health_max" : 1850, "_owner" : "[email protected]" }
- When
- client requests GET /api/buildings/541816f042e7d8204d000001
- Then
- response status should be 200
- And
-
response body should be JSON:
{ "_id" : "541816f042e7d8204d000001", "label" : "Town Hall", "level" : 3, "elixir_storage" : 398, "elixir_storage_max" : 1000, "gold_storage" : 236, "gold_storage_max" : 1000, "health" : 1850, "health_max" : 1850, "_owner" : "[email protected]" }
- Overriding an object (replacing while keeping the '_id')
-
- Given
-
the system knows those Buildings:
_id label level _owner 541816f042e7d8204d000001 Town Hall 3 [email protected] 541816f042e7d8204d000002 Army Camp 3 [email protected] 541816f042e7d8204d000003 Gold Mine 3 [email protected] - When
-
client requests PUT /api/buildings/541816f042e7d8204d000001 with JSON:
{ "label": "Clan Castle", "level": 1 }
- Then
- response status should be 200
- And
-
response body should be JSON:
{ "status": "ok" }
- And
-
Building with id "541816f042e7d8204d000001" should be JSON:
{ "_id": { "$oid": "541816f042e7d8204d000001" }, "label": "Clan Castle", "level": 1, "_owner": "[email protected]" }
- Mutating an object
-
- Given
-
the system knows those Buildings:
_id label level _owner 541816f042e7d8204d000001 Town Hall 3 [email protected] 541816f042e7d8204d000002 Army Camp 3 [email protected] 541816f042e7d8204d000003 Gold Mine 3 [email protected] - When
-
client requests PATCH /api/buildings/541816f042e7d8204d000001 with JSON:
{ "level": 5, "elixir_storage" : 9999, "elixir_storage_max" : 9999, "gold_storage" : 9999, "gold_storage_max" : 9999, "health" : 9999, "health_max" : 9999}
- Then
- response status should be 200
- And
-
response body should be JSON:
{ "status": "ok" }
- And
-
Building with id "541816f042e7d8204d000001" should be JSON:
{ "_id": { "$oid": "541816f042e7d8204d000001" }, "label": "Town Hall", "level": 5, "elixir_storage" : 9999, "elixir_storage_max" : 9999, "gold_storage" : 9999, "gold_storage_max" : 9999, "health" : 9999, "health_max" : 9999, "_owner": "[email protected]" }
- Deleting one object
-
- Given
-
the system knows this Building JSON:
{ "_id" : "541816f042e7d8204d000001", "label" : "Town Hall", "level" : 3, "elixir_storage" : 398, "elixir_storage_max" : 1000, "gold_storage" : 236, "gold_storage_max" : 1000, "health" : 1850, "health_max" : 1850, "_owner" : "[email protected]" }
- When
- client requests DELETE /api/buildings/541816f042e7d8204d000001
- Then
- response status should be 200
- And
-
response body should be JSON:
{ "status": "ok" }
- When
- client requests GET /api/buildings/541816f042e7d8204d000001
- Then
- response status should be 422
- And
-
response body should be JSON:
{ "status": "Unprocessable Entity", "message": "Object with _id 541816f042e7d8204d000001 not found." }
- Getting the list of objects
-
- Given
-
the system only knows those Buildings:
_id label level _owner 541816f042e7d8204d000001 Town Hall 3 [email protected] 541816f042e7d8204d000002 Army Camp 3 [email protected] 541816f042e7d8204d000003 Gold Mine 3 [email protected] - When
- client requests GET /api/buildings
- Then
- response status should be 200
- And
-
response body should be JSON:
[ { "_id" : "541816f042e7d8204d000001", "label" : "Town Hall", "level" : 3, "_owner" : "[email protected]" }, { "_id" : "541816f042e7d8204d000002", "label" : "Army Camp", "level" : 3, "_owner" : "[email protected]" }, { "_id" : "541816f042e7d8204d000003", "label" : "Gold Mine", "level" : 3, "_owner" : "[email protected]" } ]
Last published over 7 years ago by Bruno Le Hyaric.