This API allows the user to query endpoints to retrieve information related to Merchants, Items, and Sales.
-
Ruby 2.5.3
-
Rails 5.2.4.3
Table of Contents
Endpoints and example queries are listed below.
Merchants: Example JSON response for the Merchant resource:
{
"data": [
{
"id": "1",
"type": "merchant",
"attributes": {
"name": "Mike's Awesome Store",
}
},
{
- get all merchants, allows for pagination
GET /api/v1/merchants?per_page=50&page=2
- get one merchant
GET /api/v1/merchant/:id
- get all items for a given merchant ID
GET /api/v1/merchants/:id/items
Items: Example of JSON response for Item resource.
{
"data": {
"id": "1",
"type": "item",
"attributes": {
"name": "Super Widget",
"description": "A most excellent widget of the finest crafting",
"unit_price": 109.99
}
}
}
- get all items, allows for pagination
GET /api/v1/items?per_page=50&page=2
- get one item
GET /api/v1/item/:id
- create an item
POST /api/v1/items
- edit an item
PUT /api/v1/items/:id
- delete an item
POST /api/v1/items
- get the merchant data for a given item ID
GET /api/v1/items/:id/merchant
NonCrud Endpoints
- Find merchant based on partial search
GET /api/v1/merchants/find
- Find all Items based on partial search
GET /api/v1/items/find_all
Example of JSON response for revenue
{
"data": {
"id": "42",
"type": "merchant_revenue",
"attributes": {
"revenue" : 532613.9800000001
}
}
}
- Find top merchants by revenue
GET /api/v1/revenue/merchants
- Find total revenue for a given merchant
GET /api/v1/revenue/merchants/:id
Example of JSON response for potential revenue
{
"data": [
{
"id": 834,
"type": "unshipped_order",
"attributes": {
"potential_revenue": 5923.78
}
},
{
"id": 28,
"type": "unshipped_order",
"attributes": {
"potential_revenue": 3298.63
}
}
]
}
- find potential(unshipped) revenue by largest invoice
GET /api/v1/revenue/unshipped
- find merhants with largest potential(unshipped) revenue
GET /api/v1/revenue/merchant_unshipped
See the open issues for a list of proposed features (and known issues).
-
Fork and Clone the repo
git clone [https://github.com/AlexanderOsborne/rails-engine]
-
Install gems -- For list of Gems see here
bundle install
-
Setup the database:
The database is set up with a .pgdump. When running the setup you may see lots of output that can be ignored.
Run rake db:{drop,create,migrate,seed}
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Project Link: https://github.com/AlexanderOsborne/rails-engine