Example #1
0
        public IActionResult GetExternalAccounts()
        {
            string                 clientId  = Request.HttpContext.Items["ClientId"]?.ToString();
            List <Datafeed>        datafeeds = _datafeedProcessor.GetDatafeeds(clientId);
            List <ExternalAccount> accounts  = new List <ExternalAccount>();

            foreach (var datafeed in datafeeds)
            {
                IDatafeedAPI datafeedApi = DatafeedManager.ResolveApiType(datafeed.Provider);
                if (datafeedApi is TrueLayerAPI trueLayerAPI)
                {
                    trueLayerAPI._ClientId = _appSettings.TrueLayer_ClientID;
                    trueLayerAPI._Secret   = _appSettings.TrueLayer_ClientSecret;
                    trueLayerAPI.SetMode(_appSettings.TrueLayer_Mode);
                    trueLayerAPI._datafeedDataService = new FinanceAPIMongoDataService.DataService.DatafeedDataService(_appSettings.MongoDB_ConnectionString);
                }
                accounts.AddRange(datafeedApi.GetExternalAccounts(clientId, datafeed.AccessKey, datafeed.VendorID, datafeed.VendorName, datafeed.Provider));
            }

            List <ExternalAccount> mappedAccounts = _datafeedProcessor.GetExternalAccounts(clientId);

            foreach (ExternalAccount account in mappedAccounts)
            {
                if (!accounts.Any(a => a.AccountID == account.AccountID))
                {
                    accounts.Add(account);
                }
            }

            return(Json(accounts));
        }
        public IActionResult GetDatafeeds(string datafeedType = null)
        {
            string clientId = Request.HttpContext.Items["ClientId"]?.ToString();

            return(Json(_datafeedProcessor.GetDatafeeds(clientId, datafeedType)));
        }