Skip to content

Commit

Permalink
feat: add method to retrieve bank list from API
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugochukwu Onyebuchi committed Mar 7, 2023
1 parent c67354f commit 56d92d9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions decide/models/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import requests
from enum import Enum

BANK_LIST_URL = "https://api.indicina.co/api/v3/banks"


class Currency(Enum):
NGN = "NGN"
Expand Down Expand Up @@ -31,6 +34,15 @@ class Bank(Enum):
UNION = "032"
ZENITH = "057"

@classmethod
def get_bank_list(cls):
response = requests.get(BANK_LIST_URL)
if response.status_code == 200:
bank_list = response.json()['data']
return [(bank['name'], bank['code']) for bank in bank_list]
else:
raise Exception(f"Failed to get bank list. Status code: {response.status_code}")


class StatementType(Enum):
JSON = "json"
Expand Down

0 comments on commit 56d92d9

Please sign in to comment.