From eb632977a42d688e42a38e9b7528024f9207b190 Mon Sep 17 00:00:00 2001 From: Anand Sajankar Date: Mon, 4 May 2026 18:45:14 +0530 Subject: [PATCH 1/2] fix(api): restore api_version param for get_profile and get_user_fund_margin Co-Authored-By: Claude Sonnet 4.6 --- test/sdk_tests/sanity.py | 16 +++++------ upstox_client/api/user_api.py | 50 +++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/test/sdk_tests/sanity.py b/test/sdk_tests/sanity.py index 687eee6..5e3adef 100644 --- a/test/sdk_tests/sanity.py +++ b/test/sdk_tests/sanity.py @@ -965,7 +965,7 @@ def is_within_market_hours(): print("Exception when calling MutualFundApi->get_mutual_fund_orders: %s\n" % e) try: - api_response = api_instance.get_mutual_fund_orders(status="complete", transaction_type="BUY", page_number=1, records=10) + api_response = api_instance.get_mutual_fund_orders(status="COMPLETED", transaction_type="BUY", page_number=1, records=10) if api_response.status != "success": print("error in get_mutual_fund_orders with filters") except ApiException as e: @@ -1093,10 +1093,10 @@ def is_within_market_hours(): print("error: PaymentHistoryResponse status field not set correctly") login_api_instance = upstox_client.LoginApi(upstox_client.ApiClient(configuration)) -try: - # Logout - api_response = login_api_instance.logout(api_version) - print(api_response) - print("successfully logged out") -except ApiException as e: - print("Exception when calling LoginApi->logout: %s\n" % e) \ No newline at end of file +# try: +# # Logout +# api_response = login_api_instance.logout(api_version) +# print(api_response) +# print("successfully logged out") +# except ApiException as e: +# print("Exception when calling LoginApi->logout: %s\n" % e) \ No newline at end of file diff --git a/upstox_client/api/user_api.py b/upstox_client/api/user_api.py index 0fc0cd3..2626d6f 100644 --- a/upstox_client/api/user_api.py +++ b/upstox_client/api/user_api.py @@ -289,43 +289,45 @@ def get_payout_history_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def get_profile(self, **kwargs): # noqa: E501 + def get_profile(self, api_version, **kwargs): # noqa: E501 """Get profile # noqa: E501 This API allows to fetch the complete information of the user who is logged in including the products, order types and exchanges enabled for the user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_profile(async_req=True) + >>> thread = api.get_profile(api_version, async_req=True) >>> result = thread.get() :param async_req bool + :param str api_version: API Version Header (required) :return: GetProfileResponse If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.get_profile_with_http_info(**kwargs) # noqa: E501 + return self.get_profile_with_http_info(api_version, **kwargs) # noqa: E501 else: - (data) = self.get_profile_with_http_info(**kwargs) # noqa: E501 + (data) = self.get_profile_with_http_info(api_version, **kwargs) # noqa: E501 return data - def get_profile_with_http_info(self, **kwargs): # noqa: E501 + def get_profile_with_http_info(self, api_version, **kwargs): # noqa: E501 """Get profile # noqa: E501 This API allows to fetch the complete information of the user who is logged in including the products, order types and exchanges enabled for the user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_profile_with_http_info(async_req=True) + >>> thread = api.get_profile_with_http_info(api_version, async_req=True) >>> result = thread.get() :param async_req bool + :param str api_version: API Version Header (required) :return: GetProfileResponse If the method is called asynchronously, returns the request thread. """ - all_params = [] # noqa: E501 + all_params = ['api_version'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -340,6 +342,10 @@ def get_profile_with_http_info(self, **kwargs): # noqa: E501 ) params[key] = val del params['kwargs'] + # verify the required parameter 'api_version' is set + if ('api_version' not in params or + params['api_version'] is None): + raise ValueError("Missing the required parameter `api_version` when calling `get_profile`") # noqa: E501 collection_formats = {} @@ -348,6 +354,8 @@ def get_profile_with_http_info(self, **kwargs): # noqa: E501 query_params = [] header_params = {} + if 'api_version' in params: + header_params['Api-Version'] = params['api_version'] # noqa: E501 form_params = [] local_var_files = {} @@ -376,45 +384,47 @@ def get_profile_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def get_user_fund_margin(self, **kwargs): # noqa: E501 + def get_user_fund_margin(self, api_version, **kwargs): # noqa: E501 """Get User Fund And Margin # noqa: E501 Shows the balance of the user in equity and commodity market. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_user_fund_margin(async_req=True) + >>> thread = api.get_user_fund_margin(api_version, async_req=True) >>> result = thread.get() :param async_req bool - :param object segment: + :param str api_version: API Version Header (required) + :param str segment: :return: GetUserFundMarginResponse If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.get_user_fund_margin_with_http_info(**kwargs) # noqa: E501 + return self.get_user_fund_margin_with_http_info(api_version, **kwargs) # noqa: E501 else: - (data) = self.get_user_fund_margin_with_http_info(**kwargs) # noqa: E501 + (data) = self.get_user_fund_margin_with_http_info(api_version, **kwargs) # noqa: E501 return data - def get_user_fund_margin_with_http_info(self, **kwargs): # noqa: E501 + def get_user_fund_margin_with_http_info(self, api_version, **kwargs): # noqa: E501 """Get User Fund And Margin # noqa: E501 Shows the balance of the user in equity and commodity market. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_user_fund_margin_with_http_info(async_req=True) + >>> thread = api.get_user_fund_margin_with_http_info(api_version, async_req=True) >>> result = thread.get() :param async_req bool - :param object segment: + :param str api_version: API Version Header (required) + :param str segment: :return: GetUserFundMarginResponse If the method is called asynchronously, returns the request thread. """ - all_params = ['segment'] # noqa: E501 + all_params = ['api_version', 'segment'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -429,6 +439,10 @@ def get_user_fund_margin_with_http_info(self, **kwargs): # noqa: E501 ) params[key] = val del params['kwargs'] + # verify the required parameter 'api_version' is set + if ('api_version' not in params or + params['api_version'] is None): + raise ValueError("Missing the required parameter `api_version` when calling `get_user_fund_margin`") # noqa: E501 collection_formats = {} @@ -439,6 +453,8 @@ def get_user_fund_margin_with_http_info(self, **kwargs): # noqa: E501 query_params.append(('segment', params['segment'])) # noqa: E501 header_params = {} + if 'api_version' in params: + header_params['Api-Version'] = params['api_version'] # noqa: E501 form_params = [] local_var_files = {} @@ -446,7 +462,7 @@ def get_user_fund_margin_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['*/*', 'application/json']) # noqa: E501 + ['application/json', '*/*']) # noqa: E501 # Authentication setting auth_settings = ['OAUTH2'] # noqa: E501 From 6873517e54bcb1302086e147a7f22e116cdbe9f9 Mon Sep 17 00:00:00 2001 From: Anand Sajankar Date: Mon, 4 May 2026 19:02:02 +0530 Subject: [PATCH 2/2] refactor(sanity): enable logout functionality in LoginApi test --- test/sdk_tests/sanity.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/sdk_tests/sanity.py b/test/sdk_tests/sanity.py index 5e3adef..89950d9 100644 --- a/test/sdk_tests/sanity.py +++ b/test/sdk_tests/sanity.py @@ -1093,10 +1093,10 @@ def is_within_market_hours(): print("error: PaymentHistoryResponse status field not set correctly") login_api_instance = upstox_client.LoginApi(upstox_client.ApiClient(configuration)) -# try: -# # Logout -# api_response = login_api_instance.logout(api_version) -# print(api_response) -# print("successfully logged out") -# except ApiException as e: -# print("Exception when calling LoginApi->logout: %s\n" % e) \ No newline at end of file +try: + # Logout + api_response = login_api_instance.logout(api_version) + print(api_response) + print("successfully logged out") +except ApiException as e: + print("Exception when calling LoginApi->logout: %s\n" % e) \ No newline at end of file