Ejemplo n.º 1
0
        /// <summary>
        /// Returns a paged list of phone calls made to and from the account.
        /// Makes a GET request to the Calls List resource.
        /// </summary>
        /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
        public virtual async Task<CallResult> ListCallsAsync(CallListRequest options)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            return await Execute<CallResult>(request);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a paged list of phone calls made to and from the account.
        /// Makes a GET request to the Calls List resource.
        /// </summary>
        /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
        public virtual CallResult ListCalls(CallListRequest options)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            return Execute<CallResult>(request);
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Returns a paged list of phone calls made to and from the account.
		/// Sorted by DateUpdated with most-recent calls first.
		/// </summary>
		/// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
		/// <param name="callback">Method to call upon successful completion</param>
        public virtual void ListCalls(CallListRequest options, Action<CallResult> callback)
		{
			var request = new RestRequest();
			request.Resource = "Accounts/{AccountSid}/Calls.json";

			AddCallListOptions(options, request);

			ExecuteAsync<CallResult>(request, (response) => callback(response));
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a paged list of phone calls made to and from the account.
        /// Sorted by DateUpdated with most-recent calls first.
        /// </summary>
        /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public void ListCalls(CallListRequest options, Action <CallResult> callback)
        {
            var request = new RestRequest();

            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            ExecuteAsync <CallResult>(request, (response) => callback(response));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a paged list of phone calls made to and from the account.
        /// Makes a GET request to the Calls List resource.
        /// </summary>
        /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
        public virtual CallResult ListCalls(CallListRequest options)
        {
            var request = new RestRequest();

            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            return(Execute <CallResult>(request));
        }
Ejemplo n.º 6
0
        private async Task<CallResult> ListCallsAsyncInternal(CallListRequest options)
        {
            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            var result = await ExecuteAsync(request, typeof(CallResult));
            return (CallResult)result;
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            TwilioConnect tc = new TwilioConnect();

            CallListRequest req = new CallListRequest();
            req.StartTimeComparison = ComparisonType.GreaterThanOrEqualTo;
            req.StartTime = new DateTime(2013, 5, 1);

            CallResult calls = tc.GetCallsAll(tc.GetTwilio(), req);

            List<CallResult> calllist = new List<CallResult>();

            FileInfo logfilename = new FileInfo("twiliologfile.txt");
            if (logfilename.Exists == true)
                logfilename.Delete();

            DirectoryInfo di = new DirectoryInfo("C:\\bjork\\twilio");
            if (di.Exists == false)
                di.Create();

            String fullpath = Path.Combine(di.FullName, logfilename.Name);

            using (StreamWriter writer = new StreamWriter(fullpath))
            {
                StringBuilder sb = new StringBuilder();
                foreach (var cr in calls.Calls)
                {
                    DateTime CallStart = cr.DateCreated.AddHours(-7);
                    sb.Append(CallStart);
                    sb.Append("|");
                    sb.Append(cr.Direction);
                    sb.Append("|");
                    sb.Append(cr.From);
                    sb.Append("|");
                    sb.Append(cr.To);
                    sb.Append("|");
                    sb.Append(cr.Status);
                    sb.Append("|");
                    TimeSpan duration = new TimeSpan(0, 0, 0, Convert.ToInt32(cr.Duration));
                    sb.Append(Convert.ToInt32(Math.Ceiling(duration.TotalMinutes)));
                    sb.Append("|");
                    sb.Append(cr.CallerName.Trim());
                    sb.Append("|");
                    sb.Append(cr.Sid);

                    writer.WriteLine(sb.ToString());

                    Console.WriteLine(sb.ToString());
                    sb.Clear();
                }
            }

            Console.ReadKey();
        }
Ejemplo n.º 8
0
        private async Task <CallResult> ListCallsAsyncInternal(CallListRequest options)
        {
            var request = new RestRequest();

            request.Resource = "Accounts/{AccountSid}/Calls.json";

            AddCallListOptions(options, request);

            var result = await ExecuteAsync(request, typeof(CallResult));

            return((CallResult)result);
        }
Ejemplo n.º 9
0
        private void AddCallListOptions(CallListRequest options, RestRequest request)
        {
            if (options.From.HasValue())
            {
                request.AddParameter("From", options.From);
            }
            if (options.To.HasValue())
            {
                request.AddParameter("To", options.To);
            }
            if (options.Status.HasValue())
            {
                request.AddParameter("Status", options.Status);
            }
            if (options.StartTime.HasValue)
            {
                request.AddParameter("StartTime", options.StartTime.Value.ToString("yyyy-MM-dd"));
            }
            if (options.EndTime.HasValue)
            {
                request.AddParameter("EndTime", options.EndTime.Value.ToString("yyyy-MM-dd"));
            }

            var startTimeParameterName = GetParameterNameWithEquality(options.StartTimeComparison, "StartTime");
            var endTimeParameterName   = GetParameterNameWithEquality(options.EndTimeComparison, "EndTime");

            if (options.StartTime.HasValue)
            {
                request.AddParameter(startTimeParameterName, options.StartTime.Value.ToString("yyyy-MM-dd"));
            }
            if (options.EndTime.HasValue)
            {
                request.AddParameter(endTimeParameterName, options.EndTime.Value.ToString("yyyy-MM-dd"));
            }

            if (options.Count.HasValue)
            {
                request.AddParameter("PageSize", options.Count.Value);
            }
            if (options.PageNumber.HasValue)
            {
                request.AddParameter("Page", options.PageNumber.Value);
            }

            if (options.ParentCallSid.HasValue())
            {
                request.AddParameter("ParentCallSid", options.ParentCallSid);
            }
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            //var tickets = _repository.All();
            var twilio = new TwilioRestClient(_credentials.AccountSid, _credentials.AuthToken);

            // Build the parameters
            var options = new CallListRequest();

            var calls = twilio.ListCalls(options);
            foreach (var call in calls.Calls)
            {
                Console.WriteLine(call.Direction);
            }
            return View(calls.Calls);
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new CallListRequest();
        request.From = "client:tommy";
        var calls = twilio.ListCalls(request);

        foreach (var call in calls.Calls)
        {
          Console.WriteLine(call.Direction);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new CallListRequest();
        request.Status = "busy";
        request.To = "+15558675309";
        var calls = twilio.ListCalls(request);

        foreach (var call in calls.Calls)
        {
          Console.WriteLine(call.StartTime);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new CallListRequest();
        request.Status = "completed";
        request.StartTimeComparison = ComparisonType.GreaterThanOrEqualTo;
        request.StartTime = new DateTime(2009, 07, 06);
        var calls = twilio.ListCalls(request);

        foreach (var call in calls.Calls)
        {
          Console.WriteLine(call.To);
        }
    }
Ejemplo n.º 14
0
        private void AddCallListOptions(CallListRequest options, RestRequest request)
        {
            if (options.From.HasValue()) request.AddParameter("From", options.From);
            if (options.To.HasValue()) request.AddParameter("To", options.To);
            if (options.Status.HasValue()) request.AddParameter("Status", options.Status);
            //			if (options.StartTime.HasValue) request.AddParameter("StartTime", options.StartTime.Value.ToString("yyyy-MM-dd"));
            //			if (options.EndTime.HasValue) request.AddParameter("EndTime", options.EndTime.Value.ToString("yyyy-MM-dd"));

            var startTimeParameterName = GetParameterNameWithEquality(options.StartTimeComparison, "StartTime");
            var endTimeParameterName = GetParameterNameWithEquality(options.EndTimeComparison, "EndTime");

            if (options.StartTime.HasValue) request.AddParameter(startTimeParameterName, options.StartTime.Value.ToString("yyyy-MM-dd"));
            if (options.EndTime.HasValue) request.AddParameter(endTimeParameterName, options.EndTime.Value.ToString("yyyy-MM-dd"));

            if (options.Count.HasValue) request.AddParameter("PageSize", options.Count.Value);
            if (options.PageNumber.HasValue) request.AddParameter("Page", options.PageNumber.Value);

            if (options.ParentCallSid.HasValue()) request.AddParameter("ParentCallSid", options.ParentCallSid);
        }
 private bool RedirectTwilio(string xmlPage)
 {
     TwilioRestClient Tclient;
     CallListRequest options;
     Tclient = new TwilioRestClient(AccountSid, "803c5c172df9c39096770ae982e0cefe");
     options = new CallListRequest();
     options.Count = 1;
     options.Status = "in-progress";
     var call = Tclient.RedirectCall(CallSid, xmlPage, "GET");
     if (call.RestException != null)
     {
         log.Info(String.Format("{0} - RedirectTwilio sendError Code: " + call.RestException.Code + " Error Message: " + call.RestException.Message, ANI));
         return false;
     }
     else
     {
         log.Info(String.Format("{0} - Sent " + xmlPage + " to Twilio. CallSid is " + CallSid + " AccountSid is " + AccountSid, ANI));
         return true;
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Returns a paged list of phone calls made to and from the account.
        /// Sorted by DateUpdated with most-recent calls first.
        /// Makes a GET request to the Calls List resource.
        /// </summary>
        /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
		public IAsyncOperation<CallResult> ListCallsAsync(CallListRequest options)
        {
            return (IAsyncOperation<CallResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListCallsAsyncInternal(options));
        }
Ejemplo n.º 17
0
 public CallResult GetCallsAll(TwilioRestClient TwilioAccount, CallListRequest CallListReq )
 {
     var calls = TwilioAccount.ListCalls(CallListReq);
     return calls;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Returns a paged list of phone calls made to and from the account.
 /// Sorted by DateUpdated with most-recent calls first.
 /// Makes a GET request to the Calls List resource.
 /// </summary>
 /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
 public IAsyncOperation <CallResult> ListCallsAsync(CallListRequest options)
 {
     return((IAsyncOperation <CallResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListCallsAsyncInternal(options)));
 }
Ejemplo n.º 19
0
 public CallResult GetCallsAll(TwilioRestClient TwilioAccount)
 {
     var request = new CallListRequest();
     var calls = TwilioAccount.ListCalls();
     return calls;
 }