Merge pull request #37359 from ruthra-kumar/change_request_response_strucutre_on_exchangerate
refactor: add `access_key` field to facilitate use of exchangerate.host provider
This commit is contained in:
commit
c006c14aaa
@ -9,6 +9,7 @@
|
|||||||
"disabled",
|
"disabled",
|
||||||
"service_provider",
|
"service_provider",
|
||||||
"api_endpoint",
|
"api_endpoint",
|
||||||
|
"access_key",
|
||||||
"url",
|
"url",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"help",
|
"help",
|
||||||
@ -84,12 +85,18 @@
|
|||||||
"fieldname": "disabled",
|
"fieldname": "disabled",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Disabled"
|
"label": "Disabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.service_provider == 'exchangerate.host';",
|
||||||
|
"fieldname": "access_key",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Access Key"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-01-09 12:19:03.955906",
|
"modified": "2023-10-04 15:30:25.333860",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Currency Exchange Settings",
|
"name": "Currency Exchange Settings",
|
||||||
|
@ -18,11 +18,21 @@ class CurrencyExchangeSettings(Document):
|
|||||||
|
|
||||||
def set_parameters_and_result(self):
|
def set_parameters_and_result(self):
|
||||||
if self.service_provider == "exchangerate.host":
|
if self.service_provider == "exchangerate.host":
|
||||||
|
|
||||||
|
if not self.access_key:
|
||||||
|
frappe.throw(
|
||||||
|
_("Access Key is required for Service Provider: {0}").format(
|
||||||
|
frappe.bold(self.service_provider)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.set("result_key", [])
|
self.set("result_key", [])
|
||||||
self.set("req_params", [])
|
self.set("req_params", [])
|
||||||
|
|
||||||
self.api_endpoint = "https://api.exchangerate.host/convert"
|
self.api_endpoint = "https://api.exchangerate.host/convert"
|
||||||
self.append("result_key", {"key": "result"})
|
self.append("result_key", {"key": "result"})
|
||||||
|
self.append("req_params", {"key": "access_key", "value": self.access_key})
|
||||||
|
self.append("req_params", {"key": "amount", "value": "1"})
|
||||||
self.append("req_params", {"key": "date", "value": "{transaction_date}"})
|
self.append("req_params", {"key": "date", "value": "{transaction_date}"})
|
||||||
self.append("req_params", {"key": "from", "value": "{from_currency}"})
|
self.append("req_params", {"key": "from", "value": "{from_currency}"})
|
||||||
self.append("req_params", {"key": "to", "value": "{to_currency}"})
|
self.append("req_params", {"key": "to", "value": "{to_currency}"})
|
||||||
|
@ -121,6 +121,7 @@ class TestCurrencyExchange(unittest.TestCase):
|
|||||||
# Update Currency Exchange Rate
|
# Update Currency Exchange Rate
|
||||||
settings = frappe.get_single("Currency Exchange Settings")
|
settings = frappe.get_single("Currency Exchange Settings")
|
||||||
settings.service_provider = "exchangerate.host"
|
settings.service_provider = "exchangerate.host"
|
||||||
|
settings.access_key = "12345667890"
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
# Update exchange
|
# Update exchange
|
||||||
|
Loading…
Reference in New Issue
Block a user