-
Notifications
You must be signed in to change notification settings - Fork 2
StaticData Core ussage
The best and recommended option is injecting the needed service inside the consumer service, those are the provided services, and information about the different methods could be found clicking on each one. Inside, all methods are allowed like sync and async: There are four different services inside StaticData, all services are internally documented:
- SetCountriesFromApi(countriesFromApi: bool)
Use to set services that could provide data from API or Local repository both, if this parameter is yes, the tool will go to API data to retrieve information instead of local. By default, this property is false Availaible Services that are considering this is ICountryService
- SetBaseCurency(configuredBaseCurrency: string)
Use this method to configure a base currency for comparing ExchangeRates data. By default, USD is configured
- SetConfiguredCurrencies(configuredCurrencies; string[])
Use this method to configure a list of currencies for data services, Availaible methods that are considering this are, inside IExchangeRateService:
- GetConfiguredLatest
- GetConfiguredHistorical
Configuration by default does not configure any currency for data services, but it configures USD as base currency to compare requested ExchangeRates on demand
Getting all countries:
var configuration = new ConfigurationBase();
var countryService = StaticDataServiceFactory.GetCountryService(configuration);
var data = countryService.GetAll();
Getting information of a single country:
var configuration = new ConfigurationBase();
var countryService = StaticDataServiceFactory.GetCountryService(configuration);
var data = countryService.Get("Burkina Faso");
Getting cities of a country
var configuration = new ConfigurationBase();
var cityService = StaticDataServiceFactory.GetCityService(configuration);
var usdData = cityService.Get("Burkina Faso");
Getting all currencies
var configuration = new ConfigurationBase();
var currenciesService = StaticDataServiceFactory.GetCurrencyService(configuration);
var data = currenciesService.GetAll();
Getting exchange rate between dates
var configuration = new ConfigurationBase();
var exchangeRateService = StaticDataServiceFactory.GetExchangeRateService(configuration);
var data = exchangeRateService.Get("EUR", "USD"); //Latest
var dataForDate = exchangeRateService.Get("EUR", "USD", new DateTime(2018, 1, 1)); //Concrete date