Version Requirements
Steps
git clone git@github.com:rrabinovitch/aetna_movie_api.git
cd aetna_movie_api
bundle install
rails db:{create,migrate}
- note that as of 11/17/20, running this command from main
will only set up the movies
database and table and not the ratings
onesbundle exec rspec
rails s
and explore the endpoints documented belowBase URL: localhost:3000/api/v1
GET /movies
page
=> specifies pagination; not specifying page defaults to page 1year
=> filters movies by specified year sorted by descending chronological order of dategenre
=> filters movies by specified genreRequest: GET localhost:3000/api/v1/movies?page=1
Response:
{
"data": [
{
"id": "2",
"type": "movie",
"attributes": {
"imdbId": "tt0094675",
"title": "Ariel",
"releaseDate": "1988-10-21",
"budget": "$0.00",
"genres": "[{\"id\": 18, \"name\": \"Drama\"}, {\"id\": 80, \"name\": \"Crime\"}]"
}
},
{
"id": "3",
"type": "movie",
"attributes": {
"imdbId": "tt0092149",
"title": "Shadows in Paradise",
"releaseDate": "1986-10-16",
"budget": "$0.00",
"genres": "[{\"id\": 18, \"name\": \"Drama\"}, {\"id\": 35, \"name\": \"Comedy\"}]"
}
},
{
"id": "5",
"type": "movie",
"attributes": {
"imdbId": "tt0113101",
"title": "Four Rooms",
"releaseDate": "1995-12-09",
"budget": "$4000000.00",
"genres": "[{\"id\": 80, \"name\": \"Crime\"}, {\"id\": 35, \"name\": \"Comedy\"}]"
}
},
{
"id": "6",
"type": "movie",
"attributes": {
"imdbId": "tt0107286",
"title": "Judgment Night",
"releaseDate": "1993-10-15",
"budget": "$0.00",
"genres": "[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 53, \"name\": \"Thriller\"}, {\"id\": 80, \"name\": \"Crime\"}]"
}
},
...
]
}
Request: GET localhost:3000/api/v1/movies?year=2005
Response:
{
"data": [
{
"id": "21705",
"type": "movie",
"attributes": {
"imdbId": "tt0795338",
"title": "Barbie Diaries",
"genres": "[{\"id\": 10751, \"name\": \"Family\"}, {\"id\": 16, \"name\": \"Animation\"}]",
"releaseDate": "2005-12-31",
"budget": "$0.00"
}
},
{
"id": "26147",
"type": "movie",
"attributes": {
"imdbId": "tt0453365",
"title": "FC Venus",
"genres": "[{\"id\": 35, \"name\": \"Comedy\"}, {\"id\": 10749, \"name\": \"Romance\"}]",
"releaseDate": "2005-12-30",
"budget": "$2196531.00"
}
},
{
"id": "45035",
"type": "movie",
"attributes": {
"imdbId": "tt0492835",
"title": "King and the Clown",
"genres": "[{\"id\": 18, \"name\": \"Drama\"}, {\"id\": 36, \"name\": \"History\"}, {\"id\": 53, \"name\": \"Thriller\"}]",
"releaseDate": "2005-12-29",
"budget": "$0.00"
}
},
...
{
"id": "40017",
"type": "movie",
"attributes": {
"imdbId": "tt0499041",
"title": "Kalyug",
"genres": "[{\"id\": 10769, \"name\": \"Foreign\"}, {\"id\": 53, \"name\": \"Thriller\"}]",
"releaseDate": "2005-12-09",
"budget": "$0.00"
}
}
]
}
Request: GET localhost:3000/api/v1/movies?year=2005&page=5
Response:
{
"data": [
{
"id": "53935",
"type": "movie",
"attributes": {
"imdbId": "tt0419922",
"title": "Living 'til the End",
"genres": "[{\"id\": 18, \"name\": \"Drama\"}, {\"id\": 10749, \"name\": \"Romance\"}]",
"releaseDate": "2005-10-21",
"budget": "$0.00"
}
},
{
"id": "59958",
"type": "movie",
"attributes": {
"imdbId": "tt0487907",
"title": "Gideon's Daughter",
"genres": "[{\"id\": 18, \"name\": \"Drama\"}]",
"releaseDate": "2005-10-21",
"budget": "$0.00"
}
},
{
"id": "123858",
"type": "movie",
"attributes": {
"imdbId": "tt0460926",
"title": "Scab",
"genres": "[]",
"releaseDate": "2005-10-21",
"budget": "$0.00"
}
},
...
{
"id": "9621",
"type": "movie",
"attributes": {
"imdbId": "tt0368709",
"title": "Elizabethtown",
"genres": "[{\"id\": 35, \"name\": \"Comedy\"}, {\"id\": 18, \"name\": \"Drama\"}, {\"id\": 10749, \"name\": \"Romance\"}]",
"releaseDate": "2005-10-06",
"budget": "$57000000.00"
}
}
]
}
GET /movies/:id
Request: GET localhost:3000/api/v1/movies/11
Response:
{
"data": {
"id": "11",
"type": "movie",
"attributes": {
"imdbId": "tt0076759",
"title": "Star Wars",
"description": "Princess Leia is captured and held hostage by the evil Imperial forces in their effort to take over the galactic Empire. Venturesome Luke Skywalker and dashing captain Han Solo team together with the loveable robot duo R2-D2 and C-3PO to rescue the beautiful princess and restore peace and justice in the Empire.",
"releaseDate": "1977-05-25",
"budget": "$11000000.00",
"runtime": 121,
"genres": "[{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 28, \"name\": \"Action\"}, {\"id\": 878, \"name\": \"Science Fiction\"}]",
"originalLanguage": null,
"productionCompanies": "[{\"name\": \"Lucasfilm\", \"id\": 1}, {\"name\": \"Twentieth Century Fox Film Corporation\", \"id\": 306}]"
}
}
}
genres
return as objects within movies responses (see issue #10)ratings.db
chore/ratings_db_setup
branch but hit a wall when it came to setting up the model associations/relationships. At that point, I had spent well over the recommended 3-4 hours on this challenge and decided to take a step back and instead prioritize reflecting on how this assignment went.fast_jsonapi
gem, I realized that the gem is no longer maintainedmovies#index
endpoint would ideally include the specified page number in responsessimplecov
to support my testing, but did not prioritize setting it up right awayfaker
gemYour task is to create an API on top of a couple different databases. It should conform to the user stories provided below. You are free to use whatever language you prefer. Google and the interwebs are at your disposal.
The Databases
The databases are provided as a SQLite3 database in db/
. It does not require any credentials to login. You can run SQL queries directly against the database using:
sqlite <path to db file>
.tables
will return a list of available tables and .schema <table>
will provide the schema.
When developing your solution, please consider the following:
AC:
page
query paramsAC:
AC:
page
query paramsAC:
page
query params