Subversion Repositories SmartDukaan

Rev

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

package com.spice.profitmandi.web.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.spice.profitmandi.service.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.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

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

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

    @Autowired
    MVCResponseSender mvcResponseSender;

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

    @Autowired
    ObjectMapper objectMapper;

    @RequestMapping(value = "/click2call/report-handler", method = RequestMethod.POST)
    public String click2callReportHandlerPost(HttpServletRequest request, Model model, @RequestParam(name = "push_report") String report) throws Exception {

        LOGGER.info("Report - {}", report);
        objectMapper.readValue(report, CallDetailModel.class);
        model.addAttribute("response1", mvcResponseSender.createResponseString("GODBLESSYOU"));
        return "response";
    }
}