Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

StaticData Core ussage

Xavi Rueda edited this page Oct 23, 2018 · 7 revisions

Installation

Search ChustaSoft.Services.StaticData on NuGet public gallery

Configuration

ConfigurationBase class on ChustaSoft.Services.StaticData.Base namespace has the default configuration, it is only needed to create one configuration that could be configured, but it is optional. The configurable possibilities are:

  • 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

Use

There are four different services inside StaticData, all services are internally documented:

Examples

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

Clone this wiki locally