Private
Public Access
1
0

import working

This commit is contained in:
Sander Roosendaal
2017-04-16 14:14:20 +02:00
parent cb7d43487e
commit d70df62b63
7 changed files with 359 additions and 13 deletions

View File

@@ -171,9 +171,9 @@ def get_underarmour_workout_list(user):
headers = {'Authorization': authorizationstring,
'Api-Key': UNDERARMOUR_CLIENT_KEY,
'user-agent': 'sanderroosendaal',
'user':'v7.1/user/'+str(get_userid(r.underarmourtoken))+'/',
'Content-Type': 'application/json'}
url = "https://api.ua.com/v7.1/workout/"
url = "https://api.ua.com/v7.1/workout/?user="+str(get_userid(r.underarmourtoken))
s = requests.get(url,headers=headers)
return s
@@ -191,7 +191,7 @@ def get_underarmour_workout(user,underarmourid):
'Api-Key': UNDERARMOUR_CLIENT_KEY,
'user-agent': 'sanderroosendaal',
'Content-Type': 'application/json'}
url = "https://api.ua.com/v7.1/workout/"+str(underarmourid)+"/"
url = "https://api.ua.com/v7.1/workout/"+str(underarmourid)+"/?field_set=time_series"
s = requests.get(url,headers=headers)
return s
@@ -292,13 +292,36 @@ def createunderarmourworkoutdata(w):
return data
# Obtain Underarmour Workout ID from the response returned on successful
# upload
def getidfromresponse(response):
uri = response.headers["Location"]
id = uri[len(uri)-9:]
# Obtain Underarmour Workout ID and activity type
def get_idfromuri(user,links):
id = links['self'][0]['id']
typeid = links['activity_type'][0]['id']
typename = get_typefromid(typeid,user)
return id,typename
def get_typefromid(typeid,user):
r = Rower.objects.get(user=user)
authorizationstring = str('Bearer ' + r.underarmourtoken)
headers = {'Authorization': authorizationstring,
'Api-Key': UNDERARMOUR_CLIENT_KEY,
'user-agent': 'sanderroosendaal',
'Content-Type': 'application/json'}
import urllib
url = "https://api.ua.com/v7.1/activity_type/"+str(typeid)
response = requests.get(url,headers=headers)
me_json = response.json()
try:
res = me_json['name']
except KeyError:
res = 0
return res
return int(id)
# Get user id, having access token