public static List <Invoice> GetInvoiceHistory_ByDateRange_Next(int itemLimit, string startingAfterInvoiceId, DateTime startDate, DateTime endDate, string accountId = null) { var invoices = new List <Invoice>(); #region (Plan A) Check Redis Cache First #endregion #region (Plan B) Call Stripe API, Transform Data & Store in Redis Cache var stripeManager = new StripeManager(); string stripeCustomerId = null; bool addAccountDetails = false; if (!String.IsNullOrEmpty(accountId)) { stripeCustomerId = AccountManager.GetAccount(accountId, true, AccountManager.AccountIdentificationType.AccountID).StripeCustomerID; } else { addAccountDetails = true; } var stripeInvoices = stripeManager.GetInvoices_ByDateRange_Next(itemLimit, startingAfterInvoiceId, startDate, endDate, stripeCustomerId); if (stripeInvoices != null) { foreach (var stripeInvoice in stripeInvoices) { invoices.Add(Transformations.TransformStripeInvoiceToInvoice(stripeInvoice, addAccountDetails)); } } #endregion return(invoices); }