README

Task description:

Please create 2 models with at least the following attributes:

  • Stock (name: string - must be unique)
  • Bearer (name: string - must be unique)(can own many stocks)

Please create some JSON API endpoints:

  1. Create a stock with a referenced bearer.
  2. Update a stock.
  3. The bearer cannot be updated via stock update endpoint. If you need to change the bearer, a new object needs to be created. If bearer exists already, it must be re-used and connected to the stock.
  4. List all stocks with bearer information.
  5. Soft-delete a stock so it doesn't appear on the API.

NOTE: Error responses should be detailed enough to see what exactly missied or wrong.

Requirements

  • Ruby 2.7.1

Things done

Create a stock with a referenced bearer.

POST api/v1/:bearer_id/stocks with { stock: { name: string } }

Update a stock.

PATCH api/v1/:id with { stock: { name: string, bearer_name: string } }

one of params is required

The bearer cannot be updated via stock update endpoint. If you need to change the bearer, a new object needs to be created. If bearer exists already, it must be re-used and connected to the stock.

covered within stock#update

List all stocks with bearer information.

GET api/v1/stocks

Soft-delete a stock so it doesn't appear on the API.

DELETE api/v1/stocks/:id