Skip to content

Commit

Permalink
improves readme
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Bernardi <[email protected]>
  • Loading branch information
citin committed Jul 12, 2019
1 parent d3c1a2a commit 4e88b20
Showing 1 changed file with 68 additions and 16 deletions.
84 changes: 68 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,71 @@
The Problem
Our application has movies, seasons and episodes. Let's simplify the metadata, so it only has a title and a plot. An episode belongs to a season and a season can have N episodes, the episode also has the number of episode in the season.
# The Problem

Our application has movies, seasons and episodes.
Movies and seasons can be purchased (but not episodes), each one can have several purchase options, a purchase option has a price (2.99) and a video quality (HD or SD).
We also have users, to simplify, a user will only have an email.
A user can make a purchase of a content (movie/season) through a purchase option. When a user makes a purchase, we store it in his library, the user has up to 2 days to see the content. In his library, we only show the titles that the user has "alive" and he can see and not the expired purchases. Also, while the user has a content in his library, he can't purchase the same content again.
For instance, if the user purchases the movie '300: Rise of an Empire' and goes to his library, he will find the movie. If he tries to purchase it again, he will receive an error. 3 days after, if he goes to the library, the movie will not appear in his library and he can purchase it again.

We also have users. A user can make a purchase of a content (movie/season) through a purchase option. When a user makes a purchase, we store it in his library, the user has up to 2 days to see the content. In his library, we only show the titles that the user has "alive" and he can see and not the expired purchases. Also, while the user has a content in his library, he can't purchase the same content again.

Define and implement the following JSON REST API in Ruby:
1. An endpoint to return the movies, ordered by creation.
2. An endpoint to return the seasons ordered by creation, including the list of episodes ordered by its number. 3. An endpoint to return both movies and seasons, ordered by creation.
4. An endpoint for a user to perform a purchase of a content.
5. An endpoint to get the library of a user ordered by the remaining time to watch the content.
Notes:
A. Implement the API following REST principles
B. Use any gem or library that you need (except gems like rocket pants)
C. Implement the tests that you consider appropriate
D. Implement a caching mechanism when appropriate
E. There is no need to implement authentication. Suppose that the user is already registered and authenticated, you can identify the user in each request by a parameter like user_id.
F. Use a SQL database to persist the data

1. An endpoint to return the movies, ordered by creation.

```
/api/v1/movies
```

2. An endpoint to return the seasons ordered by creation, including the list of episod
es ordered by its number.

```
/api/v1/seasons
```

3. An endpoint to return both movies and seasons, ordered by creation.

```
/api/v1/movies_and_seasons
```

4. An endpoint for a user to perform a purchase of a content.

```
/api/v1/users/:id/purchase
```

5. An endpoint to get the library of a user ordered by the remaining time to watch the content.

```
/api/v1/users/:id/purchases
params: { "purchase_option_id": 2 }
```

# Installation

- Install dependencies:

```
bundle install
```

- Setup database

```
rails db:setup
rails db:migrate
```

- Run local server

```
rails server
```

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.


# ToDo

- Add validations
- Add pagination on json responses
- Add caching

0 comments on commit 4e88b20

Please sign in to comment.