Coder Social home page Coder Social logo

order-management-api's Introduction

Installation Steps for Ubuntu

sudo apt install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.6.3
rvm use 2.6.3 --default
ruby -v
gem install bundler
gem install rails -v 6.0.2.1
bundle install
rake db:migrate
rails s

Finally, you can start testing.

Endpoints and request types

1. Get inventories

GET ```localhost:3000/inventories```

2. Get single inventory

GET ```localhost:3000/inventories/1```

3. Create inventory

POST ```localhost:3000/inventories```
Payload
{
	"name" : "test 1",
	"description" : "test desc 1",
	"price" : 10.52,
	"quantity": 10
}

4. Update inventory

Payload

PUT/PATCH localhost:3000/inventories/1

{
	"name" : "test 1",
	"description" : "test desc 1",
	"price" : 10.52,
	"quantity": 10
}

5. Delete inventory

DELETE localhost:3000/inventories/1

6. Get orders

GET localhost:3000/orders

7. Get single order

GET localhost:3000/orders/1

8. Create order

POST localhost:3000/orders

Payload
{
	"orders" : {
		"email": "testtest.com",
		"order_items": [
    		{
    			"inventory_id" : 4,
    			"quantity" : 1
    		},
    		{
    			"inventory_id" : 5,
    			"quantity" : 1
	    	}
		]
	}
}

9. Update order

PUT/PATCH localhost:3000/orders/1

Payload
{
	"orders" : {
		"email": "[email protected]",
		"order_items": [
    		{
    			"inventory_id" : 2,
    			"quantity" : 2
    		}
    	]
	}
}

10. Delete order

DELETE localhost:3000/orders/1

Running Test

rspec spec/requests/create_inventory_spec.rb
rspec spec/requests/create_order_spec.rb
rspec spec/requests/delete_inventory_spec.rb
rspec spec/requests/delete_order_spec.rb
rspec spec/requests/get_inventories_spec.rb
rspec spec/requests/get_orders_spec.rb
rspec spec/requests/update_inventory_spec.rb
rspec spec/requests/update_order_spec.rb

order-management-api's People

Contributors

chashmeetsingh avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

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.