예제 #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))
예제 #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))
예제 #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))
예제 #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))
예제 #5
0
def store_transaction_to(to, user_id):
    REDIS.hset('%s:transaction' % user_id, 'to', to)
예제 #6
0
def store_transaction_from(fr, user_id):
    REDIS.hset('%s:transaction' % user_id, 'from', fr)
예제 #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])
예제 #8
0
def get_stored_resource(resource, user_id):
    return json.loads(REDIS.hget(user_id, resource))
예제 #9
0
def flush_transaction_fields(user_id):
    REDIS.delete('%s:transaction' % user_id)
예제 #10
0
def store_transaction_amount(amount, user_id):
    REDIS.hset('%s:transaction' % user_id, 'amount', amount)
예제 #11
0
def store_transaction_to(to, user_id):
    REDIS.hset('%s:transaction' % user_id, 'to', to)
예제 #12
0
def store_transaction_from(fr, user_id):
    REDIS.hset('%s:transaction' % user_id, 'from', fr)
예제 #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])
예제 #14
0
def get_stored_resource(resource, user_id):
    return json.loads(REDIS.hget(user_id, resource))
예제 #15
0
def store_transaction_amount(amount, user_id):
    REDIS.hset('%s:transaction' % user_id, 'amount', amount)
예제 #16
0
def get_api_token(user_id):
    return REDIS.hget(user_id, 'token')
예제 #17
0
def flush_transaction_fields(user_id):
    REDIS.delete('%s:transaction' % user_id)
예제 #18
0
def get_api_token(user_id):
    return REDIS.hget(user_id, 'token')