public async Task <ActionResult <FeeQuoteViewModelGet> > GetFeeQuote() { if (!IdentityProviderStore.GetUserAndIssuer(User, Request.Headers, out var identity)) { return(Unauthorized("Incorrectly formatted token")); } logger.LogInformation($"Get FeeQuote for user { ((identity == null) ? "/" : identity.ToString() )} ..."); FeeQuote feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(identity); if (feeQuote == null) { logger.LogInformation($"There are no active feeQuotes."); return(NotFound()); } var feeQuoteViewModelGet = new FeeQuoteViewModelGet(feeQuote, callbackIPAddressesArray) { Timestamp = clock.UtcNow(), }; return(await FillFeeQuoteViewModelWithInfo(feeQuoteViewModelGet)); }
public async Task <ActionResult <FeeQuoteViewModelGet> > GetFeeQuote() { if (!IdentityProviderStore.GetUserAndIssuer(User, Request.Headers, out var identity)) { return(Unauthorized("Incorrectly formatted token")); } logger.LogInformation($"Get FeeQuote for user { ((identity == null) ? "/" : identity.ToString() )} ..."); FeeQuote feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(identity); if (feeQuote == null) { logger.LogInformation($"There are no active feeQuotes."); return(NotFound()); } var feeQuoteViewModelGet = new FeeQuoteViewModelGet(feeQuote) { Timestamp = clock.UtcNow(), }; feeQuoteViewModelGet.ExpiryTime = feeQuoteViewModelGet.Timestamp.Add(TimeSpan.FromMinutes(quoteExpiryMinutes)); var info = blockChainInfo.GetInfo(); feeQuoteViewModelGet.MinerId = await minerId.GetCurrentMinerIdAsync(); feeQuoteViewModelGet.CurrentHighestBlockHash = info.BestBlockHash; feeQuoteViewModelGet.CurrentHighestBlockHeight = info.BestBlockHeight; logger.LogInformation($"Returning feeQuote with ExpiryTime: {feeQuoteViewModelGet.ExpiryTime}."); return(await SignIfRequiredAsync(feeQuoteViewModelGet, feeQuoteViewModelGet.MinerId)); }
public ActionResult <IEnumerable <FeeQuoteConfigViewModelGet> > Get( [FromQuery] string identity, [FromQuery] string identityProvider, [FromQuery] bool anonymous, [FromQuery] bool current, [FromQuery] bool valid) { UserAndIssuer userAndIssuer = null; if (identity != null || identityProvider != null) { userAndIssuer = new UserAndIssuer() { Identity = identity, IdentityProvider = identityProvider }; } IEnumerable <FeeQuote> result = new List <FeeQuote>(); if (valid) { logger.LogInformation($"GetValidFeeQuotes for user { ((userAndIssuer == null) ? "/" : userAndIssuer.ToString())} ..."); if (userAndIssuer != null) { result = feeQuoteRepository.GetValidFeeQuotesByIdentity(userAndIssuer); } if (anonymous) { result = result.Concat(feeQuoteRepository.GetValidFeeQuotesByIdentity(null)); } if (!anonymous && userAndIssuer == null) { result = feeQuoteRepository.GetValidFeeQuotes(); } } else if (current) { logger.LogInformation($"GetCurrentFeeQuotes for user { ((userAndIssuer == null) ? "/" : userAndIssuer.ToString())} ..."); if (userAndIssuer != null) { var feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(userAndIssuer); if (feeQuote != null) { result = result.Append(feeQuote); } } if (anonymous) { var feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(null); if (feeQuote != null) { result = result.Append(feeQuote); } } if (!anonymous && userAndIssuer == null) { result = feeQuoteRepository.GetCurrentFeeQuotes(); } } else { logger.LogInformation($"GetFeeQuotes for user { ((userAndIssuer == null) ? "/" : userAndIssuer.ToString())} ..."); if (userAndIssuer != null) { result = feeQuoteRepository.GetFeeQuotesByIdentity(userAndIssuer); } if (anonymous) { result = result.Concat(feeQuoteRepository.GetFeeQuotesByIdentity(null)); } if (!anonymous && userAndIssuer == null) { result = feeQuoteRepository.GetFeeQuotes(); } } return(Ok(result.Select(x => new FeeQuoteConfigViewModelGet(x)))); }