/e_store

This project is just a simple API for a small "E-Commerce".

Primary LanguageRuby

README

codebeat badge Maintainability Test Coverage Build Status

About this project

This project is just a simple API for a small "E-Commerce".

Is a Rails application to management Products, Orders, Items and Reports.

Technical Informations and dependencies

- The Ruby language - version 2.7.0
- The Rails gem     - version 6.0
- RSpec             - version 4.0.0.beta4
- Rubocop           - version 0.79.0
- PostgreSQL        - version 10
- Docker            - version 19.03.5-ce
- Docker Compose    - version 1.25.1

To use

Clone the project:

git clone git@github.com:marcelotoledo5000/e_store.git
cd e_store

With Docker (better option)

script/setup    # => development bootstrap, preparing containers
script/server   # => starts server
script/console  # => starts console
script/test     # => running tests

Running without Docker (not recommended!)

If you prefer, you'll need to update config/database.yml:

# host: db        # when using docker
host: localhost   # when using localhost

System dependencies:

And then:

gem install bundler         # => install the last Bundler version
bundle install              # => install the project's gems
rails db:setup db:migrate   # => prepare the database
rails s                     # => starts server
rails c                     # => starts console
bundle exec rspec           # => to running tests

To run app

To see the application in action, starts the rails server to able http://localhost:3000/

API Documentation

Authentication

  • No authentication, for now.

Domain

http://localhost:3000/

Endpoints

To Products

INDEX

GET: http://DOMAIN/products
"http://localhost:3000/products"

Response:

200 Ok

SHOW

GET: http://DOMAIN/products/ID
"http://localhost:3000/products/1"

Response:

200 Ok

CREATE

POST: http://DOMAIN/products
"http://localhost:3000/products"
Params: Body, JSON(application/json)
{
  "name": "KBS Beer",
  "description": "The best of the World!",
  "stock": 400,
  "price": 39.90,
  "custom_attributes": "Custom Aattributes"
}

Response:

201 Created

UPDATE

PUT: http://DOMAIN/products/ID
"http://localhost:3000/products/1"
Params: Body, JSON(application/json)
{
  "name": "KBS - 2016 Edition",
  "description": "The best of the World!",
  "stock": 400,
  "price": 49.90
}

Response:

201 Created

DESTROY

DELETE: http://DOMAIN/products/ID
"http://localhost:3000/products/2"

Response:

204 No Content
To Customers

INDEX

GET: http://DOMAIN/customers
"http://localhost:3000/customers"

Response:

200 Ok

SHOW

GET: http://DOMAIN/customers/ID
"http://localhost:3000/customers/1"

Response:

200 Ok

CREATE

POST: http://DOMAIN/customers
"http://localhost:3000/customers"
Params: Body, JSON(application/json)
{
  "name": "Vladimir Harkonnen",
  "cpf": "123.456.789-01",
  "email": "harkonnen@mail.com",
  "birthday": "10/01/1990"
}

Response:

201 Created

UPDATE

PUT: http://DOMAIN/customers/ID
"http://localhost:3000/customers/1"
Params: Body, JSON(application/json)
{
  "email": "mr.harkonnen@mail.com",
  "birthday": "10/01/1980"
}

Response:

201 Created
To Orders

INDEX

GET: http://DOMAIN/orders
"http://localhost:3000/orders"

Response:

200 Ok

CREATE

POST: http://DOMAIN/customers
"http://localhost:3000/customers"
Params: Body, JSON(application/json)
{
  "customer_id":1,
  "freight":22.5,
  "items":[
    {
      "product_id":5,
      "quantity":8
    },
    {
      "product_id":4,
      "quantity":5
    }
  ]
}

Response:

201 Created
To Reports

AVERAGE_TICKET

GET: http://DOMAIN/reports/average_ticket
"http://localhost:3000/reports/average_ticket"
Params: Body, JSON(application/json)
{
  "initial_date":"2019-04-18 19:55:15",
  "final_date":"2019-04-25 19:55:15"
}

Response:

200 Ok
PENDING
  • Update Orders
  • Put JSON API format response
  • Show Order with all details
  • Separate tests from services and controllers
  • Improvement in Average Ticket:
    • verify if period is valid before (initial_date < final_date)
    • verify if have orders into period
  • Add process to set new status to orders
  • Fix all issues from CodeClimate
  • To thinking about possible competition
  • Etc