public EnvironmentSeedCommand(
            AppSettings settings,
            IPortalService portal,
            IHSSupplierCommand supplierCommand,
            IHSBuyerCommand buyerCommand,
            IHSBuyerLocationCommand buyerLocationCommand,
            IOrderCloudClient oc,
            IExchangeRatesCommand exhangeRates
            )
        {
            _settings             = settings;
            _portal               = portal;
            _supplierCommand      = supplierCommand;
            _buyerCommand         = buyerCommand;
            _buyerLocationCommand = buyerLocationCommand;
            _oc           = oc;
            _exhangeRates = exhangeRates;
            var translationsConfig = new BlobServiceConfig()
            {
                ConnectionString = _settings.BlobSettings.ConnectionString,
                Container        = _settings.BlobSettings.ContainerNameTranslations
            };

            _translationsBlob = new OrderCloudIntegrationsBlobService(translationsConfig);
        }
        public void Setup()
        {
            mockBlob = Substitute.For <IOrderCloudIntegrationsBlobService>();

            //mockBlob.Get().ReturnsForAnyArgs(Serializ)
            _command = new ExchangeRatesCommand(mockBlob, new PerBaseUrlFlurlClientFactory(), new MockCachingService());
        }
 public void Setup()
 {
     _http = new HttpTest();
     _http.RespondWith(@"{'rates':{'CAD':1.5231,'HKD':8.3693,'ISK':157.5,'PHP':54.778,'DKK':7.4576,'HUF':354.7,'CZK':27.589,'AUD':1.6805,'RON':4.84,'SEK':10.6695,'IDR':16127.82,'INR':81.9885,'BRL':6.3172,'RUB':79.6208,'HRK':7.5693,'JPY':115.53,'THB':34.656,'CHF':1.0513,'SGD':1.5397,'PLN':4.565,'BGN':1.9558,'TRY':7.4689,'CNY':7.6759,'NOK':11.0568,'NZD':1.8145,'ZAR':20.0761,'USD':1.0798,'MXN':25.8966,'ILS':3.8178,'GBP':0.88738,'KRW':1332.6,'MYR':4.6982},'base':'EUR','date':'2020-05-15'}");
     //_http.RespondWith(@"{'rates':{'MYR':4.6982},'base':'EUR','date':'2020-05-15'}");
     _blob    = Substitute.For <IOrderCloudIntegrationsBlobService>();
     _command = new ExchangeRatesCommand(_blob, new PerBaseUrlFlurlClientFactory(), new MockCachingService());
 }
Esempio n. 4
0
 public Currency(AppSettings settings, IFlurlClientFactory flurlFactory, IAppCache cache)
 {
     _command = new ExchangeRatesCommand(new BlobServiceConfig()
     {
         ConnectionString = settings.BlobSettings.ConnectionString,
         Container        = settings.BlobSettings.ContainerNameExchangeRates
     }, flurlFactory, cache);
 }
 public CheckoutIntegrationCommand(IAvalaraCommand avalara, IExchangeRatesCommand exchangeRates, IOrderCloudClient orderCloud, IEasyPostShippingService shippingService, AppSettings settings)
 {
     _avalara         = avalara;
     _exchangeRates   = exchangeRates;
     _oc              = orderCloud;
     _shippingService = shippingService;
     _settings        = settings;
     _profiles        = new HSShippingProfiles(_settings);
 }
 public CheckoutIntegrationCommand(IDiscountDistributionService discountDistribution, ITaxCalculator taxCalculator, IExchangeRatesCommand exchangeRates, IOrderCloudClient orderCloud, IEasyPostShippingService shippingService, AppSettings settings)
 {
     _taxCalculator        = taxCalculator;
     _exchangeRates        = exchangeRates;
     _oc                   = orderCloud;
     _shippingService      = shippingService;
     _settings             = settings;
     _discountDistribution = discountDistribution;
     _profiles             = new HSShippingProfiles(_settings);
 }
Esempio n. 7
0
 public MeProductCommand(
     IOrderCloudClient elevatedOc,
     IHSBuyerCommand hsBuyerCommand,
     IHSProductCommand hsProductCommand,
     ISendgridService sendgridService,
     ISimpleCache cache,
     IExchangeRatesCommand exchangeRatesCommand
     )
 {
     _oc                   = elevatedOc;
     _hsBuyerCommand       = hsBuyerCommand;
     _hsProductCommand     = hsProductCommand;
     _sendgridService      = sendgridService;
     _cache                = cache;
     _exchangeRatesCommand = exchangeRatesCommand;
 }
Esempio n. 8
0
 public EnvironmentSeedCommand(
     AppSettings settings,
     IPortalService portal,
     IHSSupplierCommand supplierCommand,
     IHSBuyerCommand buyerCommand,
     IHSBuyerLocationCommand buyerLocationCommand,
     IOrderCloudClient oc,
     IExchangeRatesCommand exhangeRates
     )
 {
     _portal               = portal;
     _supplierCommand      = supplierCommand;
     _buyerCommand         = buyerCommand;
     _buyerLocationCommand = buyerLocationCommand;
     _oc           = oc;
     _exhangeRates = exhangeRates;
     _settings     = settings;
 }
 public HSExchangeRatesService(IOrderCloudClient oc, IExchangeRatesCommand exchangeRatesCommand)
 {
     _oc = oc;
     _exchangeRatesCommand = exchangeRatesCommand;
 }
 public ExchangeRatesController(IExchangeRatesCommand command)
 {
     _command = command;
 }
Esempio n. 11
0
 public ExchangeRatesController(AppSettings settings, IExchangeRatesCommand command) : base(settings)
 {
     _command = command;
 }
        public static async Task <IList <HSShipEstimate> > ConvertCurrency(this IList <HSShipEstimate> shipEstimates, CurrencySymbol shipperCurrency, CurrencySymbol buyerCurrency, IExchangeRatesCommand _exchangeRates)
        {
            // If the Buyer's currency is USD, do not convert rates.
            if (buyerCurrency == CurrencySymbol.USD)
            {
                return(shipEstimates);
            }
            ;

            var rates          = (await _exchangeRates.Get(buyerCurrency)).Rates;
            var conversionRate = rates.Find(r => r.Currency == shipperCurrency).Rate;

            return(shipEstimates.Select(estimate =>
            {
                estimate.ShipMethods = estimate.ShipMethods.Select(method =>
                {
                    method.xp.OriginalCurrency = shipperCurrency;
                    method.xp.OrderCurrency = buyerCurrency;
                    method.xp.ExchangeRate = conversionRate;
                    if (conversionRate != null)
                    {
                        method.Cost /= (decimal)conversionRate;
                    }
                    return method;
                }).ToList();
                return estimate;
            }).ToList());
        }