Skip to content

Commit

Permalink
feat: add profile to wise for bussiness account
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Apr 21, 2024
1 parent 42c31e0 commit 820a4f0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/tariochbctools/importers/transferwise/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ def file_account(self, file):
return ""

def __init__(self, *args, **kwargs):
if "profileId" in kwargs:
self.profileId = kwargs.pop("profileId")
if "startDate" in kwargs:
self.startDate = kwargs["startDate"]
self.startDate = kwargs.pop("startDate")
else:
self.startDate = datetime.combine(
date.today() + relativedelta(months=-3),
datetime.min.time(),
timezone.utc,
).isoformat()
if "endDate" in kwargs:
self.endDate = kwargs["endDate"]
self.endDate = kwargs.pop("endDate")
else:
self.endDate = datetime.combine(
date.today(), datetime.max.time(), timezone.utc
Expand Down Expand Up @@ -121,9 +123,10 @@ def extract(self, file, existing_entries):
self.private_key_path = config["privateKeyPath"]

headers = {"Authorization": "Bearer " + self.api_token}
r = requests.get("https://api.transferwise.com/v1/profiles", headers=headers)
profiles = r.json()
self.profileId = profiles[0]["id"]
if not self.profileId:
r = requests.get("https://api.transferwise.com/v1/profiles", headers=headers)
profiles = r.json()
self.profileId = profiles[0]["id"]

r = requests.get(
"https://api.transferwise.com/v1/borderless-accounts",
Expand Down

0 comments on commit 820a4f0

Please sign in to comment.