Example #1
0
        public async Task <PagedResult <IEnumerable <RecurringPayment> > > GetRecurringPaymentSchedulesAsync(int customerId, DateTime?startDate = null, DateTime?endDate = null, ScheduleStatus status = ScheduleStatus.Active, ScheduleSort sortBy = ScheduleSort.Id, SortDirection direction = SortDirection.ASC, int page = 1, int pageSize = 200, bool lite = false)
        {
            var result = await customerService.GetRecurringPaymentSchedulesAsync(customerId, startDate, endDate, status, sortBy, direction, page, pageSize, lite);

            if (result != null)
            {
                DumpObject("GetRecurringPaymentSchedulesAsync", result);
            }

            return(result);
        }
        public async Task <PagedResult <IEnumerable <RecurringPayment> > > GetRecurringPaymentSchedulesAsync(int customerId, DateTime?startDate = null, DateTime?endDate = null, ScheduleStatus?status = null, ScheduleSort sortBy = ScheduleSort.Id, SortDirection direction = SortDirection.ASC, int page = 1, int pageSize = 200, bool lite = false)
        {
            StringBuilder endpoint = new StringBuilder(string.Format("{0}{1}/{2}/recurringpayments?lite={3}", settings.BaseUrl, Endpoints.Customer, customerId, lite));

            if (startDate != null)
            {
                endpoint.AppendFormat("&startdate={0}", startDate.Value.ToString("yyyy-MM-dd"));
            }

            if (endDate != null)
            {
                endpoint.AppendFormat("&enddate={0}", endDate.Value.ToString("yyyy-MM-dd"));
            }

            if (status != null)
            {
                endpoint.Append(string.Format("&status={0}", status));
            }

            if (sortBy != ScheduleSort.Id)
            {
                endpoint.AppendFormat("&sortby={0}", EnumStrings.ScheduleSortStrings[sortBy]);
            }

            if (direction != SortDirection.ASC)
            {
                endpoint.AppendFormat("&direction={0}", EnumStrings.SortDirectionStrings[direction]);
            }

            if (page != 1)
            {
                endpoint.AppendFormat("&page={0}", page);
            }

            if (pageSize != 200)
            {
                endpoint.AppendFormat("&pagesize={0}", pageSize);
            }

            var result = await webServiceRequest.GetDeserializedAsync <Result <IEnumerable <RecurringPayment> > >(new Uri(endpoint.ToString()));

            return(PagedResult.ConvertToPagedResult <IEnumerable <RecurringPayment> >(result));
        }