Package org.bookstore.order.service
Interface OrderService
public interface OrderService
The interface OrderService defines a service to manage the orders of a bookstore.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelOrder
(long id) Tries to cancel an order.findOrder
(long id) Finds an order by identifier.placeOrder
(long customerId, List<OrderItem> items) Places an order with the bookstore.searchOrders
(long customerId, int year) Searches for orders by customer and year.
-
Method Details
-
placeOrder
Order placeOrder(long customerId, List<OrderItem> items) throws CustomerNotFoundException, PaymentFailedException Places an order with the bookstore.- Parameters:
customerId
- the identifier of the customeritems
- the items to be ordered- Returns:
- the data of the placed order
- Throws:
CustomerNotFoundException
- if no customer with the specified identifier existsPaymentFailedException
- if the payment failed (e.g. invalid or expired credit card, amount exceeds limit)
-
findOrder
Finds an order by identifier.- Parameters:
id
- the identifier of the order- Returns:
- the data of the found order
- Throws:
OrderNotFoundException
- if no order with the specified identifier exists
-
searchOrders
Searches for orders by customer and year.- Parameters:
customerId
- the identifier of the customeryear
- the year of the orders- Returns:
- the matching orders
- Throws:
CustomerNotFoundException
- if no customer with the specified identifier exists
-
cancelOrder
Tries to cancel an order.- Parameters:
id
- the identifier of the order- Throws:
OrderNotFoundException
- if no order with the specified identifier existsOrderAlreadyShippedException
- if the order has already been shipped
-