Closed yilmaz-burak closed 2 years ago
As a group, we have each created our own little projects by creating distinct endpoints, providing a unique functionality.
I have used a currency converting api, namely currencyconverterapi and by using its features, created a table for conversion rates. User can send a post request to /currency/allConversions
endpoint to get rates between USD
and [USD, EUR, TRY, AZN]
currencies. Similar to this, users can also get the value of a currency in the form of another currency by sending a get request to /currency/getConversion
.
Code can be found within the report folder. I have implemented the currency route (/server/src/routes/currency)
Declares the routes for the /currency. It has getConversion
and allConversions
configured.
Provides the validity checks for requests coming, body of the post request, query parameters etc.
Handles the API requests for the declared routes.
/currency/allConversions
:
allCurrencies
, which is an array of currencies. The function loops over all the items in that array and makes a request to the external api. After the iteration is completed successfully, all the conversion rates are sent to the request origin. If any error is thrown (catch block), sends a 400 to the request origin./currency/getConversion
:
from
, to
and amount
, representing both currencies and a float representing the amount of currency. The function parses the query to get the data and then gets the conversion rate through the external api. After the conversion rate is successfully fetched, multiplies the rate value by the amount, resulting in the amount of currency equivalent to the value of the initial currency. If any error is thrown (catch block), sends a 400 to the request origin.
This file contains the relevant tests for the /currency
endpoints. For each endpoints, 3 cases are given:
\currency
in this pull request. Bilal quickly gave some good feedback and regarding his comments, I have made some changes. It was a quick and painless process.LGTM!
Each member needs to prepare an Individual Report showcasing the work they done with
Deadline: 20.05.2022 @ 23.59