private async Task <ServiceObjectResult <ICollection <AccountAccessContext> > > ObtainValidAccountContexts(string userId) { //Refresh access on all users accounts where required var accessRefreshResult = await _authorizationService.AttemptRefreshAccountContexts(userId); if (!accessRefreshResult.Success) { return(ServiceObjectResult <ICollection <AccountAccessContext> > .Failed(null, accessRefreshResult.Errors)); } //ObtainAccessContexts var accessContextResult = await _accessCachingService.RetrieveAccessContexts(userId, new List <Scope> { Scope.transactions, Scope.accounts }); if (!accessContextResult.Success) { return(ServiceObjectResult <ICollection <AccountAccessContext> > .Failed(null, accessContextResult.Errors)); } if (accessContextResult.Result == null) { return(ServiceObjectResult <ICollection <AccountAccessContext> > .Failed(null, new List <string> { ErrorMessages.UserNotFound })); } return(ServiceObjectResult <ICollection <AccountAccessContext> > .Succeeded(accessContextResult.Result)); }