REST API Shopping cart

Logic Shopcart for any platform.

Faster

You will use very fastest technologies. This is docker image to run the nginx.

Fool-proof

Image size: 8 MB.

Low-priced

Amazing software for the low price of FREE!

How to use

$ docker pull imega/cart
$ docker run -d --env REDIS_IP={YOUR_REDIS} --env REDIS_PORT=6379 -p 80:8085 imega/cart

You can also read the article with examples.

Example Shop

{|product.title|}
{|product.title|}
UUID Your ShopCart
Not yet!
{|item.title|}
$ {|item.price|}

Get shopcart contents

Get the details from the basket is easy.

Code status:

200: Ok
404: basket is not exist.

JS

$http.get('http://shopcart.imega.ru/cart/' + this.currentUuid).then(
    function (res) {
        console(res.data);
    }
);

CURL

curl http://shopcart.imega.ru/cart/{cartUUID}

Get shopcart item

As well as the previous example, further specify the ID of product.

Code status:

200: Ok
404: product is not exist.

JS

$http.get('http://shopcart.imega.ru/cart/' + this.currentUuid + '/' + productUuid).then(
    function (res) {
        console(res.data);
    }
);

CURL

curl http://shopcart.imega.ru/cart/{cartUUID}/{productUUID}

Add shopcart item

After creating a product you get HTTP 201 response code and a link to create a product (Header: Location)

Code status:

201: Added product
409: Conflict, product is exist.

JS

$http.put('http://shopcart.imega.ru/cart', {
    price: product.price,
    title: product.title,
    preview: product.url,
    quantity: 1,
    url: product.url,
    cart_uuid: this.currentUuid,
    product_id: product.product_id
}).then(
    function (res) {
        console.log(res);
    }
);

CURL

curl -X PUT -d '"{
    "cart_uuid": "a727cbf0-d165-4703-bf57-3a8af0b83cbd",
    "product_id": "6126f97c-29fe-4be4-94df-4e3677d7b129",
    "title": "iPhone 6S 16Gb",
    "price": 749,
    "preview": "http://example.com/url_to_image_preview.png",
    "quantity": 1,
    "url": "http://example.com/url_to_page_detail_product"
}"' http://shopcart.imega.ru/cart/

Update shopcart item

Code status:

200: Ok
404: product is not exist.

JS

$http.post(
    'http://shopcart.imega.ru/cart/',
    {
        price: product.price,
        title: product.title,
        preview: product.url,
        quantity: Number(product.quantity),
        url: product.url,
        cart_uuid: this.currentUuid,
        product_id: product.product_id
    }
);

CURL

curl -X POST -d '"{
    "cart_uuid": "a727cbf0-d165-4703-bf57-3a8af0b83cbd",
    "product_id": "6126f97c-29fe-4be4-94df-4e3677d7b129",
    "title": "iPhone 6S 16Gb",
    "price": 749,
    "preview": "http://example.com/url_to_image_preview.png",
    "quantity": 1,
    "url": "http://example.com/url_to_page_detail_product"
}"' http://shopcart.imega.ru/cart/

Remove shopcart item

Code status:

200: Ok
404: product is not exist.

JS

$http.delete('http://shopcart.imega.ru/cart/' + this.currentUuid + '/' + product.product_id);

CURL

curl -X DELETE http://shopcart.imega.ru/cart/{cartUUID}/{productUUID}

Data format JSON

{
    "cart_uuid": "a727cbf0-d165-4703-bf57-3a8af0b83cbd",
    "product_id": "6126f97c-29fe-4be4-94df-4e3677d7b129",
    "title": "iPhone 6S 16Gb",
    "price": 749,
    "preview": "http://example.com/url_to_image_preview.png",
    "quantity": 1,
    "url": "http://example.com/url_to_page_detail_product"
}