Rails calendar application
Setup a local development enviroment through the following instructions:
- Please make sure to install Ruby 2.7.2+
- Install
bundler
andrails
through the following command:gem install rails bundler
- Install project dependencies:
bundle install
- Provide a PostgreSQL server for local development (PostgreSQL 13.x)
- Test your local environment through the following command:
bin/rails db:setup && bin/rails test
- The server can be started through the following command:
bin/rails server
This project can be deployed through a Docker container. To test it locally, follow these instructions:
- Please make sure to install Docker and docker-compose
- Build the image and provide the essential services through docker-compose:
docker-compose up --build
- Please make sure to provide a
CALENDAR_DATABASE_URL
while deploying the containerized solution (checkdocker-compose.yml
as a reference)
This application provides a REST API for Calendar management. It exposes the following endpoints:
POST /events
Request body (application/json
) for annually recurring events
{
"event": {
"name": "Christmas",
"day": 25,
"month": 12
}
}
Request body (application/json
) for single events
{
"event": {
"name": "Meeting",
"day": 10,
"month": 4,
"year": 2022
}
}
Example:
$ curl -X POST -H "Content-Type: application/json" \
-d '{"event": { "name": "Christmas", "day": 25, "month": 12 } }' \
http://localhost:3000/events
{"id":1}
$ curl -X POST -H "Content-Type: application/json" \
-d '{"event": { "name": "Meeting", "day": 10, "month": 4, "year": 2022 } }' \
http://localhost:3000/events
{"id":1}
GET /events
Query parameters:
day
(required): event daymonth
(required): event monthyear
(required): event year
Response body format (application/json
):
{
"total_events": 1,
"events": [
{
"name": "Meeting"
}
]
}
Example, given the entries above:
$ curl http://localhost:3000/events\?day\[\]=10\&month\[\]=4\&year\[\]=2022
{"total_records":1,"event":[{"name":"Meeting"}]}
- It is possible to create the same event for the same day
- The calendar is not handling timezones, since we're not working with time ranges
MIT License © Ewerton Carlos Assis