public static async Task <List <PortfolioItem> > GetAllListings(this StockXAccount login) { List <PortfolioItem> OutputItems = new List <PortfolioItem>(); StockXApiResult <GetPagedPortfolioItemsResponse> GetListings; try { GetListings = await login.GetCurrentListings(login.CustomerID.ToString(), 1); } catch (Exception ex) { AuditExtensions.CreateAudit(login.Id, "StockXApi", "GetAllListings", "Error", ex.Message, ex.StackTrace); return(null); } if ((int)GetListings.Code > 399 && (int)GetListings.Code < 500) { throw new NeedsVerificaitonException(login); } GetPagedPortfolioItemsResponse Items = GetListings.RO; if (Items.PortfolioItems.Count == 0) { return(OutputItems); } if (Items.PortfolioItems == null) { return(null); } OutputItems.AddRange(Items.PortfolioItems); var i = 2; while (Items.Pagination != null && Items.Pagination.NextPage != null) { GetListings = await login.GetCurrentListings(login.CustomerID.ToString(), i ++); if ((int)GetListings.Code > 399 && (int)GetListings.Code < 500) { throw new NeedsVerificaitonException(login); } Items = GetListings.RO; if (Items.PortfolioItems == null || Items.PortfolioItems.Count == 0) { break; } OutputItems.AddRange(Items.PortfolioItems); } return(OutputItems); }
public static async Task <List <PortfolioItem> > GetAllPending(this StockXAccount login) { List <PortfolioItem> OutputItems = new List <PortfolioItem>(); var GetListings = await login.GetCurrentPending(login.CustomerID.ToString(), 1); if ((int)GetListings.Code > 399 && (int)GetListings.Code < 500) { throw new NeedsVerificaitonException(login); } GetPagedPortfolioItemsResponse Items = GetListings.RO; if (Items.PortfolioItems == null) { return(Array.Empty <PortfolioItem>().ToList()); } if (Items.PortfolioItems.Count == 0) { return(Items.PortfolioItems); } OutputItems.AddRange(Items.PortfolioItems); var i = 2; while (Items.Pagination != null && Items.Pagination.NextPage != null) { GetListings = await login.GetCurrentPending(login.CustomerID.ToString(), i ++); if ((int)GetListings.Code > 399 && (int)GetListings.Code < 500) { throw new NeedsVerificaitonException(login); } Items = GetListings.RO; if (Items.PortfolioItems == null || Items.PortfolioItems.Count == 0) { return(null); } OutputItems.AddRange(Items.PortfolioItems); } return(OutputItems); }