From 61abf795c36b2df5cf84f3c5afab55cc893b7df4 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 1 Feb 2023 10:32:05 +0000 Subject: [PATCH] update clear --- openbb_terminal/account/account_controller.py | 2 +- openbb_terminal/session/hub_model.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/openbb_terminal/account/account_controller.py b/openbb_terminal/account/account_controller.py index 7b3a71d385b..337ff7a6513 100644 --- a/openbb_terminal/account/account_controller.py +++ b/openbb_terminal/account/account_controller.py @@ -160,7 +160,7 @@ class AccountController(BaseController): ) if i.lower() in ["y", "yes"]: console.print("") - Hub.clear_user_configs(auth_header=User.get_auth_header()) + Hub.clear_user_configs() else: console.print("\nAborted.", style="info") diff --git a/openbb_terminal/session/hub_model.py b/openbb_terminal/session/hub_model.py index 3eae067f918..77d0ed30519 100644 --- a/openbb_terminal/session/hub_model.py +++ b/openbb_terminal/session/hub_model.py @@ -176,7 +176,12 @@ def fetch_user_configs( def patch_user_configs( - key: str, value: str, type_: str, base_url: str = BASE_URL, timeout: int = TIMEOUT + key: str, + value: str, + type_: str, + auth_header: str, + base_url: str = BASE_URL, + timeout: int = TIMEOUT, ) -> Optional[requests.Response]: """Patch user configurations to the server. @@ -188,6 +193,8 @@ def patch_user_configs( The value to patch. type_ : str The type of the patch, either "keys" or "settings". + auth_header : str + The authorization header. base_url : str The base url, by default BASE_URL timeout : int @@ -208,7 +215,7 @@ def patch_user_configs( try: response = requests.patch( url=base_url + "terminal/user-json", - headers={"Authorization": User.get_auth_header()}, + headers={"Authorization": auth_header}, json=data, timeout=timeout, ) @@ -229,16 +236,16 @@ def patch_user_configs( def clear_user_configs( - auth_header: str, base_url: str = BASE_URL, timeout: int = TIMEOUT + base_url: str = BASE_URL, auth_header: Optional[str] = None, timeout: int = TIMEOUT ) -> Optional[requests.Response]: """Clear user configurations to the server. Parameters ---------- - auth_header : str - The authorization header. base_url : str The base url, by default BASE_URL + auth_header : Optional[str] + The authorization header, by default None timeout : int The timeout, by default TIMEOUT @@ -247,6 +254,8 @@ def clear_user_configs( Optional[requests.Response] The response from the put request. """ + auth_header = User.get_auth_header() if auth_header is None else auth_header + data: Dict[str, dict] = {"features_keys": {}, "features_settings": {}} try: