Applying a coupon discount automatically

Applying a coupon discount automatically

Hello, 
I have a Price Books with different prices according to quantity and coupons with different discounts. 

I"m looking for the way to have the final price be calculated based on quantity and coupon discount (if coupon is supplied) when I call a REST API from external system. 

What is the best way to implement it?