adding intervals.icu webhook support
This commit is contained in:
@@ -49,6 +49,8 @@ headers = {
|
||||
intervals_authorize_url = 'https://intervals.icu/oauth/authorize?'
|
||||
intervals_token_url = 'https://intervals.icu/api/oauth/token'
|
||||
|
||||
webhookverification = 'JA9Vt6RNH10'
|
||||
|
||||
class IntervalsIntegration(SyncIntegration):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(IntervalsIntegration, self).__init__(*args, **kwargs)
|
||||
@@ -335,6 +337,28 @@ class IntervalsIntegration(SyncIntegration):
|
||||
data = response.json()
|
||||
|
||||
return data
|
||||
|
||||
def update_plannedsession(self, ps, data, *args, **kwargs):
|
||||
_ = self.open()
|
||||
r = self.rower
|
||||
|
||||
if data['category'] == 'WORKOUT':
|
||||
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(ps.intervals_icu_id) + '/downloadfit'
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + r.intervals_token,
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code != 200:
|
||||
dologging('intervals.icu.log', response.text)
|
||||
else:
|
||||
filename = 'planned_' + str(ps.intervals_icu_id) + '.fit'
|
||||
filename2 = 'media/planned_' + str(ps.intervals_icu_id) + '.fit'
|
||||
with open(filename2, 'wb') as f:
|
||||
f.write(response.content)
|
||||
|
||||
data['fitfile'] = filename
|
||||
|
||||
return data
|
||||
|
||||
def get_plannedsession(self, id, *args, **kwargs):
|
||||
_ = self.open()
|
||||
@@ -396,6 +420,7 @@ class IntervalsIntegration(SyncIntegration):
|
||||
"name": ps.name,
|
||||
"description": stepstext,
|
||||
"indoor": ps.sessionsport in mytypes.ergtypes,
|
||||
'external_id': ps.id,
|
||||
}
|
||||
|
||||
if ps.sessiontype == 'cycletarget':
|
||||
|
||||
Reference in New Issue
Block a user