Skip to content

Commit

Permalink
Merge pull request #110 from blaggacao/master
Browse files Browse the repository at this point in the history
feat: add profile to wise for bussiness account
  • Loading branch information
tarioch authored Apr 29, 2024
2 parents 42c31e0 + 3d716eb commit 6d150c1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 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,12 @@ 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 6d150c1

Please sign in to comment.