aboutsummaryrefslogtreecommitdiff
path: root/src/ppm
diff options
context:
space:
mode:
Diffstat (limited to 'src/ppm')
-rw-r--r--src/ppm/provider.py11
-rw-r--r--src/ppm/providerdb.py8
2 files changed, 18 insertions, 1 deletions
diff --git a/src/ppm/provider.py b/src/ppm/provider.py
index fbbd911..54bc0fe 100644
--- a/src/ppm/provider.py
+++ b/src/ppm/provider.py
@@ -62,6 +62,17 @@ class Provider(object):
else:
return False
+ def get_top_up_code_length(self):
+ """The length of the topup code"""
+ if self.has_top_up_cmd():
+ return self.top_up_cmds['ussd'][2]
+ else:
+ return 0
+
+ @property
+ def top_up_code_length(self):
+ return self.get_top_up_code_length()
+
def fetch_balance(self, mm, reply_func=None, error_func=None):
if self.has_fetch_balance_cmd():
mm.ussd_initiate (self.fetch_balance_cmds['ussd'],
diff --git a/src/ppm/providerdb.py b/src/ppm/providerdb.py
index db2bdc9..e2b097d 100644
--- a/src/ppm/providerdb.py
+++ b/src/ppm/providerdb.py
@@ -90,7 +90,13 @@ class ProviderDB(object):
if t.tag == 'ussd':
sequence = t.text
replacement = t.attrib['replacement']
- provider.add_top_up_cmd({'ussd': [sequence, replacement]})
+ try:
+ length = int(t.attrib['length'])
+ except KeyError:
+ length = 0
+ provider.add_top_up_cmd({'ussd': [sequence,
+ replacement,
+ length]})
if t.tag == 'sms':
number = t.text
text = t.attrib['text']