Exemplo n.º 1
0
 public TaxTaxJarController(ICountryService countryService,
                            ILocalizationService localizationService,
                            ISettingService settingService,
                            TaxJarSettings taxJarSettings)
 {
     this._countryService      = countryService;
     this._localizationService = localizationService;
     this._settingService      = settingService;
     this._taxJarSettings      = taxJarSettings;
 }
Exemplo n.º 2
0
        public TaxJarClient(ILogger <TaxJarClient> logger, HttpClient httpClient,
                            IOptions <TaxJarSettings> taxJarSettings)
        {
            _logger         = logger;
            _httpClient     = httpClient;
            _taxJarSettings = taxJarSettings.Value;

            if (_taxJarSettings == null || string.IsNullOrEmpty(_taxJarSettings.ApiKey))
            {
                throw new Exception($"TaxJarSettings is not configured or Api Key is missing");
            }

            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _taxJarSettings.ApiKey);
            _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        }