Hi!
Using this API you can create movies, showtimes and reservations for a Cinema. Additional you can search for movies using day of the week or reservations given date range.
You can find the app in heroku
https://cinema-test-maria.herokuapp.com/api/status
This project requires postgres
- Clone project from [email protected]:manvedu/cinema.git
- Install bundler
gem install bundler
- Install gems
bundle
- Create database
- Run migrations
bundle exec rake db:migrate
- Config in your
.env
file the variableDATABASE_URL
DATABASE_URL='postgres://host/db_name'
- Run command
bundle exec rackup -p 9292 config.ru
Now your app is running at localhost:9292
- Run command
bundle exec rspec spec/
- GET /status
Health check endpoint
Request:
http://localhost:9292/api/status
Response
{
"status":"ok"
}
- POST /api/v1/movies
It creates a movie Request
curl -X POST
-H "Content-Type: application/json"
-d '{
"name":"Finding Dory",
"description":"A fish lost her parents",
"image_url":"https://url_to_image",
}'
http://localhost:9292/api/v1/movies
Parameters description
Param name | Description | Type | Required | Restrictions |
---|---|---|---|---|
name | Name of the movie | String | true | There can be no more of one movie with the same name |
description | Brief data about the movie | String | true | |
image_url | URL to the image movie poster | String | true | There can be no more of one movie with the same image_url |
Response
{
"id":1,
"name":"Finding Dory",
"description":"A fish lost her parents",
"image_url":"https://url_to_image"
}
- GET /api/v1/movies
It list movies giving a day of the week Request
curl -X GET -H "Content-Type: application/json"
http://localhost:9292/api/v1/movies?day=lunes
Parameters description
Param name | Description | Type | Required | Restrictions |
---|---|---|---|---|
day | Name of day | String | true | It has to be name of day of the week in spanish |
Response
{
"movies":
[
{
"id":1,
"name":"Finding Dory",
"description":"A fish lost her parents",
"image_url":"https://url_to_image"
},
{
"id":2,
"name":"Finding Nemo",
"description":"Two fishes search a lost fish",
"image_url":"https://url_to_image_2"
},
]
}
- POST /api/v1/showtimes
It creates a showtime Request
curl -X POST
-H "Content-Type: application/json"
-d '{
"movie_id": 1,
"date":"2019-10-20"
}'
http://localhost:9292/api/v1/showtimes
Parameters description
Param name | Description | Type | Required | Restrictions |
---|---|---|---|---|
movie_id | Id of the movie associated | Integer | true | It has to be for an existing movie |
date | Date when the movie will be presenting | String | true | It has to have format YYYY-mm-dd |
Response
{
"id":1,
"movie_id": 1,
"date": "2019-10-20",
"available_capacity": 10,
"day_of_the_week": 7,
}
- POST /api/v1/reservations
It creates a reservation Request
curl -X POST
-H "Content-Type: application/json"
-d '{
"showtime_id":5,
"identity_number":1234567,
"number_of_people":3
}'
http://localhost:9292/api/v1/reservations
Parameters description
Param name | Description | Type | Required | Restrictions |
---|---|---|---|---|
showtime_id | Id of the showtime associated | Integer | true | It has to be for an existing showtime |
identity_number | Identity number for a person (C.C.) | Integer | true | |
number_of_people | number of people in the reservation | Integer | true | It can not be more than 10 or number available capacity has the showtime |
Response
{
"id":1,
"showtime_id": 1,
"identity_number":1234567,
"number_of_people":3
}
- GET /api/v1/reservations
It list reservations giving a range of dates Request
curl -X GET
-H "Content-Type: application/json"
http://localhost:9292/api/v1/reservations?initial_date=2019-10-20&end_date=2019-10-23
Parameters description
initial_date | First date for searching movies with associated showtimes | String | true | It has to have format YYYY-mm-dd |
end_date | End date for searching movies with associated showtimes | String | true | It has to have format YYYY-mm-dd |
Response
{
"reservations":
[
{
"id":1,
"showtime_id":5,
"identity_number":1234567,
"number_of_people":3
},
{
"id":2,
"showtime_id":1,
"identity_number":1234567,
"number_of_people":8
}
]
}