public void deliverVoxVerification(String destination, String verificationCode, Optional<String> locale) throws IOException, TwilioRestException { String url = "https://" + localDomain + "/v1/voice/description/" + verificationCode; if (locale.isPresent()) { url += "?l=" + locale.get(); } TwilioRestClient client = new TwilioRestClient(accountId, accountToken); CallFactory callFactory = client.getAccount().getCallFactory(); Map<String, String> callParams = new HashMap<>(); callParams.put("To", destination); callParams.put("From", getRandom(random, numbers)); callParams.put("Url", url); try { callFactory.create(callParams); } catch (RuntimeException damnYouTwilio) { throw new IOException(damnYouTwilio); } voxMeter.mark(); }
Call call = callFactory.create(callParams); System.out.println(call.getSid());
@Override public void connect(MessageContext messageContext) throws ConnectException { SynapseLog log = getLog(messageContext); log.auditLog("Start: Make Call"); Map<String, String> callParams = createParameterMap(messageContext); try { TwilioRestClient twilioRestClient = TwilioUtil.getTwilioRestClient(messageContext); CallFactory callFactory = twilioRestClient.getAccount().getCallFactory(); Call call = callFactory.create(callParams); OMElement omResponse = TwilioUtil.parseResponse("call.create.success"); TwilioUtil.addElement(omResponse, TwilioUtil.PARAM_CALL_SID, call.getSid()); TwilioUtil.preparePayload(messageContext, omResponse); } catch (Exception e) { log.error(e.getMessage()); TwilioUtil.handleException(e, "0003", messageContext); throw new SynapseException(e); } log.auditLog("End: Make Call"); }