Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pasquy73 committed Jan 20, 2025
1 parent 0d3497d commit 83a229e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@ public class BillingController {

@Autowired
protected BillingProxyService billing;

/**
* The POST /billing/previewPrice REST API is invoked to calculate the price preview (i.e., prices and taxes) of a ProcuctOrder (TMF622-v4).
*
* @param orderJson The ProductOrder (TMF622-v4) as a Json string for which the prices and taxes must be calculated
* @return The ProductOrder as a Json string with prices and taxes
* @throws Throwable If an error occurs during the calculation of the product order's price preview
*/

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

/**
* The POST /billing/bill REST API is invoked to calculate the bill of a Product (TMF637-v4) without taxes.
*
* @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.
* @return The list of AppliedCustomerBillingRate as a Json without taxes
* @throws Throwable If an error occurs during the calculation of the bill for the Product
*/

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

/**
* The POST /billing/bill REST API is invoked to calculate the bill of a Product (TMF637-v4) without taxes.
*
* @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.
* @return The list of AppliedCustomerBillingRate as a Json without taxes
* @throws Throwable If an error occurs during the calculation of the bill for the Product
*/
private String getBillRequestDTOtoJson(BillingRequestDTO billRequestDTO) {
// product
String productJson = billRequestDTO.getProduct().toJson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ public class BillingProxyService implements IProxyService {
public String billinEngine;


public ResponseEntity<String> pricePreview(String appliedCustomerBillingRates) {
public ResponseEntity<String> previewPrice(String order) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<>(appliedCustomerBillingRates, headers);
HttpEntity<String> request = new HttpEntity<>(order, headers);

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface IProxyService {

public ResponseEntity<String> pricePreview(String appliedCustomerBillingRates);
public ResponseEntity<String> previewPrice(String order);

public ResponseEntity<String> bill(String billRequest);

Expand Down

0 comments on commit 83a229e

Please sign in to comment.