refactor: parse native JSON request args in erpnext_integrations/doctype/plaid_settings/plaid_settings.py

Use frappe.parse_json instead of json.loads so the whitelisted endpoints
accept native JSON types (list/dict/bool) in addition to JSON strings.
This commit is contained in:
Mihir Kandoi
2026-06-24 20:37:32 +05:30
parent afb2616aee
commit 2e75a4b830

View File

@@ -51,8 +51,8 @@ def get_plaid_configuration():
@frappe.whitelist()
def add_institution(token: str, response: str):
response = json.loads(response)
def add_institution(token: str, response: str | dict):
response = frappe.parse_json(response)
plaid = PlaidConnector()
access_token = plaid.get_access_token(token)
@@ -81,12 +81,11 @@ def add_institution(token: str, response: str):
@frappe.whitelist()
def add_bank_accounts(response: str | dict, bank: str | dict, company: str):
try:
response = json.loads(response)
response = frappe.parse_json(response)
except TypeError:
pass
if isinstance(bank, str):
bank = json.loads(bank)
bank = frappe.parse_json(bank)
result = []
parent_gl_account = frappe.db.get_all(
@@ -358,8 +357,8 @@ def get_company(bank_account_name):
@frappe.whitelist()
def update_bank_account_ids(response: str):
data = json.loads(response)
def update_bank_account_ids(response: str | dict):
data = frappe.parse_json(response)
institution_name = data["institution"]["name"]
bank = frappe.get_doc("Bank", institution_name).as_dict()
bank_account_name = f"{data['account']['name']} - {institution_name}"