Closed aksnell closed 4 years ago
https://github.com/aksnell/TamagotchiAPI
Theoretically adventure mode is done, not happy with forcing synchronous client side evaluation.
Nicely done. Come find me during the week at some point if you want to discuss the synchronous code.
Your homework 04 - 04 - The Rise of the Tamagotchi was marked: Exceeds Expectations
“You got it!”
To start your journey you will be creating an API that allows a user to create and care for a virtual pet, reminiscent of a Tamagotchi. The basic functionality will walk you through the four basic parts of a web API, create, read, update and delete.
Objectives
Explorer Mode
Create and new
sdg-api
that has the following featuresCreate a database with one table named
Pets
.Pet
with the following columns:Your API should have the following endpoints
GET /pets
, should return all pets in your database.GET /pets/{id}
, should return the pet with the corresponding id.POST /pets
, should create a new pet. The body of the request should contain a JSON object with a key of "name" and a value of the pet's name. The petsBirthday
should default to the current datetime,HungerLevel
defaults to 0 andHappinessLevel
defaults to 0.POST /pets/{id}/playtimes
, should find the pet by id and add 5 to its happiness level and 3 to its hungry level.POST /pets/{id}/feedings
, should find the pet by id and subtract 5 from its hungry level and 3 from its happiness level.POST /pets/{id}/scoldings
, should find the pet by id and subtract 5 from its happiness level.DELETE /pets/{id}
, should delete a pet from the database by IdAdventure Mode
Add the following features to your API
LastInteractedWithDate
(DateTime). Every time a pet us updated in the database, set theLastInteractedWithDate
to the current time. Add a property namedIsDead
to yourPets
that has logic such that if theLastInteractedWithDate
is over 3 days old, the property returnstrue
otherwisefalse
.GET /pets
that only returns Pets that are alive.Epic mode
Create a console app that interacts with your API that:
Resources