Subversion Repositories SmartDukaan

Rev

Rev 33595 | Rev 33672 | 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.dao.repository.cs.AgentRecordingRepository;
import com.spice.profitmandi.service.integrations.kommuno.KommunoService;
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.ModelAttribute;
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;

    @Autowired
    KommunoService kommunoService;

    @Autowired
    AgentRecordingRepository agentRecordingRepository;

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

        return responseSender.ok(true);
    }


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