Skip to content

Commit

Permalink
Merge pull request #109 from carposio/patch-1
Browse files Browse the repository at this point in the history
Update nordigen api base url to GoCardless
  • Loading branch information
tarioch authored Mar 8, 2024
2 parents b559bb1 + d9a545d commit 42c31e0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/tariochbctools/importers/nordigen/nordigen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def check_result(result):

def get_token(secret_id, secret_key):
r = requests.post(
"https://ob.nordigen.com/api/v2/token/new/",
"https://bankaccountdata.gocardless.com/api/v2/token/new/",
data={
"secret_id": secret_id,
"secret_key": secret_key,
Expand All @@ -30,7 +30,7 @@ def get_token(secret_id, secret_key):

def list_bank(token, country):
r = requests.get(
"https://ob.nordigen.com/api/v2/institutions/",
"https://bankaccountdata.gocardless.com/api/v2/institutions/",
params={"country": country},
headers=build_header(token),
)
Expand All @@ -48,7 +48,7 @@ def create_link(token, reference, bank):
print(f"Link for for reference {reference} already exists.") # noqa: T201
else:
r = requests.post(
"https://ob.nordigen.com/api/v2/requisitions/",
"https://bankaccountdata.gocardless.com/api/v2/requisitions/",
data={
"redirect": "http://localhost",
"institution_id": bank,
Expand All @@ -63,23 +63,26 @@ def create_link(token, reference, bank):

def list_accounts(token):
headers = build_header(token)
r = requests.get("https://ob.nordigen.com/api/v2/requisitions/", headers=headers)
r = requests.get(
"https://bankaccountdata.gocardless.com/api/v2/requisitions/", headers=headers
)
print(r.json()) # noqa: T201
check_result(r)
for req in r.json()["results"]:
reference = req["reference"]
print(f"Reference: {reference}") # noqa: T201
for account in req["accounts"]:
ra = requests.get(
f"https://ob.nordigen.com/api/v2/accounts/{account}", headers=headers
f"https://bankaccountdata.gocardless.com/api/v2/accounts/{account}",
headers=headers,
)
check_result(ra)
acc = ra.json()
asp = acc["institution_id"]
iban = acc["iban"]

ra = requests.get(
f"https://ob.nordigen.com/api/v2/accounts/{account}/details",
f"https://bankaccountdata.gocardless.com/api/v2/accounts/{account}/details",
headers=headers,
)
check_result(ra)
Expand All @@ -94,15 +97,17 @@ def delete_link(token, reference):
requisitionId = _find_requisition_id(token, reference)
if requisitionId:
r = requests.delete(
f"https://ob.nordigen.com/api/v2/requisitions/{requisitionId}",
f"https://bankaccountdata.gocardless.com/api/v2/requisitions/{requisitionId}",
headers=build_header(token),
)
check_result(r)


def _find_requisition_id(token, userId):
headers = build_header(token)
r = requests.get("https://ob.nordigen.com/api/v2/requisitions/", headers=headers)
r = requests.get(
"https://bankaccountdata.gocardless.com/api/v2/requisitions/", headers=headers
)
check_result(r)
for req in r.json()["results"]:
if req["reference"] == userId:
Expand Down

0 comments on commit 42c31e0

Please sign in to comment.