Example #1
0
        public void CreateAndVerifyOutDialActionCallbackTest()
        {
            OutDialActionCallback oa = OutDialActionCallback.fromJson("{\"accountId\":\"AC766bc3fb87212042619f41ac6344feef2f1b0d00\",\"callId\":\"CA06d0eeb157c2322e3c44a19947eec2085e4be356\",\"callStatus\":\"inProgress\",\"conferenceId\":null,\"dialCallId\":\"CA694ec3a0eedfc8d62a96e3c97defc89371b1fdda\",\"direction\":\"outboundDial\",\"from\":\"+12248806205\",\"queueId\":null,\"requestType\":\"outDialStart\",\"to\":\"+18475978014\"}");

            Assert.AreEqual(oa.getAccountId, "AC766bc3fb87212042619f41ac6344feef2f1b0d00");
            Assert.AreEqual(oa.getCallId, "CA06d0eeb157c2322e3c44a19947eec2085e4be356");
            Assert.AreEqual(oa.getCallStatus, ECallStatus.InProgress);
            Assert.IsNull(oa.getConferenceId);
            Assert.AreEqual(oa.getDirection, EDirection.OutboundDial);
            Assert.AreEqual(oa.getFrom, "+12248806205");
            Assert.IsNull(oa.getParentCallId);
            Assert.AreEqual(oa.getDialCallId, "CA694ec3a0eedfc8d62a96e3c97defc89371b1fdda");
            Assert.AreEqual(oa.getTo, "+18475978014");
        }
        public ActionResult OutboundCallMade([FromQuery(Name = "conferenceId")] string conferenceId, OutDialActionCallback request)
        {
            PerCLScript script = new PerCLScript();
            // note the context of the request is the original call, not the newly created via OutDial
            AddToConference addToConference    = new AddToConference(conferenceId, request.getCallId);
            var             leaveConferenceUrl = AppUrl + "/voice/LeftConference";

            // set the leaveConferenceUrl for the inbound caller, so that we can terminate the conference when they hang up
            addToConference.setLeaveConferenceUrl(leaveConferenceUrl);
            script.Add(addToConference);
            return(Content(script.toJson(), "application/json"));
        }