You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
import store
|
|
import stripe
|
|
import json
|
|
import os
|
|
import pandas as pd
|
|
import healthcareio
|
|
|
|
def copyright(**_args):
|
|
return [store.__name__,store.__version__]
|
|
def init (**_args):
|
|
_path = _args['config']['system']['source']['store']
|
|
if not store.isready() :
|
|
if os.path.exists(_path) :
|
|
f = open(_path)
|
|
_info = json.loads(f.read())
|
|
f.close()
|
|
store.init(_info['secret'])
|
|
return "1"
|
|
else:
|
|
return "0"
|
|
else:
|
|
return "1"
|
|
def plans (**_args) :
|
|
"""
|
|
This function will return plans associated with a product
|
|
"""
|
|
_config = _args['config']
|
|
if not store.isready() :
|
|
print (['Initializing Store'])
|
|
init(config = _config)
|
|
|
|
_plans = store.get.plans('healthcareio')
|
|
_df = {}
|
|
columns = [_plan['nickname'] for _plan in _plans if _plan['active']]
|
|
pricing = [ '/'.join([str(_plan['unit_amount']/100),_plan['recurring']['interval']]) if _plan['unit_amount'] else 'FREE' for _plan in _plans if _plan['active']]
|
|
_features = [json.loads(_plan['metadata']['features']) for _plan in _plans if _plan['active']]
|
|
|
|
_key = list(set(['community','free']) & set(columns))[0]
|
|
_features = pd.DataFrame(_features).T
|
|
_features.columns = columns
|
|
_features = _features.sort_values(by=[_key],ascending=False)
|
|
|
|
_lrow = pd.DataFrame([dict(zip(columns,pricing))],index=[''])
|
|
_df = _features
|
|
# _df = pd.concat([_features,_lrow])
|
|
return _df.to_json()
|
|
|
|
def signup (**_args):
|
|
_request = _args['request']
|
|
_email = _request.headers['email']
|
|
_name = None if 'name' in _request.headers else _request.headers['name']
|
|
product = store.get.product('healthcareio')
|
|
#
|
|
# If the user is already signed up
|
|
customer = store.get.customer(_email)
|
|
|
|
def version (**_args):
|
|
return str(healthcareio.meta.__version__) |