54 lines
1.7 KiB
Java
54 lines
1.7 KiB
Java
package com.billpaymentservice.bbps.controller;
|
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
|
import com.billpaymentservice.bbps.service.AgentService;
|
|
|
|
@RestController
|
|
@RequestMapping("/agent")
|
|
public class AgentController {
|
|
|
|
private final AgentService agentService;
|
|
|
|
public AgentController(AgentService agentService) {
|
|
this.agentService = agentService;
|
|
}
|
|
|
|
/**
|
|
* Fetches bill details from external BBPS service
|
|
*/
|
|
@PostMapping(
|
|
value = "/requestBillFetch",
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
)
|
|
public ResponseEntity<ResponseModel> requestBillFetch(
|
|
@Validated @RequestBody FetchBillRequest fetchBillRequest) {
|
|
|
|
ResponseModel response = agentService.initiateBillFetch(fetchBillRequest);
|
|
return ResponseEntity.ok(response);
|
|
}
|
|
|
|
/**
|
|
* Fetches bill details from external BBPS service
|
|
*/
|
|
@PostMapping(
|
|
value = "/fetchBillById",
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
)
|
|
public ResponseEntity<ResponseModel> fetchBillById(
|
|
@Validated @RequestBody BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
|
|
|
ResponseModel response = agentService.fetchBillById(billFetchByBillIdRequest);
|
|
return ResponseEntity.ok(response);
|
|
}
|
|
|
|
}
|