Esempio n. 1
0
def get_questions(access_token):
    r = requests.get(MAIN_API + COACHMANAGER + '/questions',
                     headers=get_headers(access_token))
    if r.status_code == 200:
        return r.json()
    print('failed to get questions', r.status_code)
    return None
Esempio n. 2
0
def test_authorization(access_token):
    r = requests.get(MAIN_API + TRACKERMANAGER + '/fitbit/authorized',
                     headers=get_headers(access_token))
    if r.status_code == 200:
        return r.json()
    print('failed to get authorization', r.status_code)
    return None
Esempio n. 3
0
def get_steps(access_token):
    r = requests.get(MAIN_API + TRACKERMANAGER + '/fitbit/get_steps',
                     headers=get_headers(access_token))
    if r.status_code == 200:
        return r.json()
    print('failed to get steps', r.status_code)
    return None
Esempio n. 4
0
def post_answers(answers, access_token):
    r = requests.post(MAIN_API + COACHMANAGER + '/answers',
                      headers=get_headers(access_token),
                      json=answers)
    if r.status_code == 200:
        return True
    print('failed to save answers')
    return False
Esempio n. 5
0
def get_url(access_token):
    r = requests.get(MAIN_API + TRACKERMANAGER + '/fitbit/get_url',
                     headers=get_headers(access_token))
    if r.status_code == 200:
        return r.json()
    print('failed to get authorisation url', r.status_code)
    print(r.content)
    return None
Esempio n. 6
0
def rate_intervention(access_token):
    rating = {
        # item 1 is rated whenever a user is created while UserManager is running with dev mode enabled in config
        "rating": random.randint(1, 5),
        "item_id": 1,
        "successful": True
    }
    r = requests.post(MAIN_API + COACHMANAGER + '/intervention_response',
                      headers=get_headers(access_token),
                      json=rating)
    if r.status_code == 200:
        return True
    print('failed to rate intervention', r.text)
    return False