Esempio n. 1
0
def store_api_user(user_id):
    try:
        url = API_URL + 'conf/'
        api_user = requests.get(url, headers={'authorization': 'JWT ' + get_api_token(user_id)}).json().get('username')
        REDIS.hset(user_id, 'api_user', api_user)
    except Exception as e:
        logger.warn('Failed store api_user for "%s": %s' % (user_id, e))
Esempio n. 2
0
def store_resource(resource, user_id):
    try:
        url = API_URL + resource
        resources = requests.get(url, headers={'authorization': 'JWT ' + get_api_token(user_id)}).text.encode('utf-8')
        REDIS.hset(user_id, resource, resources)
    except Exception as e:
        logger.warn('Failed store resource "%s": %s' % (resource, e))
Esempio n. 3
0
def store_resource(resource, user_id):
    try:
        url = API_URL + resource
        resources = requests.get(url,
                                 headers={
                                     'authorization':
                                     'JWT ' + get_api_token(user_id)
                                 }).text.encode('utf-8')
        REDIS.hset(user_id, resource, resources)
    except Exception as e:
        logger.warn('Failed store resource "%s": %s' % (resource, e))
Esempio n. 4
0
def store_api_user(user_id):
    try:
        url = API_URL + 'conf/'
        api_user = requests.get(url,
                                headers={
                                    'authorization':
                                    'JWT ' + get_api_token(user_id)
                                }).json().get('username')
        REDIS.hset(user_id, 'api_user', api_user)
    except Exception as e:
        logger.warn('Failed store api_user for "%s": %s' % (user_id, e))
Esempio n. 5
0
def store_transaction_to(to, user_id):
    REDIS.hset('%s:transaction' % user_id, 'to', to)
Esempio n. 6
0
def store_transaction_from(fr, user_id):
    REDIS.hset('%s:transaction' % user_id, 'from', fr)
Esempio n. 7
0
def store_transaction_kind(kind, user_id):
    kinds_map = {'income': 'inc', 'expense': 'exp', 'transfer': 'trn'}
    REDIS.hset('%s:transaction' % user_id, 'kind', kinds_map[kind])
Esempio n. 8
0
def get_stored_resource(resource, user_id):
    return json.loads(REDIS.hget(user_id, resource))
Esempio n. 9
0
def flush_transaction_fields(user_id):
    REDIS.delete('%s:transaction' % user_id)
Esempio n. 10
0
def store_transaction_amount(amount, user_id):
    REDIS.hset('%s:transaction' % user_id, 'amount', amount)
Esempio n. 11
0
def store_transaction_to(to, user_id):
    REDIS.hset('%s:transaction' % user_id, 'to', to)
Esempio n. 12
0
def store_transaction_from(fr, user_id):
    REDIS.hset('%s:transaction' % user_id, 'from', fr)
Esempio n. 13
0
def store_transaction_kind(kind, user_id):
    kinds_map = {'income': 'inc', 'expense': 'exp', 'transfer': 'trn'}
    REDIS.hset('%s:transaction' % user_id, 'kind', kinds_map[kind])
Esempio n. 14
0
def get_stored_resource(resource, user_id):
    return json.loads(REDIS.hget(user_id, resource))
Esempio n. 15
0
def store_transaction_amount(amount, user_id):
    REDIS.hset('%s:transaction' % user_id, 'amount', amount)
Esempio n. 16
0
def get_api_token(user_id):
    return REDIS.hget(user_id, 'token')
Esempio n. 17
0
def flush_transaction_fields(user_id):
    REDIS.delete('%s:transaction' % user_id)
Esempio n. 18
0
def get_api_token(user_id):
    return REDIS.hget(user_id, 'token')