From f7cbb9b3b92d51850d6b0032a62e062dac45fd69 Mon Sep 17 00:00:00 2001 From: sinopsysHK Date: Tue, 1 Oct 2019 12:09:47 +0800 Subject: [PATCH] [americanexpress] get correct accounts currency get correct accounts currency from users session locales rather than static so it works for other currencies than EUR --- modules/americanexpress/browser.py | 5 +++-- modules/americanexpress/pages.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/americanexpress/browser.py b/modules/americanexpress/browser.py index 35e433d6a8..74bd7b64d7 100644 --- a/modules/americanexpress/browser.py +++ b/modules/americanexpress/browser.py @@ -52,7 +52,7 @@ class AmericanExpressBrowser(LoginBrowser): js_posted = URL(r'/account-data/v1/financials/transactions\?limit=1000&offset=(?P\d+)&statement_end_date=(?P[0-9-]+)&status=posted', JsonHistory) js_periods = URL(r'/account-data/v1/financials/statement_periods', JsonPeriods) - currency_page = URL(r'https://www.aexp-static.com/cdaas/axp-app/modules/axp-offers/1.11.1/fr-fr/axp-offers.json', CurrencyPage) + currency_page = URL(r'https://www.aexp-static.com/cdaas/axp-app/modules/axp-balance-summary/4.7.0/(?P\w\w-\w\w)/axp-balance-summary.json', CurrencyPage) no_card = URL(r'https://www.americanexpress.com/us/content/no-card/', r'https://www.americanexpress.com/us/no-card/', NoCardPage) @@ -93,7 +93,8 @@ def get_accounts(self): self.page.set_balances(accounts) # get currency - self.currency_page.go() + loc = self.session.cookies.get_dict(domain=".americanexpress.com")['axplocale'].lower() + self.currency_page.go(locale=loc) currency = self.page.get_currency() for acc in accounts: diff --git a/modules/americanexpress/pages.py b/modules/americanexpress/pages.py index 5c7b59b4f5..80e3d1d016 100644 --- a/modules/americanexpress/pages.py +++ b/modules/americanexpress/pages.py @@ -143,7 +143,7 @@ def set_balances(self, accounts): class CurrencyPage(LoggedPage, JsonPage): def get_currency(self): - return self.doc['currency'] + return self.doc['localeSettings']['currency_code'] class JsonPeriods(LoggedPage, JsonPage): -- GitLab