Consuming REST API fixer.io

0
I would like to retrieve different currencies using fixer.io's REST API. Calling the API works fine, but it fails when displaying the different currencies. The currencies depend on user input. For example, a user can request two currencies: USD and GBP. The call then becomes: http://data.fixer.io/api/latest?access_key={1}&symbols=USD,GBP&format=1 That then results in { "success":true, "timestamp":1651324144, "base":"EUR", "date":"2022-04-30", "rates":{ "USD":1.054463, "GBP":0.838639 } } Now another user can request other currencies. For example CAD, HKD and BTC. The call then becomes: http://data.fixer.io/api/latest?access_key={1}&symbols=CAD,HKD,BTC&format=1 Result: { "success":true, "timestamp":1651324144, "base":"EUR", "date":"2022-04-30", "rates":{ "CAD":1.354273, "HKD":8.273915, "BTC":2.7333513e-5 } } Now I would use a import mapping but I don’t want make an entity in my Domain model for every currency. How can I get this in my domain model in a better way? Thanks in advance!
asked
2 answers
1

Have been playing around with this API and the issue is that the JSON structure has a 1-1 relationship between the root and the list of values, which is actually not a list, but an item with multiple values.

So the only thing I can come up with is the following, which completely depend on how the user can define the specific currencies in the request.

  1. user specifies the request parameters
  2. Run a microflow which calls API and map it to this domain model
  3. Some attributes are set, some are empty
  4. Use the return of the rest call to fetch the Rates object
  5. Extract the values of the attributes based on your request input 
  6. Create an Result object for each specific value
  7. Show something to the user 
answered
0

Thanks!

answered