From 155bafcc2fbfdef18ec42b6bb4dd3fb16f7bc715 Mon Sep 17 00:00:00 2001 From: Reena Aheer Date: Wed, 5 Apr 2023 11:33:47 +0200 Subject: [PATCH 1/2] Working on API_VERSION --- apimanager/apimanager/settings.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apimanager/apimanager/settings.py b/apimanager/apimanager/settings.py index 42ceada..8798bf5 100644 --- a/apimanager/apimanager/settings.py +++ b/apimanager/apimanager/settings.py @@ -258,8 +258,8 @@ API_HOST = 'http://127.0.0.1:8080' API_EXPLORER_HOST = 'http://127.0.0.1:8082' # Only override this if you have a separate portal instance API_PORTAL = API_HOST -API_BASE_PATH = '/obp/v' -API_VERSION = '5.1.0' +API_BASE_PATH = '/obp/' +#API_VERSION = '5.1.0' # URL to API Tester API_TESTER_URL = 'https://www.example.com' @@ -318,10 +318,11 @@ except ImportError: # DO NOT TRY TO DO SO YOU WILL BE IGNORED! # Settings here might use parts overwritten in local settings -API_ROOT = API_HOST + API_BASE_PATH + API_VERSION +#API_ROOT = API_HOST + API_BASE_PATH + API_VERSION +API_ROOT = API_HOST + API_BASE_PATH # For some reason, swagger is not available at the latest API version -API_URL_SWAGGER = API_HOST + '/obp/v1.4.0/resource-docs/v' + API_VERSION + '/swagger' # noqa - +#API_URL_SWAGGER = API_HOST + '/obp/v1.4.0/resource-docs/v' + API_VERSION + '/swagger' # noqa +API_URL_SWAGGER = API_HOST + '/obp/v1.4.0/resource-docs/v5.1.0/swagger' # noqa if not OAUTH_CONSUMER_KEY: raise ImproperlyConfigured('Missing settings for OAUTH_CONSUMER_KEY') if not OAUTH_CONSUMER_SECRET: From 822f3e6b5c3beee632140c946ad07db0a1023b0c Mon Sep 17 00:00:00 2001 From: Reena Aheer Date: Wed, 5 Apr 2023 15:17:05 +0200 Subject: [PATCH 2/2] hard coded API_VERSION --- apimanager/accountlist/views.py | 4 ++-- apimanager/banks/views.py | 2 +- apimanager/base/context_processors.py | 2 +- apimanager/obp/api.py | 2 +- apimanager/obp/views.py | 2 +- apimanager/systemviews/views.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apimanager/accountlist/views.py b/apimanager/accountlist/views.py index 156c905..fc5e5a7 100644 --- a/apimanager/accountlist/views.py +++ b/apimanager/accountlist/views.py @@ -27,7 +27,7 @@ class AccountListView(IndexAccountsView, LoginRequiredMixin, FormView ): #self.bankids = self.get_banks() accounts_list = [] #for bank_id in self.bankids: - urlpath = '/my/accounts' + urlpath = 'v5.1.0/my/accounts' result = api.get(urlpath) if 'accounts' in result: accounts_list.extend(result['accounts']) @@ -55,7 +55,7 @@ class ExportCsvView(LoginRequiredMixin, View): self.bankids = get_banks(self.request) accounts_list = [] for bank_id in self.bankids: - urlpath = 'banks/{}/accounts'.format(bank_id) + urlpath = 'v5.1.0/banks/{}/accounts'.format(bank_id) result = api.get(urlpath) if 'accounts' in result: accounts_list.extend(result['accounts']) diff --git a/apimanager/banks/views.py b/apimanager/banks/views.py index c2e8f95..69cde1d 100644 --- a/apimanager/banks/views.py +++ b/apimanager/banks/views.py @@ -44,7 +44,7 @@ class IndexBanksView(LoginRequiredMixin, FormView): def form_valid(self, form): try: data = form.cleaned_data - urlpath = '/banks' + urlpath = 'v5.1.0/banks' payload ={ "id": data["bank_id"], "bank_code": data["bank_code"], diff --git a/apimanager/base/context_processors.py b/apimanager/base/context_processors.py index 1169fdc..12801b7 100644 --- a/apimanager/base/context_processors.py +++ b/apimanager/base/context_processors.py @@ -9,7 +9,7 @@ from django.contrib import messages from obp.api import API, APIError, LOGGER from django.core.cache import cache -USER_CURRENT = "/users/current" +USER_CURRENT = "v5.1.0/users/current" def api_root(request): """Returns the configured API_ROOT""" diff --git a/apimanager/obp/api.py b/apimanager/obp/api.py index 5f976fc..28abcbb 100644 --- a/apimanager/obp/api.py +++ b/apimanager/obp/api.py @@ -156,7 +156,7 @@ class API(object): def get_bank_id_choices(self): """Gets a list of bank ids and bank ids as used by form choices""" choices = [('', _('Choose ...'))] - result = self.get('/banks') + result = self.get('v5.1.0/banks') for bank in sorted(result['banks'], key=lambda d: d['id']) : choices.append((bank['id'], bank['id'])) return choices diff --git a/apimanager/obp/views.py b/apimanager/obp/views.py index 8130bce..80ae0dd 100644 --- a/apimanager/obp/views.py +++ b/apimanager/obp/views.py @@ -29,7 +29,7 @@ class LoginToDjangoMixin(object): # Here, we already get the Token for the api call. api = API(self.request.session.get('obp')) try: - data = api.get('/users/current') + data = api.get('v5.1.0/users/current') except APIError as err: messages.error(self.request, err) except Exception as err: diff --git a/apimanager/systemviews/views.py b/apimanager/systemviews/views.py index d247479..8e86bf0 100644 --- a/apimanager/systemviews/views.py +++ b/apimanager/systemviews/views.py @@ -23,7 +23,7 @@ class SystemView(LoginRequiredMixin, FormView): api = API(self.request.session.get('obp')) try: system_view = [] - urlpath = '/system-views/owner' + urlpath = 'v5.1.0/system-views/owner' result = api.get(urlpath) system_view = result except APIError as err: