def get_data(datapoint_date): """Requests summary time for a given date and returns in hours.""" api_token = db.get_parameter('toggl_api_token') user_agent = db.get_parameter('toggl_user_agent') workspace_id = db.get_parameter('toggl_wrkspc_id') datapoint_date = datapoint_date.isoformat() payload = {'user_agent':user_agent, 'workspace_id':workspace_id, 'since':datapoint_date, 'until':datapoint_date, 'grouping':'clients', 'subgrouping':'projects'} response = requests.get('https://www.toggl.com/reports/api/v2/summary', auth=(api_token, 'api_token'), params=payload) logging.debug(str(json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':')))) total_grand_ms = response.json()['total_grand'] if total_grand_ms is not None: total_grand_hours = response.json()['total_grand']/3600000 else: total_grand_hours = 0 logging.debug(str(datapoint_date) + ':' + str(total_grand_hours)) return total_grand_hours
def get_workspaces(): api_token = db.get_parameter('toggl_api_token') user_agent = db.get_parameter('toggl_user_agent') payload = {'user_agent':user_agent} response = requests.get('https://www.toggl.com/api/v8/workspaces', auth=(api_token, 'api_token'), params=payload) return json.dumps(response.json())
def get_data_for_range(since, until): """Requests summary time for a date range per day. Turns out Toggl currently does not support such format. """ api_token = db.get_parameter('toggl_api_token') user_agent = db.get_parameter('toggl_user_agent') workspace_id = db.get_parameter('toggl_wrkspc_id') since, until = since.isoformat(), until.isoformat() payload = {'user_agent':user_agent, 'workspace_id':workspace_id, 'since':since, 'until':until, 'grouping':'clients', 'subgrouping':'projects'} response = requests.get('https://www.toggl.com/reports/api/v2/summary', auth=(api_token, 'api_token'), params=payload) logging.debug(str(json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':')))) # # total_grand_ms = response.json()['total_grand'] # # if total_grand_ms is not None: # # total_grand_hours = response.json()['total_grand']/3600000 # # else: # # total_grand_hours = 0 # logging.debug(str(datapoint_date) + ':' + str(total_grand_hours)) return None
def get_data(datapoint_date): """Requests summary time for a given date and returns in hours.""" api_token = db.get_parameter('toggl_api_token') user_agent = db.get_parameter('toggl_user_agent') workspace_id = db.get_parameter('toggl_wrkspc_id') datapoint_date = datapoint_date.isoformat() payload = { 'user_agent': user_agent, 'workspace_id': workspace_id, 'since': datapoint_date, 'until': datapoint_date, 'grouping': 'clients', 'subgrouping': 'projects' } response = requests.get('https://www.toggl.com/reports/api/v2/summary', auth=(api_token, 'api_token'), params=payload) logging.debug( str( json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':')))) total_grand_ms = response.json()['total_grand'] if total_grand_ms is not None: total_grand_hours = response.json()['total_grand'] / 3600000 else: total_grand_hours = 0 logging.debug(str(datapoint_date) + ':' + str(total_grand_hours)) return total_grand_hours
def __init__(self, bm_goal_url): self.auth_token = db.get_parameter('bm_api_token') self.user = db.get_parameter('bm_user_name') self.goal = bm_goal_url
def __init__(self): self.api_token = db.get_parameter('habitica_api_token') self.user_agent = db.get_parameter('habitica_user_id')
def __init__(self): self.auth_token = db.get_parameter('bm_api_token') self.user = db.get_parameter('bm_user_name') self.goal = db.get_parameter('bm_goal_url')