Exemple #1
0
        public void EnqueueRequiredWithWaitUrlTest()
        {
            Enqueue enqueue = new Enqueue("14f487e2-de1a-4a45-a682-5df8e3f3458d", "http://foo.com");

            enqueue.setWaitUrl("http://foo.com/wait");
            string json = enqueue.toJson();

            Assert.IsNotNull(json);
            Assert.AreEqual(json, "{\"Enqueue\":{\"queueId\":\"14f487e2-de1a-4a45-a682-5df8e3f3458d\",\"actionUrl\":\"http://foo.com\",\"waitUrl\":\"http://foo.com/wait\",\"notificationUrl\":null}}");
        }
        public ActionResult InboundCall(CallStatusCallback freeClimbRequest)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify inbound call is in proper state
            if (freeClimbRequest.getCallStatus == ECallStatus.Ringing)
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set greeting prompt
                say.setText("Hello. Your call will be queued.");

                // Add PerCL say script to PerCL container
                script.Add(say);

                // Create PerCL pause script with a 100 millisecond pause
                script.Add(new Pause(100));

                // Create queue options with an alias
                QueueOptions options = new QueueOptions();
                options.setAlias("InboundCallQueue");

                // Create FreeClimbClient object
                FreeClimbClient client = new FreeClimbClient(getFreeClimbAccountId(), getFreeClimbApiKeys());

                // Create a queue with an alias
                Queue queue = client.getQueuesRequester.create(options);

                // Create PerCL say to enqueue the call into the newly created queue with an actionUrl
                Enqueue enqueue = new Enqueue(queue.getQueueId, getAppUrl() + "/voice/InboundCallAction");
                // Add waitUrl
                enqueue.setWaitUrl(getAppUrl() + "/voice/InboundCallWait");

                // Add PerCL enqueue script to PerCL container
                script.Add(enqueue);
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }