list of intervals
This commit is contained in:
@@ -63,7 +63,7 @@ class IntervalsIntegration(SyncIntegration):
|
||||
'base_url': 'https://intervals.icu/api/v1/',
|
||||
'grant_type': 'refresh_token',
|
||||
'headers': headers,
|
||||
'scope': 'ACTIVITY:WRITE, LIBRARY:READ',
|
||||
'scope': 'ACTIVITY:WRITE, LIBRARY:READ, CALENDAR:WRITE',
|
||||
}
|
||||
|
||||
def get_token(self, code, *args, **kwargs):
|
||||
@@ -297,5 +297,48 @@ class IntervalsIntegration(SyncIntegration):
|
||||
def token_refresh(self, *args, **kwargs):
|
||||
return super(IntervalsIntegration, self).token_refresh(*args, **kwargs)
|
||||
|
||||
def get_plannedsessions_list(self, *args, **kwargs):
|
||||
_ = self.open()
|
||||
r = self.rower
|
||||
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + r.intervals_token,
|
||||
}
|
||||
|
||||
# first get the folders - we need the folder id for the next call
|
||||
url = self.oauth_data['base_url'] + 'athlete/0/folders'
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code != 200:
|
||||
return []
|
||||
|
||||
data = response.json()
|
||||
# get all elements in the list where start_date_local is not None
|
||||
folders = [x for x in data if x['start_date_local']]
|
||||
for plan in folders:
|
||||
plan_start_date = arrow.get(plan['start_date_local']).datetime
|
||||
for session in plan["children"]:
|
||||
session["date"] = (plan_start_date+timedelta(days=session["day"])).date()
|
||||
|
||||
return folders
|
||||
|
||||
def get_plannedsession(self, id, *args, **kwargs):
|
||||
_ = self.open()
|
||||
r = self.rower
|
||||
|
||||
url = self.oauth_data['base_url'] + 'athlete/0/workouts/' + str(id)
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + r.intervals_token,
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
if response.status_code != 200:
|
||||
dologging('intervals.icu.log', response.text)
|
||||
return 0
|
||||
|
||||
data = response.json()
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user