Skip to content

Latest commit

 

History

History
173 lines (145 loc) · 6.66 KB

README.md

File metadata and controls

173 lines (145 loc) · 6.66 KB

Currency Fetcher

Currency Fetcher is Web API project to fetch data from https://sdw-wsrest.ecb.europa.eu/help/ web service and generate currency information based on

  • The currency being measured (e.g.: US dollar - code USD),
  • The currency against which a currency is being measured (e.g.: Euro - code EUR),
  • With range of dates

To set up web service read below informations:

Project code overview

Installation

  1. To set up web service change connection strings value in localizations:
  • {path_to_repo}/webAPI/CurrencyFetcherApi/CurrencyFetcherApi/appsettings.json
  • change ConnectionString value into own database connection string
  • Provide the connection string in second localization:
$ {path_to_repo}/webAPI/CurrencyFetcherApi/CurrencyFetcherApi/NLog.config

in node:

$ targets/target.connectionString

This configures nlog logger to save logs into database

  1. Install dotnet ef tool. The installation link is below: https://docs.microsoft.com/pl-pl/ef/core/miscellaneous/cli/dotnet

  2. Run any common line terminal tool and move to directory: {path_to_repo}/webAPI/CurrencyFetcherApi/CurrencyFetcher.Core/

  3. Run command:

$ dotnet ef database update

After that scripts will create database and configure it to use web service. Run application with any c# editor like Visual Studio 2019 and on screen will be show Swagger UI to help communicate with web api service

  • Default authentication for generate JWT Token is
$ Username=> currency
$ Password=> Currency123)(*

Web API Endpoints:

  1. /api/Token
  • method: POST
  • in default token expires in 7 hours
  • this can be change in appsettings file -> appsettings (Jwt.ExpiresInHours)
  • example of body:
{
  "Username": "currency",
  "Password": "Currency123)(*"
}
  • example of response:
{
  "token": "eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjZjdhZDViMC05Y2Y5LTRjYjktOGYyOS0wZTgyOTdmMGVlMzciLCJqdGkiOiJmOWIzZjExYi1lODI4LTQyODktYjM0OC1iNzRiYzRjMWUxZDkiLCJleHAiOjE1ODg3MDU5MDYsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0OjQ0MzE3IiwiYXVkIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NDQzMTcifQ.LCK99o3Fd8IviunPAbL2qWxXwSnTvA1C7X9l6ctRuO0"
}
  1. /api/Currency
  • method: POST
  • example of body:
{
  "CurrencyCodes": {
    "PLN": "EUR",
    "USD": "EUR",
    "NOK": "EUR"
  },
"StartDate": "2010-05-28",
"EndDate": "2010-06-30",
"apiKey": "secret token string"
}
  • example of response:
[
  {
    "currencyBeingMeasured": "PLN",
    "currencyMatched": "EUR",
    "currencyValue": 3.99,
    "dailyDataOfCurrency": "2010-05-14T00:00:00"
  },
  {
    "currencyBeingMeasured": "PLN",
    "currencyMatched": "EUR",
    "currencyValue": 4.02,
    "dailyDataOfCurrency": "2010-05-17T00:00:00"
  },
  {
    "currencyBeingMeasured": "PLN",
    "currencyMatched": "EUR",
    "currencyValue": 4,
    "dailyDataOfCurrency": "2010-05-18T00:00:00"
  },
  {
    "currencyBeingMeasured": "PLN",
    "currencyMatched": "EUR",
    "currencyValue": 4.08,
    "dailyDataOfCurrency": "2010-05-19T00:00:00"
  },
  {
    "currencyBeingMeasured": "PLN",
    "currencyMatched": "EUR",
    "currencyValue": 4.19,
    "dailyDataOfCurrency": "2010-05-20T00:00:00"
  }
]

Techechnologies used in this project

Dillinger uses a number of open source projects to work properly:

  • ASP.NET Core 3.1 - The better vesion of MVC 5
  • Entity Framework - The data access technology that provide functionality to work with database with linq queries
  • Entity Framework Migrations - The solution to provide migrations that can build databases by code
  • Sql Server - The great database engine provide fexibility and is excelent to work with Enity Framework
  • JWT - JSON web token to provide login functionality
  • nlog - To better create logger functionlity in service
  • nUnit - The ane of the best solution for creating unit tests
  • Moq - To mock interfaces as testing object in test scenarioes
  • Swagger - To better tests service by Swagger UI

License

apache 2.0

Free Software, Hell Yeah!