Skip to content

A ReST API exposing necessary data for an e-commerce application using a service-oriented architecture.

Notifications You must be signed in to change notification settings

mkrumholz/rails-engine

Repository files navigation

Rails Engine

About

A ReST API exposing merchant, item, and aggregated revenue data for an e-commerce application using a service-oriented architecture.

ReST API

Get all items/merchants

GET /items or GET /merchants

  • These endpoints take optional page and per_page parameters to specify number and format of items returned

  • Defaults to 20 items per page and first page if not specified

Get specified item/merchant

GET /items/:id or GET /merchants/:id

Create an item

POST /items

  • Accepts the following JSON body with only the following fields:
{
  "name": "value1",
  "description": "value2",
  "unit_price": 100.99,
  "merchant_id": 14
}

(Note that the unit price is to be sent as a numeric value, not a string.)

Update an item

PATCH /items

  • Accepts the following JSON body with one or more of the following fields:
{
  "name": "value1",
  "description": "value2",
  "unit_price": 100.99,
  "merchant_id": 7
}

(Note that the unit price is to be sent as a numeric value, not a string.)

Delete an item

DELETE /items

Get a complete list of a merchant's items

GET /merchants/:id/items

Get an item's merchant

GET /items/:id/merchant

Additional Endpoints

Find a single merchant by name

GET /merchants/find

  • Requires a find parameter with a string or string fragment to search

Search all items by name or price

GET /items/find_all

  • Requires EITHER a name parameter OR price parameters

  • Price parameters allowed include: min_price, max_price, or both

  • name parameter will search all item names AND descriptions for the string or string fragment

  • Prices must be formatted as numeric values, e.g.: 4.99 or 939.01

Total revenue for a provided date range

GET /revenue

  • Requires both start and end date parameters in YYYY-MM-DD format

List items by revenue generated (desc)

GET /revenue/items

  • Defaults to the top 10 items

  • Takes optional quantity parameter to specify number of items returned

Find total revenue for a given merchant

GET /revenue/merchants/:id

Report of total revenue generated by week

GET /revenue/weekly

Dependencies

Testing

Running the Tests

  1. Use $ bundle exec rspec to run the full test suite
  2. To see a coverage report enter $ open coverage/index.html

Versions

  • Ruby 2.7.2

  • Rails 2.5.3

About the Author

Molly Krumholz is a backend developer who loves to adventure on two feet or two wheels (only one board though 🏂). Things she finds satisfying include: thoroughly testing code, refactoring gnarly ActiveRecord queries, and making code run even just slightly faster.

About

A ReST API exposing necessary data for an e-commerce application using a service-oriented architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published