Skip to content

Rails API which uses advanced ActiveRecord queries and Fast_JSONAPI to expose Restful and non Restful endpoints from an e-commerce database.

Notifications You must be signed in to change notification settings

AlexanderOsborne/rails-engine

Repository files navigation

README

Rails Engine

About this App

This API allows the user to query endpoints to retrieve information related to Merchants, Items, and Sales.

Versions

  • Ruby 2.5.3

  • Rails 5.2.4.3

Contributors Forks Stargazers Issues

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. License
  5. Contact
  6. Acknowledgements

About The Application

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

Built With

See the open issues for a list of proposed features (and known issues).

Getting Started

Installation

  1. Fork and Clone the repo

    git clone [https://github.com/AlexanderOsborne/rails-engine]
    
  2. Install gems -- For list of Gems see here

    bundle install
    
  3. 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} 
    

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/AlexanderOsborne/rails-engine

Acknowledgements

About

Rails API which uses advanced ActiveRecord queries and Fast_JSONAPI to expose Restful and non Restful endpoints from an e-commerce database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published