Skip to content

Latest commit

 

History

History
326 lines (248 loc) · 5.45 KB

restapi.md

File metadata and controls

326 lines (248 loc) · 5.45 KB

ClothingStorage - REST-api

Dette dokumentet forklarer hvordan server-siden av REST-api'et er satt opp.

Get Storage

Type: GET

URI: host:port/clothingStorage http://localhost:8080/clothingStorage

Response:

{
    "clothes" : [ {
        "type" : "Pants",
        "brand" : "Nike",
        "size" : "S",
        "price" : 10.0,
        "discount" : 0.0
    }, {
        "quantity" : 5
    }, {
        "type" : "Shorts",
        "brand" : "LouisVuitton",
        "size" : "M",
        "price" : 20.0,
        "discount" : 0.0
    }, {
        "quantity" : 8
    }, {
        "type" : "Socks",
        "brand" : "Adidas",
        "size" : "L",
        "price" : 30.0,
        "discount" : 0.0
    }, {
        "quantity" : 4
    }, {
        "isSorted" : false
    } ]
}

Get names of Clothings in Storage for price-page

Type: GET

URI: host:port/clothingStorage/priceNames http://localhost:8080/clothingStorage/priceNames

Response:

{
    [ 
        "PantsNikeS",
        "ShortsLouisVuittonM",
        "SocksAdidasL"
    ]
}

Get names of Clothings in Storage for storage-page

Type: GET

URI: host:port/clothingStorage/storageNames http://localhost:8080/clothingStorage/storageNames

Response:

{
    [ 
        "JacketAdidasL",
        "UnderwearLouisVuittonS",
        "ShirtSupremeL"
    ]
}

Get sorted names of Clothings in Storage

Type: GET

URI: host:port/clothingStorage/sortedNames http://localhost:8080/clothingStorage/sortedNames

Response:

{
    [ 
        "PantsAdidasL",
        "JacketLacosteS",
        "UnderwearNikeS"
    ]
}

Get sorted Clothings

Type: GET

URI: host:port/clothingStorage/sorted/{id} http://localhost:8080/clothingStorage/sorted/0

Parameter: id

  • 0 for lavest pris
  • 1 for høyest pris
  • 2 for klær på rabatt

Response:

{
    [
        "Pants; Nike; 10.0kr",
        "Shorts; LouisVuitton; 20.0kr",
        "Socks; Adidas; 30.0kr"
    ]
}

Get sorted Clothings by type

Type: GET

URI: host:port/clothingStorage/sortedType/{type} http://localhost:8080/clothingStorage/sortedType/Pants

Parameter: type

Response:

{
    [
        "Pants; Nike; 86.0kr",
        "Pants; Adidas; 99.0kr",
        "Pants; Levi's; 25.0kr"
    ]
}

Get sorted Clothings by brand

Type: GET

URI: host:port/clothingStorage/sortedBrand/{brand} http://localhost:8080/clothingStorage/sortedBrand/Nike

Parameter: brand

Response:

{
    [
        "Pants; Nike; 44.0kr",
        "Shorts; Nike; 98.0kr",
        "Jacket; Nike; 35.0kr"
    ]
}

Get the storage display

Type: GET

URI: host:port/clothingStorage/storageDisplay http://localhost:8080/clothingStorage/storageDisplay

Response:

{
    [
        "Jacket; Nike; M; 2",
        "Sweater; LouisVuitton; S; 9",
        "Shorts; Supreme; L; 4"
    ]
}

Get the price display

Type: GET

URI: host:port/clothingStorage/priceDisplay http://localhost:8080/clothingStorage/priceDisplay

Response:

{
    [
        "Pants; Adidas; 40.0kr",
        "Underwear; Lacoste; 86.0kr",
        "Jacket; Nike; 26.0kr"
    ]
}

Get Clothing

Type: GET

URI: host:port/clothingStorage/clothes/{name} http://localhost:8080/clothingStorage/clothes/PantsNikeM

Parameter: name

Response:

{
    "type" : "Pants",
    "brand" : "Nike",
    "size" : "M",
    "price" : 44.0,
    "discount" : 0.5
}

Add Clothing

Type: PUT

URI: host:port/clothingStorage/clothes/{name} http://localhost:8080/clothingStorage/clothes/JacketLacosteS

Parameter: name

Request:

{
    "type" : "Jacket",
    "brand" : "Lacoste",
    "size" : "S",
    "price" : 149.0,
    "discount" : 0.0
}

Response:

{
    true
}

Remove Clothing

Type: DELETE

URI: host:port/clothingStorage/clothes/{name} http://localhost:8080/clothingStorage/clothes/SocksNikeL

Parameter: name

Response:

{
    true
}

Get quantity of Clothing

Type: GET

URI: host:port/clothingStorage/quantity/{name} http://localhost:8080/clothingStorage/quantity/PantsNikeS

Response:

{
    5
}

Put quantity of Clothing

Type: PUT

URI: host:port/clothingStorage/quantity/{name} http://localhost:8080/clothingStorage/quantity/SweaterAdidasM

Parameter: name

Request:

{
    quantity=5
}

Response:

{
    true
}

Get list of quantities for each size of type

Type: GET

URI: host:port/clothingStorage/stats/chartData/{type} http://localhost:8080/clothingStorage/stats/chartData/Pants

Parameter: type

Response:

{
    [
        5,
        0,
        8
    ]
}

Get total quantity

Type: GET

URI: host:port/clothingStorage/stats/totalQuantity http://localhost:8080/clothingStorage/stats/totalQuantity

Response:

{
    17
}

Get total value

Type: GET

URI: host:port/clothingStorage/stats/totalValue http://localhost:8080/clothingStorage/stats/totalValue

Response:

{
    330.0
}