Freid001 / restaurant-api

Simple api which allows customers to split their bill.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Restaurant api

About

Simple api which allows customers to split their bill, see SLO

Requirements

Installation

// build and run the app
./gradlew build run

// stop the app
./gradlew stop

// migrate database
./gradlew flywayMigrate -i 

// run unit tests
./gradlew unitTest

// run component tests
./gradlew componentTest

Usage

Endpoint
http://localhost:8000
POST /customer
body
{
    "firstName": "john",
    "lastName": "smith"
}

``

response
{
    "meta": {
        "status": "created"
    },
    "data": {
        "id": 1,
        "firstName": "john",
        "lastName": "smith"
    } 
}
GET /customers?firstName={first_name}&lastName={last_name}
response
{
    "meta": {
        "status": "ok"
    },
    "data": [
        {
            "id": 1,
            "firstName": "john",
            "lastName": "smith"
        },
        {
            "id": 2,
            "firstName": "david",
            "lastName": "jones"
        }
    ]
}
POST /restaurant
body
{
    "restaurant": "dominos",
    "cuisine": "pizza",
    "menu": [
        {
            "item": "margherita pizza",
            "price": 5.99,
            "available": true
        },
        {
            "item": "pepperoni pizza",
            "price": 9.99,
            "available": false
        }
    ]
}
response
{
    "meta": {
        "status": "created"
    },
    "data": {
        "restaurant": "dominos",
        "cuisine": "pizza",
        "menu": [
            {
                "item": "margherita pizza",
                "price": 5.99,
                "available": true
            },
            {
                "item": "pepperoni pizza",
                "price": 9.99,
                "available": false
            }
        ]
    }
}
GET /restaurants?restaurant={restaurant}&item={item}&&available={last_name}
response
{
    "meta": {
        "status": "ok"
    },
    "data": [
        {
            "restaurant": "dominos",
            "cuisine": "pizza",
            "menu": [
                {
                    "item": "margherita pizza",
                    "price": 5.99,
                    "available": true
                },
                {
                    "item": "pepperoni pizza",
                    "price": 9.99,
                    "available": false
                }
            ]
        }
    ]
}
POST /order
body
{
    "customerId": 1,
    "itemId": 1,
    "discount": 0.0
}
response
{
    "meta": {
        "status": "created"
    },
    "data": {
        "id": 1,
        "customer": "john smith",
        "items": [
          {
            "id": 1,
            "item": {
                "id": 1,
                "name": "margherita pizza",
                "originalPrice": 5.99
            },
            "priceCharged": 5.99,
            "discount": 0.0
          }
        ]
    }
}
GET /orders
response
{
    "meta": {
        "status": "ok"
    },
    "data": [
        {
            "id": 1,
            "customer": "john smith",
            "items": [
                {
                    "id": 1,
                    "item": {
                        "id": 1,
                        "name": "margherita pizza",
                        "originalPrice": 5.99
                    },
                    "priceCharged": 5.99,
                    "discount": 0.0
                }
            ]
        }
    ]
}
POST /order/item
body
{
    "customerId": 1,
    "itemId": 1,
    "discount": 0.5
}
response
{
    "meta": {
        "status": "created"
    },
    "data": {
        "id": 1,
        "customer": "john smith",
        "items": [
            {
                "id": 1,
                "item": {
                    "id": 1,
                    "name": "margherita pizza",
                    "originalPrice": 5.99
                },
                "priceCharged": 5.99,
                "discount": 0.0
            },
            {
                "id": 2,
                "item": {
                    "id": 1,
                    "name": "margherita pizza",
                    "originalPrice": 5.99
                },
                "priceCharged": 2.99,
                "discount": 0.5
            }
        ]
    }
}
DELETE /order/item?orderId={orderId}&itemId={itemId}
response
{
    "meta": {
        "status": "created"
    },
    "data": {
      "info": "Item #1 removed from order #1."
    }
}
DELETE /order?orderId={orderId}
response
{
    "meta": {
        "status": "created"
    },
    "data": {
      "info": "Order #1 deleted."
    }
}
POST /bill/pay
body
{
    "customerId": 1,
    "orderId": 1,
    "orderedId": 1,
    "pay": 5.99
}
response
{
    "meta": {
        "status": "created"
    },
    "data": [
        {
            "id": 1,
            "customer": "john smith",
            "ordered": [
                {
                    "id": 1,
                    "item": {
                        "id": 1,
                        "name": "margherita pizza",
                        "originalPrice": 5.99
                    },
                    "priceCharged": 5.99,
                    "discount": 0.0
                }
            ],
            "transactions": [
                {
                    "id": 1,
                    "payee": "john smith",
                    "ordered": [
                        {
                          "id": 1,
                          "name": "margherita pizza"
                        }
                    ],
                    "paid": 5.99,
                    "tip": 0.0
                }
            ],
            "totalOriginalPrice": 5.99,
            "totalDiscount": 0,
            "totalSavings": 0,
            "totalCharged": 5.99,
            "totalDue": 0,
            "totalTip": 0,
            "totalPaid": 5.99
        }
    ]
}
POST /bill/tip
body
{
    "customerId": 1,
    "orderId": 1,
    "orderedId": 1,
    "pay": 0.99
}
response
{
    "meta": {
        "status": "created"
    },
    "data": [
        {
            "id": 1,
            "customer": "john smith",
            "ordered": [
                {
                    "id": 1,
                    "item": {
                        "id": 1,
                        "name": "margherita pizza",
                        "originalPrice": 5.99
                    },
                    "priceCharged": 5.99,
                    "discount": 0.0
                }
            ],
            "transactions": [
                {
                    "id": 1,
                    "payee": "john smith",
                    "ordered": [
                        {
                          "id": 1,
                          "name": "margherita pizza"
                        }
                    ],
                    "paid": 5.99,
                    "tip": 0.0
                },
                {
                    "id": 2,
                    "payee": "john smith",
                    "ordered": [
                        {
                          "id": 1,
                          "name": "margherita pizza"
                        }
                    ],
                    "paid": 0.0,
                    "tip": 0.99
                }
            ],
            "totalOriginalPrice": 5.99,
            "totalDiscount": 0,
            "totalSavings": 0,
            "totalCharged": 5.99,
            "totalDue": 0,
            "totalTip": 0.99,
            "totalPaid": 6.98
        }
    ]
}
GET /bills?orderId={orderId}&customerId={customerId}&payeeId={payeeId}
response
{
    "meta": {
        "status": "ok"
    },
    "data": [
        {
            "id": 1,
            "customer": "john smith",
            "ordered": [
                {
                    "id": 1,
                    "item": {
                        "id": 1,
                        "name": "margherita pizza",
                        "originalPrice": 5.99
                    },
                    "priceCharged": 5.99,
                    "discount": 0.0
                }
            ],
            "transactions": [
                {
                    "id": 1,
                    "payee": "john smith",
                    "ordered": [
                        {
                          "id": 1,
                          "name": "margherita pizza"
                        }
                    ],
                    "paid": 5.99,
                    "tip": 0.0
                },
                {
                    "id": 2,
                    "payee": "john smith",
                    "ordered": [
                        {
                          "id": 1,
                          "name": "margherita pizza"
                        }
                    ],
                    "paid": 0.0,
                    "tip": 0.99
                }
            ],
            "totalOriginalPrice": 5.99,
            "totalDiscount": 0,
            "totalSavings": 0,
            "totalCharged": 5.99,
            "totalDue": 0,
            "totalTip": 0.99,
            "totalPaid": 6.98
        }
    ]
}

About

Simple api which allows customers to split their bill.


Languages

Language:PHP 79.7%Language:Gherkin 17.7%Language:TSQL 1.5%Language:Dockerfile 1.0%Language:Shell 0.1%