Subversion Repositories SmartDukaan

Rev

Rev 33581 | Rev 33590 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.controller;

import com.spice.profitmandi.common.web.util.ResponseSender;
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
import com.spice.profitmandi.service.integrations.smartping.model.CallDetailModel;
import com.spice.profitmandi.web.util.MVCResponseSender;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.transaction.Transactional;

@Controller
@Transactional(rollbackOn = Throwable.class)
public class WebHookController {

    @Autowired
    MVCResponseSender mvcResponseSender;

    @Autowired
    private ResponseSender<?> responseSender;

    private static final Logger LOGGER = LogManager.getLogger(WebHookController.class);

    @Autowired
    SmartPingService smartPingService;

//    @RequestMapping(value = "/click2call/report-handler", method = RequestMethod.POST)
//    public String click2callReportHandlerPost(HttpServletRequest request, Model model, @RequestParam(name = "push_report") String callDetailString) throws Exception {
//
//        smartPingService.createAgentRecording(callDetailString);
//        model.addAttribute("response1", mvcResponseSender.createResponseString("GODBLESSYOU"));
//        return "response";
//    }

    @RequestMapping(value = "/click2call/report-handler", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> click2callReportHandlerPost(HttpServletRequest request, Model model, @RequestBody CallDetailModel callDetail) throws Exception {
        LOGGER.info("first event call detail {}", callDetail);
        smartPingService.createAgentRecording(callDetail);

        return responseSender.ok(true);
    }


    @RequestMapping(value = "/click2call/report-handler/recording-url", method = RequestMethod.POST)
    public ResponseEntity<?> click2callReportHandlerUpdateRecordingUrlPost(HttpServletRequest request, Model model, @RequestBody CallDetailModel callDetail) throws Exception {
        LOGGER.info("update call detail {}", callDetail);
        smartPingService.updateAgentRecordingUrl(callDetail);
        return responseSender.ok(true);
    }
}