🛤 Sample API with Ruby on Rails, following Katapi contract.
Runnable - You can find a live example here: https://octo-woapi-rails.herokuapp.com/api/v1/products
Install rvm
Use the relevant Ruby version
$ rvm use ruby-2.5.7
Install bundler
$ gem install bundler
Install other dependencies
$ bundle
Copy database file and fill it with your database settings
$ cp config/database.yml.example config/database.yml
Create and migrate database
$ rake db:create
$ rake db:migrate
$ rake db:seed
Run the tests
$ rake
Start the project
$ rails s # default port is 3000
You can only GET /products for now, provided you have some in the database. :)
[
{
"id": 1,
"name": "Nintendo Switch",
"price": 300,
"weight": 3,
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}
]
{
"id": 1,
"name": "Nintendo Switch",
"price": 300,
"weight": 3,
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}
{
"name": "Nintendo Switch",
"price": 300,
"weight": 3
}
{
"name": "Nintendo Switch",
"price": 300,
"weight": 3
}
[
{
"id": 1,
"shipment_amount": 10,
"total_amount": 300,
"weight": 28,
"status": "pending",
"products": [
{
"id": 2,
"quantity": 3
}
],
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}
]
{
"id": 1,
"shipment_amount": 10,
"total_amount": 300,
"weight": 28,
"status": "pending",
"products": [
{
"id": 2,
"quantity": 3
}
],
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}
{
"products": [
{
"id": 3,
"quantity": 1
}
]
}
{
"status": "paid",
"products": [
{
"id": 3,
"quantity": 1
}
]
}
[
{
"id": 1,
"amount": 250,
"order_id": 3,
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}
]
{
"id": 1,
"amount": 250,
"order_id": 3,
"createdAt": "2018-04-06T13:21:32.611Z",
"updatedAt": "2018-04-06T13:21:32.611Z"
}