Skip to content

Currency conversion Application/API - Exchange rates are based on current foreign exchange rates published by the European Central Bank.

Notifications You must be signed in to change notification settings

maikkkko1/elixir-currency-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Currency conversion Application/API - Exchange rates are based on current foreign exchange rates published by the European Central Bank.

About

The main objective of this application is to provide a way to make currency conversions quickly, simply and based on a secure source.

Dependencies

Installation

Step 1 - Install Elixir

You can follow the installation guide according to your operating system.

Step 2 - Cloning the repository
git clone git@github.com:maikkkko1/elixir-currency-converter.git
Step 3 - Install project dependencies

From the terminal in the project's root folder, run the command:

mix deps.get

If the installation has been successfully completed, the project is ready to be used!

How to use

Elixir's interactive shell (iex)

About the IEX: https://hexdocs.pm/iex/IEx.html

From the terminal in the project's root folder, run the command to enter in the IEX mode:

iex -S mix

handle_conversion/3 - from, to, amount

Converting an amount of 1 BRL to USD, we will have in the current values the following result:

iex(1)> Conversion.handle_conversion("brl", "usd", 1)
{:ok, %{amount_converted: 0.19, amount_to_convert: 1, from: "brl", to: "usd"}}
HTTP Request (API)

To use it via API, it is first necessary to start the HTTP server.

From the terminal in the project's root folder, run the command to start the server:

mix run --no-halt

Now using a client for HTTP requests like Postman or Insomnia, it is possible to make the requests to perform the conversion.

Request params:

  • from - required
  • to - required
  • amount - required

Success request

GET http://localhost:4000/api/conversion?from=brl&to=usd&amount=1

RESPONSE
  {
  "result": {
    "to": "usd",
    "from": "brl",
    "amount_to_convert": "1",
    "amount_converted": 0.19
  },
  "error": null
}

Error request

GET http://localhost:4000/api/conversion?from=brl&to=usd

RESPONSE
  {
  "result": null,
  "error": "Amount is required"
}

Documentation

From the terminal in the project's root folder, run the command to generate modules and functions documentation:

mix docs

The docs folder will be created at the root of the project where all the HTML files with the documentation will be located.

Tests

The project contains some unit tests.

From the terminal in the project's root folder, run the command to run all the unit tests:

mix test

About

Currency conversion Application/API - Exchange rates are based on current foreign exchange rates published by the European Central Bank.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages