private async Task <ListPage <OrderCloudIntegrationsConversionRate> > GetCachedRates(ListArgs <OrderCloudIntegrationsConversionRate> rateArgs, CurrencySymbol currency)
        {
            var rates = await _cache.GetOrAddAsync($"exchangerates_{currency}", () => {
                return(_blob.Get <OrderCloudIntegrationsExchangeRate>($"{currency}.json"));
            }, TimeSpan.FromHours(1));

            return(Filter(rateArgs, rates));
        }
Exemplo n.º 2
0
        public async Task <JObject> GetQueuedItem(string path)
        {
            try
            {
                var blob = await _blobQueue.Get <JObject>(path);

                return(blob);
            }
            catch (Exception ex)
            {
                throw new OrchestrationException(OrchestrationErrorType.QueuedGetError, $"{path} | {ex.Message}");
            }
        }
Exemplo n.º 3
0
        public async Task <JObject> GetCachedItem(string path)
        {
            try
            {
                var blob = await _blobCache.Get <JObject>($"{path}");

                return(blob);
            }
            catch (Exception)
            {
                return(null); // we don't want to error here. there is an expectation that new items won't be in cache
            }
        }
        public async Task conversion_rate_by_currency()
        {
            //Arrange
            var    baseCurrency = CurrencySymbol.EUR;
            var    toCurrency   = CurrencySymbol.MYR;
            double returnedRate = 4.6982;

            _blob.Get <OrderCloudIntegrationsExchangeRate>(Arg.Any <string>()).ReturnsForAnyArgs(GetExchangeRate(baseCurrency, toCurrency, returnedRate));

            //Act
            var rate = await _command.ConvertCurrency(baseCurrency, toCurrency, 1.33);

            //Assert
            Assert.IsTrue(rate == (1.33 * returnedRate));
        }