Esempio n. 1
0
        public Queue CreateQueue(string name, int size, string waitUrl, int waitTime)
        {
            var queue = twilio.CreateQueue(name);

            TwilioProvider.ThrowIfError(queue);
            return(new Queue(queue.Sid, name, size, waitUrl, waitTime));
        }
Esempio n. 2
0
        public string GetQueue(string name)
        {
            var queues = twilio.ListQueues();

            TwilioProvider.ThrowIfError(queues);
            return(queues.Queues.Find(r => r.FriendlyName == name).Sid);
        }
Esempio n. 3
0
        public IEnumerable <string> QueueCalls(string id)
        {
            var calls = twilio.ListQueueMembers(id);

            TwilioProvider.ThrowIfError(calls);
            return(calls.QueueMembers.Select(r => r.CallSid));
        }
Esempio n. 4
0
        public override VoipCall RedirectCall(string callId, string to)
        {
            var call = twilio.RedirectCall(callId, Settings.Redirect(to), "GET");

            TwilioProvider.ThrowIfError(call);
            return(new VoipCall {
                Id = call.Sid, To = to
            });
        }
Esempio n. 5
0
        public Queue CreateQueue(string name, int size, string waitUrl, int waitTime)
        {
            var queues = twilio.ListQueues();
            var queue  = queues.Queues.FirstOrDefault(r => r.FriendlyName == name);

            if (queue == null)
            {
                queue = twilio.CreateQueue(name);
                TwilioProvider.ThrowIfError(queue);
            }
            return(new Queue(queue.Sid, name, size, waitUrl, waitTime));
        }
Esempio n. 6
0
        public void ClearOldNumbers()
        {
            if (string.IsNullOrEmpty(TwilioAccountSid) || string.IsNullOrEmpty(TwilioAuthToken))
            {
                return;
            }

            var provider = new TwilioProvider(TwilioAccountSid, TwilioAuthToken);

            var dao     = new CachedVoipDao(CoreContext.TenantManager.GetCurrentTenant().TenantId);
            var numbers = dao.GetNumbers();

            foreach (var number in numbers)
            {
                provider.DisablePhone(number);
                dao.DeleteNumber(number.Id);
            }
        }
Esempio n. 7
0
        public override VoipCall Call(string to, string contactId = null)
        {
            var number = to.Split('#');

            var call = twilio.InitiateOutboundCall(new CallOptions
            {
                SendDigits = number.Length > 1 ? number[1] + "#" : string.Empty,
                To         = number[0],
                From       = Number,
                Record     = Settings.Caller.Record,
                Url        = Settings.Connect(contactId: contactId)
            });

            TwilioProvider.ThrowIfError(call);

            return(new VoipCall {
                Id = call.Sid, From = call.From, To = call.To
            });
        }