Advertisement
BoberDiversant

Untitled

Dec 3rd, 2019
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. @GetMapping("campaign/{campaignId}/poll")
  2.     public ResponseEntity<IvoiceApiResponse<List<IncomingCallTaskDto>>>
  3.         findNew(@PathVariable("campaignId") String campaignId,
  4.             @RequestParam(value = "lastTaskId", required = false) String lastTaskId) {
  5.         List<CallTask> newTasks;
  6.         if (Optional.ofNullable(lastTaskId).isPresent()) {
  7.             log.info(format("Requesting call tasks performed after task with id: %s, for campaign: %s", lastTaskId, campaignId));
  8.             newTasks = incomingCallTaskService.findNew(campaignId, lastTaskId);
  9.         } else {
  10.             log.info(format("Requesting call tasks performed for campaign: %s", campaignId));
  11.             newTasks = incomingCallTaskService.findNew(campaignId);
  12.         }
  13.  
  14.         List<IncomingCallTaskDto> dtos = newTasks.stream()
  15.                 .filter((newTask) -> (newTask.getCampaign().equals(campaignId))).map(IncomingCallTaskController::map).collect(Collectors.toList());
  16.         IvoiceApiResponse<List<IncomingCallTaskDto>> apiResponse = IvoiceApiResponse.response(dtos);
  17.         return new ResponseEntity<>(apiResponse, HttpStatus.OK);
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement