--- /dev/null
+import hashlib
+
+def _localname(type):
+ mod = type.__module__
+ if mod.startswith("fulbank."):
+ mod = mod[8:]
+ return "%s.%s" % (mod, type.__name__)
+
+class account(object):
+ @property
+ def number(self): raise NotImplementedError("account.number")
+ @property
+ def name(self): raise NotImplementedError("account.name")
+ def transactions(self): raise NotImplementedError("account.transactions")
+
+ def __repr__(self):
+ return "#<%s %s: %r>" % (_localname(type(self)), self.number, self.name)
+
+class txnaccount(account):
+ @property
+ def balance(self): raise NotImplementedError("txnaccount.balance")
+ @property
+ def clearing(self): raise NotImplementedError("txnaccount.clearing")
+ @property
+ def fullnumber(self): raise NotImplementedError("txnaccount.fullnumber")
+
+class cardaccount(account):
+ pass
+
+class transaction(object):
+ @property
+ def value(self): raise NotImplementedError("transaction.value")
+ @property
+ def message(self): raise NotImplementedError("transaction.message")
+ @property
+ def date(self): raise NotImplementedError("transaction.date")
+
+ @property
+ def hash(self):
+ dig = hashlib.sha256()
+ dig.update(str(self.date.toordinal()).encode("ascii") + b"\0")
+ dig.update(self.message.encode("utf-8") + b"\0")
+ dig.update(str(self.value.amount).encode("ascii") + b"\0")
+ dig.update(self.value.currency.symbol.encode("ascii") + b"\0")
+ return dig.hexdigest()
+
+ def __repr__(self):
+ return "#<%s %s: %r>" % (_localname(type(self)), self.value, self.message)
-import json, http.cookiejar, binascii, time, datetime, pickle, hashlib
+import json, http.cookiejar, binascii, time, datetime, pickle
from urllib import request, parse
from bs4 import BeautifulSoup as soup
-from . import currency, auth
+from . import currency, auth, data
soupify = lambda cont: soup(cont, "html.parser")
apibase = "https://online.swedbank.se/TDE_DAP_Portal_REST_WEB/api/"
def base64(data):
return binascii.b2a_base64(data).decode("ascii").strip().rstrip("=")
-class transaction(object):
+class transaction(data.transaction):
def __init__(self, account, data):
self.account = account
self._data = data
p = time.strptime(resolve(self._data, ("accountingDate",)), self._datefmt)
return datetime.date(p.tm_year, p.tm_mon, p.tm_mday)
- @property
- def hash(self):
- dig = hashlib.sha256()
- dig.update(str(self.date.toordinal()).encode("ascii") + b"\0")
- dig.update(self.message.encode("utf-8") + b"\0")
- dig.update(str(self.value.amount).encode("ascii") + b"\0")
- dig.update(self.value.currency.symbol.encode("ascii") + b"\0")
- return dig.hexdigest()
-
- def __repr__(self):
- return "#<fsb.transaction %s: %r>" % (self.value, self.message)
-
-class txnaccount(object):
+class txnaccount(data.txnaccount):
def __init__(self, sess, id, idata):
self.sess = sess
self.id = id
yield transaction(self, tx)
page += 1
- def __repr__(self):
- return "#<fsb.txnaccount %s: %r>" % (self.fullnumber, self.name)
-
-class cardtransaction(object):
+class cardtransaction(data.transaction):
def __init__(self, account, data):
self.account = account
self._data = data
p = time.strptime(resolve(self._data, ("date",)), self._datefmt)
return datetime.date(p.tm_year, p.tm_mon, p.tm_mday)
- @property
- def hash(self):
- dig = hashlib.sha256()
- dig.update(str(self.date.toordinal()).encode("ascii") + b"\0")
- dig.update(self.message.encode("utf-8") + b"\0")
- dig.update(str(self.value.amount).encode("ascii") + b"\0")
- dig.update(self.value.currency.symbol.encode("ascii") + b"\0")
- return dig.hexdigest()
-
- def __repr__(self):
- return "#<fsb.cardtransaction %s: %r>" % (self.value, self.message)
-
-class cardaccount(object):
+class cardaccount(data.cardaccount):
def __init__(self, sess, id, idata):
self.sess = sess
self.id = id
yield cardtransaction(self, tx)
page += 1
- def __repr__(self):
- return "#<fsb.cardaccount %s: %r>" % (self.number, self.name)
-
class session(object):
def __init__(self, dsid):
self.dsid = dsid