TODO is a system intended for management of ongoing and completed tasks. It includes a database of users, all of whom can access their own TODOs; they can create, view, edit and delete their tasks.
- Ruby 2.4.1
- Postgresql (database system)
- Bundler
- Git
-
Clone the repository "TODOs" into your computer.
git clone https://github.com/wanglzuz/TODOs.git -
Install the dependencies - run
bundle install -
Set up the database:
Choose your psql user. The permission to create a new database is necessary. Then add this database user and password into your environment variables as 'POSTGRES_USERNAME' and 'POSTGRES_PASSWORD' (see file "/config/database.yml").
Run the following commands to create the database and to fill it with some test data:rake db:createrake db:migraterake db:seedThis data is accessible in the file "/db/seeds.rb" and it is only possible to add users into the user database here (for their parameters, see example users). When you make changes to this file, you can update the database with this command:
rake db:resetThis will erase all the current database data and replace it with everything included in the said file.
-
Running the service
The service can be run and tested locally. Start up the server like this:bundle exec rails serverThen send your requests to their respective routes at
http://localhost:3000.
A functional version of this service can also be accessed athttps://wanglzuz-todo.herokuapp.com/.
-
Authorization
The user is required to provide their authorization for every request. That way, the user's identity is confirmed. To do this, add "access_token" and its value to the request header. If a false or no access token is provided, the service will refuse to cooperate. -
Viewing existing tasks
It is possible to view all user's tasks. To do that, use the following endpoint:
GET "/todos"
It is possible to view only the ongoing or finished tasks. To do that, add "status" into the URL as a param with the value "ongoing" or "done", respectively. Example:
"/todos?status=done" -
Viewing a single task
To view a single task, you must know its ID (for that purpose, view the list of all tasks, as described above). Then send the following request:
GET "/todos/id"
where "id" is the ID of your desired task. -
Adding a new task
You are required and permitted to include only the parameter "text" in the request body. Send this request:
POST "/todos"
Example of the text parameter in the request body:
{"text": "Example text."} -
Editing task description
Send a JSON in the request body with the updated text (see 4.) to:
PUT "/todos/id"
where "id" is the ID of the task you mean to edit. -
Marking task as "done"
Use the following endpoint:
PUT "/todos/id/done"
where "id" is replaced by the task ID. The status 'done' will be subsequently assigned to the indicated task. -
Deleting a task
To delete a task, look up its ID and then send this request:
DELETE "/todos/id"
Watch out, the change, once the request is sent, is irreversible!