Adding subscription (with plans) interface

legacy
Steve L. Nyemba 8 years ago
parent 1a3173f2ee
commit 684ad0ccab

@ -76,6 +76,24 @@ def get_plan_info(app_name) :
if pid is not None : if pid is not None :
plans = [item['metadata'] for item in plans if item['id'] == pid] plans = [item['metadata'] for item in plans if item['id'] == pid]
return json.dumps(plans) return json.dumps(plans)
@app.route('/get/sub/<app_name>')
def get_sub_info(app_name):
uid = request.headers['uid']
pid = request.headers['pid'] if 'pid' in request.headers else None
couchdb = CouchdbReader(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
info = couchdb.read()
lsub = info['subscriptions']
#
# @TODO: Return critical information only i.e:
# - subscription state (dates,status)
# - how much is owed
# - subscription id
#
if pid is not None:
subs = [ sub for sub in lsub if sub['plan']['id'] == pid ]
else:
subs = lsub
return json.dumps(subs)
@app.route('/subscribe/<name>',methods=['DELETE']) @app.route('/subscribe/<name>',methods=['DELETE'])
def cancel_subscribe(name) : def cancel_subscribe(name) :

Loading…
Cancel
Save