SmartCart server API

Categories

GetProductCategories

Returns all available categories with Id larger than the input parameter.

Request type: POST

Parameters:
int Id

Returns:
JSON Array with JSON Objects

Example request

http://161.53.67.237/SmartCart/SmartCartService/GetProductCategories

Parameters:
{"Id":2}

Example response

[
    {
        "CategoryId": 3,
        "Name": "Snacks" 
    },    {
        "CategoryId": 4,
        "Name": "Baked goods" 
    }
]

InsertProductCategory

Inserts a product category

Request type: POST

Parameters:
string CategoryName

Returns:
Id of inserted ProductCategory if successful, -1 otherwise

Example request

 http://161.53.67.237/SmartCart/SmartCartService/InsertProductCategory

Parameters:
{"CategoryName":"Fruit"}

Example response

4

Products

GetProducts

Returns all available products with Id larger than the input parameter.

Request type: POST

Parameters:
int Id
string Latitude
string Longitude
decimal Distance

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetProducts

Parameters:
{"Id":10, "Latitude":"10.23123123", "Longitude":"32.4342432" "Distance":200}

Example response

[
    {
        "CategoryId": 1,
        "CategoryName": "Fruit",
        "Name": "Apple",
        "ProductId": 11
    }

    {
        "CategoryId": 5,
        "CategoryName": "Candy",
        "Name": "Kinder",
        "ProductId": 12
    }

]

InsertProduct

Inserts a product.

Request type: POST

Parameters:

Returns:
Id of inserted product if successful, -1 otherwise.

Example request

 "http://161.53.67.237/SmartCart/SmartCartService/InsertProduct

Parameters:
{"Name":"Pineapple","CategoryId":1,"Barcode":"31234324"}

Example response

44

Stores

GetStores

Returns all available stores with Id larger than the input parameter.

Request type: POST

Parameters:
int Id
string Latitude
string Longitude
decimal Distance

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetStores

Parameters

{"Id":1, "Latitude":"32.4234234", "Longitude":"11.321323", "Distance":1000}

Example response

[
{"StoreId":2, "Name":"Konzum Vela luka", "Address":"Gunduliceva 22", "Latitude":"32.321312312", "Longitude":"49.43234234", "City":{"CityId":5, "CityName":"Split", "Currency":"HRK"}}
]

InsertStore

Inserts a store

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/InsertStore

Parameters

{"Name":"Lidl Novi Zagreb", "Address":"Utrine 8", "Latitude":"32.321312312", "Longitude":"49.43234234"}

Example response

{"Id":3}

Prices

GetSpecificPrice

Gets a price for a specific product from a specific store

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetSpecificPrices

Parameters

{"StoreId":1, "ProductId":1}

Example response

{"StoreId":1, "StoreName":"Store1", "ProductId":1, "ProductName":"Product1", "Price":55.34, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}

GetStorePrices

Gets prices for all products in a store.

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetStorePrices

Parameters

{"StoreId":1}

Example response


[
{"StoreId":1, "StoreName":"Store1", "ProductId":1, "ProductName":"Product1", "Price":55.34, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}
{"StoreId":1, "StoreName":"Store1", "ProductId":2, "ProductName":"Product2", "Price":22, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}
{"StoreId":1, "StoreName":"Store1", "ProductId":3, "ProductName":"Product3", "Price":321.43, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}
{"StoreId":1, "StoreName":"Store1", "ProductId":4, "ProductName":"Product4", "Price":7, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}
]

GetProductPrices
Gets prices for a certain product in all available stores.

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetProductPrices

Parameters

{"ProductId":1, "Latitude":"34.423423534", "Longitude":"43.545345343", "Distance":55}

Example response

[
[
{"StoreId":1, "StoreName":"Store1", "ProductId":1, "ProductName":"Product1", "Price":55.34, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 26"}
{"StoreId":2, "StoreName":"Store2", "ProductId":1, "ProductName":"Product1", "Price":22, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 25"}
{"StoreId":3, "StoreName":"Store3", "ProductId":1, "ProductName":"Product1", "Price":321.43, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 24"}
{"StoreId":4, "StoreName":"Store4", "ProductId":1, "ProductName":"Product1", "Price":7, "Latitude":"34.5343", "Longitude":"23.34545", "Address":"Savska 23"}
]

InsertProductPrice

Inserts a product price. If price already exists will edit existing price.

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/InsertProductPrice

Parameters

{"ProductId":1, "StoreId":1, "Price":33, "PriceStart:"2011-11-11"}

Example response

{"Id":44}

Searching for stores

GetBestStores

Returns a list of "best" stores for a given shopping list of items.

Request type: POST

Parameters:

Returns:
JSON Array with JSON objects

Example request

 http://161.53.67.237/SmartCart/SmartCartService/GetBestStores

Parameters
{
    "ShoppingList": [
        {
            "ProductId": "1",
            "Quantity": "1",
            "ProductName": "Milk1LK-Plus" 
        },
        {
            "ProductId": "2",
            "Quantity": "1",
            "ProductName": "Coca-Cola2L" 
        },
        {
            "ProductId": "15",
            "Quantity": "1",
            "ProductName": "PringlesTomato400g" 
        }
    ],
    "Method": "cheapest",
    "Latitude": "59.618637",
    "Longitude": "16.540604",
    "NumberOfResults": 4,
    "Distance": 5000
}

Example response

[
    {
        "Currency": "SEK",
        "Distance": 1635,
        "Latitude": "59.6225529",
        "Longitude": " 16.5589215",
        "Products": [],
        "StoreAddress": "L+Ñngm+Ñrtensgatan 1",
        "StoreId": 10,
        "StoreName": "ICA Ettan",
        "TotalPrice": 0,
        "TotalProducts": 0
    },
    {
        "Currency": "SEK",
        "Distance": 3792,
        "Latitude": "59.6292868",
        "Longitude": "16.5822093",
        "Products": [],
        "StoreAddress": "Gunnilibogatan",
        "StoreId": 8,
        "StoreName": "Hemk+Âp Malmaberg",
        "TotalPrice": 0,
        "TotalProducts": 0
    },
    {
        "Currency": "SEK",
        "Distance": 1582,
        "Latitude": "59.6085771",
        "Longitude": "16.5399615",
        "Products": [],
        "StoreAddress": "Stora Gatan 58",
        "StoreId": 6,
        "StoreName": "Hemk+Âp",
        "TotalPrice": 0,
        "TotalProducts": 0
    },
    {
        "Currency": "SEK",
        "Distance": 3205,
        "Latitude": "59.6372868",
        "Longitude": " 16.5475017",
        "Products": [
            {
                "Name": "PringlesTomato400g",
                "Price": 22.4,
                "ProductId": 15,
                "Quantity": 1
            }
        ],
        "StoreAddress": "Grytav+ñgen 2",
        "StoreId": 11,
        "StoreName": "Lidl V+ñster+Ñs",
        "TotalPrice": 22.4,
        "TotalProducts": 1
    }
]