def startTimer(value): if tkn is None: return 'Please set Token via \'tgl token <TOKEN>\'' else: wrk = requests.get('https://www.toggl.com/api/v8/workspaces', auth=(tkn, 'api_token')) if wrk.status_code == 200: default_wrk = wrk.json[0]['id'] timer = {"time_entry":{"description":value,"duration":-1 * timestamp(datetime.now()),"start":toString(datetime.utcnow()), "wid":default_wrk, "created_with": "Alfred Toggl"}} res = requests.post('https://www.toggl.com/api/v8/time_entries', auth=(tkn, 'api_token'), data=json.dumps(timer)) return 'New Timer Started at %s' % datetime.utcnow().isoformat()
def startTimer(value): if tkn is None: return 'Please set Token via \'tgl token <TOKEN>\'' else: wrk = requests.get('https://www.toggl.com/api/v8/workspaces', auth=(tkn, 'api_token')) if wrk.status_code == 200: default_wrk = wrk.json[0]['id'] timer = { "time_entry": { "description": value, "duration": -1 * timestamp(datetime.now()), "start": toString(datetime.utcnow()), "wid": default_wrk, "created_with": "Alfred Toggl" } } res = requests.post('https://www.toggl.com/api/v8/time_entries', auth=(tkn, 'api_token'), data=json.dumps(timer)) return 'New Timer Started at %s' % datetime.utcnow().isoformat()
def login(login, password): response = requests.post(LOGIN_URL, {'login': login, 'passwd': password, 'remember': 'on'}, headers=headers, cookies=cookie_jar) return checkLogin(BeautifulSoup(response.content))