https://www.amdoren.com/currency-api/
(
from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = ""
)
| 176 | |
| 177 | |
| 178 | def convert_currency( |
| 179 | from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = "" |
| 180 | ) -> str: |
| 181 | """https://www.amdoren.com/currency-api/""" |
| 182 | # Instead of manually generating parameters |
| 183 | params = locals() |
| 184 | # from is a reserved keyword |
| 185 | params["from"] = params.pop("from_") |
| 186 | res = httpx.get(URL_BASE, params=params, timeout=10).json() |
| 187 | return str(res["amount"]) if res["error"] == 0 else res["error_message"] |
| 188 | |
| 189 | |
| 190 | if __name__ == "__main__": |
no test coverage detected