Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Added connector functions for recurring and salary transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
shouryaps committed Oct 10, 2019
1 parent 0f37175 commit 6b9771f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions finbox_bankconnect/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,48 @@ def get_accounts(entity_id):
#TODO: log here the response
return "format_changed", None, None
return status, None, None

def get_salary(entity_id):
url = "{}/bank-connect/{}/entity/{}/salary/".format(finbox_bankconnect.base_url, finbox_bankconnect.api_version, entity_id)
headers = { 'x-api-key': finbox_bankconnect.api_key }
response = requests.get(url, headers=headers)
if response.status_code == 404:
return "not_found", None, None, None
elif not response.status_code == 200:
#TODO: log here the response
return "service_failed", None, None, None
response = response.json()
try:
status = get_progress_status(response['progress'])
if status == "completed":
accounts = response['accounts']
fraud_info = response['fraud']['fraud_type']
transactions = response['transactions']
return status, accounts, fraud_info, transactions
except KeyError:
#TODO: log here the response
return "format_changed", None, None, None
return status, None, None, None

def get_recurring(entity_id):
url = "{}/bank-connect/{}/entity/{}/recurring_transactions/".format(finbox_bankconnect.base_url, finbox_bankconnect.api_version, entity_id)
headers = { 'x-api-key': finbox_bankconnect.api_key }
response = requests.get(url, headers=headers)
if response.status_code == 404:
return "not_found", None, None, None, None
elif not response.status_code == 200:
#TODO: log here the response
return "service_failed", None, None, None, None
response = response.json()
try:
status = get_progress_status(response['progress'])
if status == "completed":
accounts = response['accounts']
fraud_info = response['fraud']['fraud_type']
credit_recurring = response['transactions'].get("credit_transactions", [])
debit_recurring = response['transactions'].get("debit_transactions", [])
return status, accounts, fraud_info, credit_recurring, debit_recurring
except KeyError:
#TODO: log here the response
return "format_changed", None, None, None, None
return status, None, None, None, None

0 comments on commit 6b9771f

Please sign in to comment.