Пример #1
0
        /// <summary>
        /// Retrive all calls which satisfy CallOptions criteria. Make GET request
        /// </summary>
        /// <param name="callOptions">Call options to narrow search of calls</param>
        /// <returns></returns>
        public async Task<CallResult> GetCalls(CallListOptions callOptions)
        {
            var request = new RestRequest();
            request.Resource = RequestUri.GetCallsUri;

            CreateCallListOptions(callOptions, request);

            return await Execute<CallResult>(request);
        }
Пример #2
0
        /// <summary>
        /// Helper method to populate Rest params
        /// </summary>
        /// <param name="callListOptions">Call options</param>
        /// <param name="request">Rest Request</param>
        private void CreateCallListOptions(CallListOptions callListOptions, RestRequest request)
        {
            var startDateParameterName = GetParameterNameWithEquality(callListOptions.StartTimeComaparasion, "StartTime");

            if (callListOptions.To != null) request.AddParameter("To", callListOptions.To);
            if (callListOptions.From != null) request.AddParameter("From", callListOptions.From);
            if (callListOptions.Status != null) request.AddParameter("Status", callListOptions.Status);
            if (callListOptions.StartTime.HasValue) request.AddParameter(startDateParameterName, callListOptions.StartTime.Value.ToString("yyyy-MM-dd"));
            if (callListOptions.Page.HasValue) request.AddParameter("Page", callListOptions.Page);
            if (callListOptions.PageSize.HasValue) request.AddParameter("PageSize", callListOptions.PageSize);
        }