// номер: [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() + "\"}" : "{}"; }
@Transactional public void getCallbackHunterCalls() throws ParseException, IOException { List<AccountSettings> accountSettingsList = accountSettingsManager.getAccountSettingsList(); for (AccountSettings accountSettings : accountSettingsList) { if (accountSettings.getCbhId() != null && !accountSettings.getCbhId().isEmpty() && accountSettings.getCbhKey() != null && !accountSettings.getCbhKey().isEmpty()) { JsonArray arrayResponse = callBackHunterApi.getData( accountSettings.getCbhId(), accountSettings.getCbhKey(), Calendar.getInstance(TIME_ZONE).getTime()); for (JsonElement call : arrayResponse) { JsonObject object = call.getAsJsonObject(); String data = object.get("phone_client").getAsString(); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); format.setTimeZone(TIME_ZONE); Date date = format.parse(object.get("datecall").getAsString()); if (leadManager .getLeadsByTypeAndDataAndDate(LeadType.CALLBACK, data, date) .isEmpty()) { // check duplicated leads for today leadProcessingService.pushLead( data, "", "", accountSettings.getHost(), LeadType.CALLBACK); } } } } }