Giter VIP home page Giter VIP logo

rails_engine's Issues

Create Record (Item and Merchant)

Item

POST /api/v1/items

Merchant

POST /api/v1/merchants
Body should follow this pattern:

{
  "attribute1": "value1",
  "attribute2": "value2",
}

Example JSON response for above

{
  "data": {
    "id": "1",
    "type": "merchant",
    "attributes": {
      "name": "Store Name"
    }
  }
}

NOTES FOR ALL ENDPOINTS

  • All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
  • All endpoints will expect to return JSON data
  • All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
  • API will be compliant to the JSON API spec
  • Controller actions should be limited to only the standard Rails actions. For endpoints such as GET /api/v1/merchants/find?parameters, try something like this which adheres to the above approach of only using RESTful actions:
module Api
  module V1
    module Merchants
      class SearchController
        def show
        # code omitted
        end
      end
    end
  end
end

Multi Finders (Item and Merchant)

Instructions

This endpoint should return all records that match a set of criteria. Criteria will be input through query parameters.

Items

GET /api/v1/items/find_all?<attribute>=<value>

Merchants

GET /api/v1/merchants/find_all?<attribute>=<value>

NOTES FOR THIS THIS ENDPOINT

  • work for any attribute of the corresponding resource including the updated_at and created_at timestamps.
  • find partial matches for strings and be case insensitive, for example a request to GET /api/v1/merchants/find?name=ring would match a merchant with the name Turing and a merchant with the name Ring World.
  • Note: It does NOT need to accept multiple attributes, for example GET /api/v1/items/find?name=pen&description=blue

Example JSON response for
GET /api/v1/merchants/find_all?name=ring

{
  "data": [
    {
      "id": "4",
      "type": "merchant",
      "attributes": {
        "name": "Ring World"
      }
    },
    {
      "id": "1",
      "type": "merchant",
      "attributes": {
        "name": "Turing School"
      }
    }
  ]
}

Merchants with Most Revenue

Instructions

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.

Example JSON response for
GET /api/v1/merchants/most_revenue?quantity=2

{
  "data": [
    {
      "id": "1",
      "type": "merchant",
      "attributes": {
        "name": "Turing School"
      }
    },
    {
      "id": "4",
      "type": "merchant",
      "attributes": {
        "name": "Ring World"
      }
    }
  ]
}

Add rake task file

  • This needs to iterate through every file in your csv folder
  • It needs to iterate through every line in a csv file and filter it into the model database using Model.create(attribute: line[0], attribute2: line[1], attribute3: line[2], ETC)
  • Run using rake csv_import (I think?) - Can I test using pry?

Merchants with Most Items Sold

Instructions

This endpoint should return a variable number of merchants ranked by total number of items sold:
The URI should follow this pattern:
GET /api/v1/merchants/most_items?quantity=x
where x is the number of merchants to be returned.

Example JSON response for
GET /api/v1/merchants/most_items?quantity=2

{
  "data": [
    {
      "id": "1",
      "type": "merchant",
      "attributes": {
        "name": "Turing School"
      }
    },
    {
      "id": "4",
      "type": "merchant",
      "attributes": {
        "name": "Ring World"
      }
    }
  ]
}

Seed the database

Use your rake task to seed the database
Confirm using any resource (examples: rails s)

Single Finders (Item and Merchant)

Instructions

This endpoint should return a single record that matches a set of criteria. Criteria will be input through query parameters.

Items

GET /api/v1/items/find?<attribute>=<value>

Merchants

GET /api/v1/merchants/find?<attribute>=<value>

NOTES FOR THIS THIS ENDPOINT

  • work for any attribute of the corresponding resource including the updated_at and created_at timestamps.
  • find partial matches for strings and be case insensitive, for example a request to GET /api/v1/merchants/find?name=ring would match a merchant with the name Turing and a merchant with the name Ring World.
  • Note: It does NOT need to accept multiple attributes, for example GET /api/v1/items/find?name=pen&description=blue

Example JSON response for
GET /api/v1/merchants/find?name=ring

{
  "data": {
    "id": 4,
    "type": "merchant",
    "attributes": {
      "name": "Ring World"
    }
  }
}

Refactor/Polish of Engine

  1. Ensure encapsulation and abstraction
  2. Can you use polymorphism/Are you currently using it?
  3. Can you use inheritance/Are you currently using it?
  4. Do you have tests for all facade(s)?
  5. Do you have tests for model(s)?
  6. Do you have tests for poro(s)?
  7. Do you have tests for serializer(s)?
  8. Can you update your models for through associations, then update your factories, and finally refactor ActiveRecord calls to gain access using the throughs?

Destroy Record (Item and Merchant)

Instructions

This endpoint should destroy the corresponding record (and any associated data, eg if you delete a merchant you should delete their items too). Since this is a permanent destruction of data, we do not return any response body of any kind, and should send a 204 HTTP status code.

