@RequestMapping( value = "/mango/events/call", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Transactional public String processMangoCall(@RequestBody String body) { try { mangoApi.processCall(body); return ApiResponseStatuses.toJson(ApiResponseStatuses.OK); } catch (IOException e) { return ApiResponseStatuses.toJson(ApiResponseStatuses.BAD_REQUEST); } }
@RequestMapping( value = "/test", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public String test() { return ApiResponseStatuses.toJson(ApiResponseStatuses.OK); }
// номер: [email protected] - для того что бы voximplant мог определить // куда переадресоввать. в таблицу подставлять "rollmarkt" DESTINATION, а номер для соединения // вставить в таблицу как DEALED @RequestMapping( value = ApiConstants.PROCESS_CALL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Transactional public String processCall( @RequestParam("call_number") String callNumber, @RequestParam("destination_number") String destinationNumber) throws IOException { try { if (callNumber == null || callNumber.isEmpty() || callNumber.equals("{}")) { throw new IOException(); } callNumber = URLDecoder.decode(callNumber, "utf-8"); } catch (IOException e) { return ApiResponseStatuses.toJson(ApiResponseStatuses.BAD_REQUEST); } AccountSettings accountSettings = accountSettingsManager.getAccountSettingsByDestinationPhone(destinationNumber); PhoneNumber phoneNumber = phoneNumberManager.getDialedPhoneNumberByAccountSettingsId(accountSettings.getId()); String data = "{\"phone\":\"" + callNumber + "\"}"; leadProcessingService.pushLead(data, "", "", accountSettings.getHost(), LeadType.CALL); return phoneNumber != null ? "{\"dialedNumberType\":\"" + phoneNumber.getPhoneType() + "\"," + "\"dialedNumber\":\"" + phoneNumber.getPhone() + "\"}" : "{}"; }
@RequestMapping( value = ApiConstants.PUSH_DATA, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Transactional public String pushData(@RequestBody String body) { try { Map dataMap = new ObjectMapper().readValue(URLDecoder.decode(body, "utf-8"), Map.class); leadProcessingService.pushLead( new JSONObject((Map) dataMap.get(ApiConstants.PUSH_DATA_FORM_DATA_PARAM)).toString(), StringEscapeUtils.unescapeHtml((String) dataMap.get(ApiConstants.PUSH_DATA_PARAMS_PARAM)), StringEscapeUtils.unescapeHtml( (String) dataMap.get(ApiConstants.PUSH_DATA_REFERRER_PARAM)), InternetDomainName.from((String) dataMap.get(ApiConstants.PUSH_DATA_HOST_PARAM)) .toString(), LeadType.FORM); return ApiResponseStatuses.toJson(ApiResponseStatuses.OK); } catch (IOException e) { return ApiResponseStatuses.toJson(ApiResponseStatuses.BAD_REQUEST); } }