Giter Club home page Giter Club logo

innowise-cart-api's Introduction

Cart API

Overview

This repository contains a Go programming exercise for interview candidates. You'll be developing an API for an online shopping cart in the Go programming language.

Requirements

This is a REST API for basic CRUD operations for an online shopping cart. Data should be persisted in a storage layer which can use Postgres.

You should use default net/http package for REST implementation; sqlx or sqlc for interact with postgres; all the queries should be wrote mannually (no ORM, no Select methods and etc.); your repo should be private.

Additional requirements

Cover your code with the unit tests (you could use testify).

Create a Dockerfile for your application.

Domain Types

The Cart API consists of two simple types: Cart and CartItem. The Cart holds zero or more CartItem objects.

CartItem objects should be created in DB exactly (not from application).

Create Cart

A new cart should be created and an ID generated. The new empty cart should be returned.

POST http://localhost:3000/carts -d '{}'
{
	"id": 1,
	"items": []
}

Add to cart

A new item should added to an existing cart. Should fail if the cart does not exist, if the product name is blank, or if the quantity is non-positive. The new item should be returned.

POST http://localhost:3000/carts/1/items -d '{
	"product": "Shoes",
	"quantity": 10
}'
{
	"id": 1,
	"cart_id": 1,
	"product": "Shoes",
	"quantity": 10
}

Remove from cart

An existing item should be removed from a cart. Should fail if the cart does not exist or if the item does not exist.

DELETE http://localhost:3000/carts/1/items/1
{}

View cart

An existing cart should be able to be viewed with its items. Should fail if the cart does not exist.

GET http://localhost:3000/carts/1
{
	"id": 1,
	"items": [
		{
			"id": 1,
			"cart_id": 1,
			"product": "Shoes",
			"quantity": 10
		},
		{
			"id": 2,
			"cart_id": 1,
			"product": "Socks",
			"quantity": 5
		}
	]
}

innowise-cart-api's People

Contributors

fedo3nik 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.