Extension

When you delete an item, you will delete entries in the invoice_items table per the work above. This, however, might leave invoices in the database with no items at all, so you should find a way to clean those up, too.

NOTES FOR ALL ENDPOINTS

  • All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
  • All endpoints will expect to return JSON data
  • All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
  • API will be compliant to the JSON API spec
  • Controller actions should be limited to only the standard Rails actions. For endpoints such as GET /api/v1/merchants/find?parameters, try something like this which adheres to the above approach of only using RESTful actions:
module Api
  module V1
    module Merchants
      class SearchController
        def show
        # code omitted
        end
      end
    end
  end
end

Item relationship

Return the merchant associated with aN ITEM
GET /api/v1/items/:id/merchant

Add Each Model (with Test) to Database

Models (with my estimated relationships)

  • Items
    • belongs to merchant
    • has many invoice_items
    • has many invoices, through invoice_items
  • Merchants
    • has many items
    • has many transactions
    • has many invoices
  • Customers
    • has many transactions
    • has many invoices
  • Transactions
    • belongs to customers
    • belongs to merchants
  • Invoices
    • belongs to customers
    • belongs to merchants
    • has many invoice_items
    • has many items, through invoice_items
  • Invoice_Items (Joins)
    • belongs to invoice
    • belongs to items

Revenue for a Merchant

Instructions

This endpoint should return the total revenue for a single merchant.
The URI should follow this pattern:
GET /api/v1/merchants/:id/revenue

Example JSON response for
GET /api/v1/merchants/1/revenue

{
  "data": {
    "id": null,
    "attributes": {
      "revenue"  : 43201227.8000003
    }
  }
}

Revenue across Date Range

Instructions

This endpoint should return the total revenue across all merchants between the given dates.
The URI should follow this pattern:
GET /api/v1/revenue?start=<start_date>&end=<end_date>

Example JSON response for
GET /api/v1/revenue?start=2012-03-09&end=2012-03-24

{
  "data": {
    "id": null,
    "attributes": {
      "revenue"  : 43201227.8000003
    }
  }
}

Index of Resource (Items and Merchant)

Item

GET /api/v1/items

Merchant

GET /api/v1/merchants
Example JSON response for above

{
  "data": [
    {
      "id": "1",
        "type": "merchant",
        "attributes": {
          "name": "Mike's Awesome Store",
        }
    },
    {
      "id": "2",
      "type": "merchant",
      "attributes": {
        "name": "Store of Fate",
      }
    },
    {
      "id": "3",
      "type": "merchant",
      "attributes": {
        "name": "This is the limit of my creativity",
      }
    }
  ]
}

NOTES FOR ALL ENDPOINTS

  • All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
  • All endpoints will expect to return JSON data
  • All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
  • API will be compliant to the JSON API spec
  • Controller actions should be limited to only the standard Rails actions. For endpoints such as GET /api/v1/merchants/find?parameters, try something like this which adheres to the above approach of only using RESTful actions:
module Api
  module V1
    module Merchants
      class SearchController
        def show
        # code omitted
        end
      end
    end
  end
end

Update Record (Item and Merchant)

Item

patch /api/v1/items/:id

Merchant

patch /api/v1/merchants/:id
Body should follow this pattern:

{
  "attribute1": "value1",
  "attribute2": "value2",
}

Example JSON response for above

{
  "data": {
    "id": "1",
    "type": "merchant",
    "attributes": {
      "name": "Store Name"
    }
  }
}

NOTES FOR ALL ENDPOINTS

  • All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
  • All endpoints will expect to return JSON data
  • All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
  • API will be compliant to the JSON API spec
  • Controller actions should be limited to only the standard Rails actions. For endpoints such as GET /api/v1/merchants/find?parameters, try something like this which adheres to the above approach of only using RESTful actions:
module Api
  module V1
    module Merchants
      class SearchController
        def show
        # code omitted
        end
      end
    end
  end
end

Show Record (Item and Merchant)

Item

GET /api/v1/items/:id

Merchant

GET /api/v1/merchants/:id
Example JSON response for above

{
  "data": {
    "id": "1",
    "type": "merchant",
    "attributes": {
      "name": "Store Name"
    }
  }
}

NOTES FOR ALL ENDPOINTS

  • All endpoints should be fully tested. The Rails Driver Spec Harness is not a substitute for writing your own tests.
  • All endpoints will expect to return JSON data
  • All endpoints should be exposed under an api and version (v1) namespace (e.g. /api/v1/merchants)
  • API will be compliant to the JSON API spec
  • Controller actions should be limited to only the standard Rails actions. For endpoints such as GET /api/v1/merchants/find?parameters, try something like this which adheres to the above approach of only using RESTful actions:
module Api
  module V1
    module Merchants
      class SearchController
        def show
        # code omitted
        end
      end
    end
  end
end

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.