Skip to content

Challenge Based Learning (CBL) provides an efficient and effective framework for learning while solving real-world challenges.

License

Notifications You must be signed in to change notification settings

jonnrib/challenge-one-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Currency Converter MIT License Java Version 6+ GSON v2.10.1

Description

This project implements a simple currency converter in Java, using the Exchange Rate API to obtain updated exchange rates and Maven for dependency management.

Technologies

  • Java: Programming language used for development.
  • Maven: Automation tool for building and dependency management.
  • Gson: Library for converting Java objects to JSON and vice-versa.
  • Exchange Rate API: Provides real-time currency exchange rate data. More information can be found at Exchange Rate API.

Configuration

To run this project, you will need:

  1. Install Java JDK if it is not already installed. Download JDK
  2. Install Maven if it is not already installed. Install Maven
  3. Clone this repository or download the files to your local machine.
  4. Open the project in IntelliJ IDEA or another IDE of your choice that supports Maven.
  5. Run mvn clean install to install dependencies.
  6. Obtain a free API key from Exchange Rate API and configure it in your project.
  7. Run the project using the command mvn exec:java -Dexec.mainClass=CurrencyConverter or through your IDE.

Exchange Rate API Quick Start

1. Sign up to get your API key

Your API key will be active & enabled after email confirmation.

2. Make a GET request

No client library required - just use cURL or the HTTP library in your development environment. See the documentation for the currency conversion API endpoint URLs & formats.

3. Parse the JSON response

The response you've received can be parsed by your development environment's JSON library. You're done! Use the fresh exchange rate data to convert currencies in your application with ease.

Usage Guide

To use the Standard endpoint simply make the two substitutions explained below and then send a GET request:

  • Substitute YOUR-API-KEY with the API key displayed in your dashboard.
  • Substitute USD with the code you want to use as a base currency.

The API uses ISO 4217 Three Letter Currency Codes - e.g. USD for US Dollars, EUR for Euro etc. Here are the codes we support.

Example GET request:

GET https://v6.exchangerate-api.com/v6/YOUR-API-KEY/latest/USD

This will return the exchange rates from your base code to all the other currencies they support:

{
    "result": "success",
    "documentation": "https://www.exchangerate-api.com/docs",
    "terms_of_use": "https://www.exchangerate-api.com/terms",
    "time_last_update_unix": 1585267200,
    "time_last_update_utc": "Fri, 27 Mar 2020 00:00:00 +0000",
    "time_next_update_unix": 1585353700,
    "time_next_update_utc": "Sat, 28 Mar 2020 00:00:00 +0000",
    "base_code": "USD",
    "conversion_rates": {
        "USD": 1,
        "AUD": 1.4817,
        "BGN": 1.7741,
        "CAD": 1.3168,
        "CHF": 0.9774,
        "CNY": 6.9454,
        "EGP": 15.7361,
        "EUR": 0.9013,
        "GBP": 0.7679,
        "EUR": 0.9013,
        "GBP": 0.7679,
        "...": 7.8536,
        "...": 1.3127,
        "...": 7.4722,
        "etc.": "etc."
    }
}

Error Responses

{
    "result": "error",
    "error-type": "unknown-code"
}

Where "error-type" can be any of the following:

  • "unsupported-code" if they don't support the supplied currency code (see supported currencies).
  • "malformed-request" when some part of your request doesn't follow the structure shown above.
  • "invalid-key" when your API key is not valid.
  • "inactive-account" if your email address wasn't confirmed.
  • "quota-reached" when your account has reached the number of requests allowed by your plan.

Contributions

Contributions are welcome. To contribute:

  1. Fork the project.
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Jonnathan Ribeiro - [email protected]

Project Link: https://github.com/jonnrib/challenge-one-converter

About

Challenge Based Learning (CBL) provides an efficient and effective framework for learning while solving real-world challenges.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages