Skip to content

Commit 83a229e

Browse files
committed
refactoring
1 parent 0d3497d commit 83a229e

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/main/java/it/eng/dome/billing/proxy/controller/BillingController.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,28 @@ public class BillingController {
2323

2424
@Autowired
2525
protected BillingProxyService billing;
26+
27+
/**
28+
* The POST /billing/previewPrice REST API is invoked to calculate the price preview (i.e., prices and taxes) of a ProcuctOrder (TMF622-v4).
29+
*
30+
* @param orderJson The ProductOrder (TMF622-v4) as a Json string for which the prices and taxes must be calculated
31+
* @return The ProductOrder as a Json string with prices and taxes
32+
* @throws Throwable If an error occurs during the calculation of the product order's price preview
33+
*/
2634

2735
@RequestMapping(value = "/pricePreview", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
2836
public ResponseEntity<String> calculatePricePreview(@RequestBody String orderJson) throws Throwable {
2937
logger.info("Received request to calculate price preview");
3038
return billing.pricePreview(orderJson);
3139
}
3240

41+
/**
42+
* The POST /billing/bill REST API is invoked to calculate the bill of a Product (TMF637-v4) without taxes.
43+
*
44+
* @param BillingRequestDTO The DTO contains information about the Product (TMF637-v4), the TimePeriod (TMF678-v4) and the list of ProductPrice (TMF637-v4) for which the bill must be calculated.
45+
* @return The list of AppliedCustomerBillingRate as a Json without taxes
46+
* @throws Throwable If an error occurs during the calculation of the bill for the Product
47+
*/
3348

3449
@RequestMapping(value = "/bill", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
3550
public ResponseEntity<String> calculateBill(@RequestBody BillingRequestDTO billRequestDTO) throws Throwable {
@@ -41,6 +56,13 @@ public ResponseEntity<String> calculateBill(@RequestBody BillingRequestDTO billR
4156
return billing.bill(json);
4257
}
4358

59+
/**
60+
* The POST /billing/bill REST API is invoked to calculate the bill of a Product (TMF637-v4) without taxes.
61+
*
62+
* @param BillingRequestDTO The DTO contains information about the Product (TMF637-v4), the TimePeriod (TMF678-v4) and the list of ProductPrice (TMF637-v4) for which the bill must be calculated.
63+
* @return The list of AppliedCustomerBillingRate as a Json without taxes
64+
* @throws Throwable If an error occurs during the calculation of the bill for the Product
65+
*/
4466
private String getBillRequestDTOtoJson(BillingRequestDTO billRequestDTO) {
4567
// product
4668
String productJson = billRequestDTO.getProduct().toJson();

src/main/java/it/eng/dome/billing/proxy/service/BillingProxyService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ public class BillingProxyService implements IProxyService {
2323
public String billinEngine;
2424

2525

26-
public ResponseEntity<String> pricePreview(String appliedCustomerBillingRates) {
26+
public ResponseEntity<String> previewPrice(String order) {
2727
HttpHeaders headers = new HttpHeaders();
2828
headers.setContentType(MediaType.APPLICATION_JSON);
29-
HttpEntity<String> request = new HttpEntity<>(appliedCustomerBillingRates, headers);
29+
HttpEntity<String> request = new HttpEntity<>(order, headers);
3030

31-
logger.debug("Payload received:\n" + appliedCustomerBillingRates);
32-
//TODO replace in the future .... /billing/pricePreview
33-
ResponseEntity<String> response = restTemplate.postForEntity(billinEngine + "/price/order", request, String.class);
31+
logger.debug("Payload received:\n" + order);
32+
ResponseEntity<String> response = restTemplate.postForEntity(billinEngine + "/billing/previewPrice", request, String.class);
3433

3534
logger.debug("Headers: " + response.getHeaders().toString());
3635
logger.debug("Body:\n" + response.getBody().toString());
@@ -45,4 +44,5 @@ public ResponseEntity<String> bill(String billRequest) {
4544
//logger.debug("Payload received:\n" + billRequest);
4645
return restTemplate.postForEntity(billinEngine + "/billing/bill", request, String.class);
4746
}
47+
4848
}

src/main/java/it/eng/dome/billing/proxy/service/IProxyService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public interface IProxyService {
66

7-
public ResponseEntity<String> pricePreview(String appliedCustomerBillingRates);
7+
public ResponseEntity<String> previewPrice(String order);
88

99
public ResponseEntity<String> bill(String billRequest);
1010

0 commit comments

Comments
 (0)