Skip to content

akabiru/idea_pool

Repository files navigation

Idea Pool REST API 💡

Idea Pool is a service that records your ideas! After signing up for an account, users can log their ideas and assign them scores. Every idea contains 3 scores: Impact, Ease and Confidence. Each idea can be added, edited and deleted. All the ideas will be sorted by the average of all three scores. Every API call will return 10 ideas. When not using the service, users can log out of the system.

Getting Started

Clone the repository:

$ git clone https://github.com/akabiru/idea_pool && cd $_

Install the dependencies

$ bundle install

Setup the database & Redis store:

$ bundle exec rails db:setup
$ brew services start redis # on MacOS

The above will get you a copy of the project up and running on your local machine for development and testing purposes.

Dependencies

  1. Ruby
  2. PostgreSQL
  3. Bundler
  4. Ruby on Rails
  5. RSpec

Tests

$ bundle exec rspec -fd

API Endpoints

$ http https://infinite-dusk-17447.herokuapp.com/ideas Authorization: "Bearer eyJ0eXAiOiJ..."
EndPoint Functionality
POST /users Signup a user
POST /access-tokens Login user
POST /access-tokens/Refresh Refresh token (Header X-Refresh-Token)
DELETE /access-tokens Logout user
POST /ideas Create a new bucket list
GET /ideas/ List all the created bucket lists
GET /ideas?page=1&limit=5 List five ideas from page 1
GET /ideas/:id Get single idea
PUT /ideas/:id Update this idea
DELETE /ideas/:id Delete this single idea

Auth API

POST /signup

$ echo '{"email": "jack-black@codementor.io","name": "Jack Black","password": "the-Secret-123"}' | http https://infinite-dusk-17447.herokuapp.com/users

POST /access-tokens (Login)

$ echo '{"email": "jack-black@codementor.io","password": "the-Secret-123"}' | http https://infinite-dusk-17447.herokuapp.com/access-tokens

POST /access-tokens/refresh

$ http POST https://infinite-dusk-17447.herokuapp.com/access-tokens/refresh X-Refresh-Token: 'ashdahskjdhak....'

DELETE /access-tokens (Logout)

$ http DELETE https://infinite-dusk-17447.herokuapp.com/access-tokens X-Refresh-Token: 'ashdahskjdhak....'

Ideas API

POST /ideas

$ echo '{"content": "the-content","impact": 8,"ease": 8,"confidence": 8}' | http POST https://infinite-dusk-17447.herokuapp.com/ideas Authorization: 'Bearer hajsdhkasd'

GET /ideas

$ http https://infinite-dusk-17447.herokuapp.com/ideas page==1 Authorization: 'Bearer hajsdhkasd'

GET /ideas/:id

$ http https://infinite-dusk-17447.herokuapp.com/ideas/1 Authorization: 'Bearer hajsdhkasd'

PUT /ideas/:id

$ echo '{"impact": 10}' | http PUT https://infinite-dusk-17447.herokuapp.com/ideas/1 Authorization: 'Bearer hajsdhkasd'

DELETE /ideas/:id

$ http DELETE https://infinite-dusk-17447.herokuapp.com/ideas/1 Authorization: 'Bearer hajsdhkasd'

Responses

The API responds with JSON data by default.

Error Handling

The API responds with an error message and http status code whenenever it encounters an error.

{
  "message": "Signature has expired"
}

Versions

TODO:

Request & Response examples

Request GET /ideas?page=2&limit=2

 $ http https://infinite-dusk-17447.herokuapp.com/ideas?page=2&limit=2 \
 Authorization: 'Bearer eyJ0eXAiOiJKV...'

Response (application/json)

[
  {
    "id": 1,
    "confidence": 8,
    "ease": 8,
    "impact": 8,
    "content": "Idea",
    "user_id": 2,
    "created_at": "2018-08-30T10:08:08.876Z",
    "updated_at": "2018-08-30T10:08:08.904Z",
    "average_score": 8.0
  },
  {
    "id": 2,
    "confidence": 8,
    "ease": 8,
    "impact": 8,
    "content": "Idea",
    "user_id": 2,
    "created_at": "2018-08-30T10:08:10.646Z",
    "updated_at": "2018-08-30T10:08:10.649Z",
    "average_score": 8.0
  },
]

Contributing

  1. Fork it! 🍴
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git add -A && git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature 🚀
  5. Submit a pull request 😎

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Releases

No releases published

Packages

No packages published