Coder Social home page Coder Social logo

rails-engine's People

Contributors

gvieve avatar

Watchers

 avatar

rails-engine's Issues

Merchants Requests - All

  • get all merchants
  • a maximum of 20 at a time when no per_page limit is provided
  • page, an integer value of a “page” of resources to skip before returning data; defaults to 1 if not specified by the user

Setup

Create the DB and migrations
Add models, tests, and associations
Add gems and create factories

Non-RESTful: Total Revenue for a Single Merchant

This endpoint should return the total revenue for a single merchant.

  • The URI should follow this pattern: GET /api/v1/revenue/merchants/:id
  • Revenue is defined as invoice status = shipped, transaction = success, sum(invoice_item quantity * unit price)

example json

{
  "data": {
    "id": "42",
    "type": "merchant_revenue",
    "attributes": {
      "revenue"  : 532613.9800000001
    }
  }
}

Items - All

  • get all items
  • a maximum of 20 at a time when no per_page limit is provided
  • page, an integer value of a “page” of resources to skip before returning data; defaults to 1 if not specified by the user

Non-RESTful BI - Items Ranked by Revenue

The endpoint will return a quantity of items ranked by descending revenue.

  • The URI should follow this pattern: GET /api/v1/revenue/items?quantity=x
  • where ‘x’ is the maximum count of results to return.
  • quantity should default to 10 if not provided
  • endpoint should return an error if it is not an integer greater than 0

example json

{
  "data": [
    {
      "id": 4,
      "type": "item_revenue",
      "attributes": {
        "name": "Men's Titanium Ring",
        "description": "Fine titanium ring",
        "unit_price": 299.99,
        "merchant_id": 54,
        "revenue": 19823.12985
      }
    }
  ]
}

Non-RESTful - Merchants with Most Revenue

This endpoint should return a variable number of merchants ranked by total revenue.

  • The URI should follow this pattern: GET /api/v1/merchants/most_revenue?quantity=x
  • where x is the number of merchants to be returned. The quantity parameter is required, and should return an error if it is missing or if it is not an integer greater than 0.

example JSON

{
  "data": [
    {
      "id": "1",
      "type": "merchant_name_revenue",
      "attributes": {
        "name": "Turing School",
        "revenue": 512.256128
      }
    },
    {
      "id": "4",
      "type": "merchant_name_revenue",
      "attributes": {
        "name": "Ring World",
        "revenue": 245.130001
      }
    }
  ]
}

Merchants Items - All

  • get all items for a given merchant ID
  • GET /api/v1/merchants/:id/items - return all items associated with a merchant.
  • return a 404 if merchant is not found

Non-RESTful BI - Potential Revenue of Unshipped Orders

Build a endpoint of the orders which have not yet shipped

  • The URI should follow this pattern: GET /api/v1/revenue/unshipped?quantity=x
  • ‘x’ is the maximum count of results to return.
  • quantity should default to 10 if not provided
  • should return an error if it is not an integer greater than 0.
  • order by 'potential revenue'

Example JSON response for GET /api/v1/revenue/unshipped?quantity=2

{
  "data": [
    {
      "id": 834,
      "type": "unshipped_order",
      "attributes": {
        "potential_revenue": 5923.78
      }
    },
    {
      "id": 28,
      "type": "unshipped_order",
      "attributes": {
        "potential_revenue": 3298.63
      }
    }
  ]
}

Destroy an Item

  • destroy the corresponding record (if found) and any associated data
  • destroy any invoice if this was the only item on an invoice
  • NOT return any JSON body at all, and should return a 204 HTTP status code
  • NOT utilize a Serializer (Rails will handle sending a 204 on its own if you just .destroy the object)

Merchant Find All and Find One Item

  • find one ITEM based on search criteria AND find all MERCHANTS based on search criteria
  • find a single item which matches a search term
    - return a single object, if found
    - return the first object in the database in case-sensitive alphabetical order if multiple matches are found
    - allow the user to specify a ‘name’ query parameter
    - search data in the name query parameter should require the database to do a case-insensitive search for text fields
    - allow the user to send one or more price-related query parameters, applicable to items only
    - for items, the user will send EITHER the name parameter OR either/both of the price parameters
    - users should get an error if name and either/both of the price parameters are sent
  • find all merchants which match a search term
    - The JSON response will always be an array of objects, even if zero matches or only one match is found
    - It should not return a 404 if no matches are found
    - follow the same rules as the “find_one” endpoints

Create an Item

  • create a record and render a JSON representation of the new Item record.
  • follow this pattern: POST /api/v1/items
  • accept 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.)
  • return an error if any attribute is missing
  • ignore any attributes sent by the user which are not allowed

Update an Item

  • update the corresponding Item (if found) with whichever details are provided by the user
  • render a JSON representation of the updated record.
  • follow this pattern: PATCH /api/v1/items/:id
  • accept the following JSON body with one or more of the following fields: The body should follow this pattern:
{
  "name": "value1",
  "description": "value2",
  "unit_price": 100.99,
  "merchant_id": 7
}
  • response
{
  "data": {
    "id": "1",
    "type": "item",
    "attributes": {
      "name": "New Widget Name",
      "description": "High quality widget, now with more widgety-ness",
      "unit_price": 299.99,
      "merchant_id": 7
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.