first draft implemented

Still struggling at some ingredients which deviating names
This commit is contained in:
2022-07-16 22:20:32 +02:00
parent d9053ebaa4
commit 711a8e5c21
8 changed files with 35 additions and 18 deletions

View File

@@ -21,14 +21,19 @@ public class AmountConversion {
Request request = APIAuthentication.addAuthHeaders(
new Request.Builder()
.url("https://" + dotenv.get("X-RapidAPI-Host") +
"recipes/convert?ingredientName=" + ingrdientName +
"/recipes/convert?ingredientName=" + ingrdientName +
"&targetUnit=" + targetUnit +
"&sourceUnit=" + sourceUnit +
"&sourceAmount=" + sourceAmount)
).build();
Response response = client.newCall(request).execute();
String responseString = response.body().string();
return new ObjectMapper().readValue(responseString, ConvertedAmount.class).getTargetAmount();
try {
return new ObjectMapper().readValue(responseString, ConvertedAmount.class).getTargetAmount();
} catch (Exception e){
return 0;
}
}
}