Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update maintenance with master #11

Open
wants to merge 8 commits into
base: maintenance
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Code scanning - action"

on:
push:
pull_request:
schedule:
- cron: '0 13 * * 2'

jobs:
CodeQL-Build:

# CodeQL runs on ubuntu-latest and windows-latest
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ Download to a location of your choice and do the following.
from toggl.api_client import TogglClientApi

settings = {
'token': 'xxx',
'user_agent': 'your app name'
'token': 'token',
'user_agent': 'agent',
'workspace_id': '####',
'username': 'email',
}
toggle_client = TogglClientApi(settings)
toggl_client = TogglClientApi(settings)

response = toggle_client.get_workspaces()
response = toggl_client.get_workspaces()

```

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def readme():

setup(
name="python-toggl",
version="0.1.12",
version="0.2.0",
description="Python Wrapper for Toggl API",
long_description=readme(),
url="https://github.com/swappsco/toggl-python-api-client",
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_api_client_instance_created(self):
self.assertNotEqual(self.api, None)

def test_valid_toggl_base_url(self):
self.assertEqual(self.api.api_base_url, "https://www.toggl.com/api/v8")
self.assertEqual(self.api.api_base_url, "https://api.track.toggl.com/api/v9")

def test_api_toggl_auth_check_response_ok(self):
response = self.api.query("/me")
Expand Down
16 changes: 8 additions & 8 deletions toggl/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class TogglClientApi(object):
defaultCredentials = {
"username": "",
"workspace_name": "",
"base_url": "https://www.toggl.com/api",
"ver_api": 8,
"base_url_report": "https://toggl.com/reports/api",
"base_url": "https://api.track.toggl.com/api",
"ver_api": 9,
"base_url_report": "https://api.track.toggl.com/reports/api",
"ver_report": 2,
}
credentials = {}
Expand Down Expand Up @@ -56,11 +56,11 @@ def get_workspace_by_name(self, name):
def get_workspaces(self):
return self.query("/workspaces")

def get_projects(self):
return self.query("/workspaces/%i/projects" % self.workspace_id)
def get_projects(self, active=True):
return self.query("/workspaces/%i/projects" % self.workspace_id, params={"active": active})

def get_workspace_members(self, workspace_id):
response = self.query("/workspaces/" + str(workspace_id) + "/workspace_users")
response = self.query("/workspaces/" + str(workspace_id) + "/users")
return response

"""
Expand Down Expand Up @@ -120,7 +120,7 @@ def get_project_times(self, project_id, start_date, end_date, extra_params={}):
return json_response

def get_dashboard_data(self, params={}):
dashboard_response = self.query("/dashboard/%i" % self.workspace_id, params)
dashboard_response = self.query("/workspaces/%i/dashboard/all_activity" % self.workspace_id, params)

if dashboard_response.status_code != requests.codes.ok:
dashboard_response.raise_for_status()
Expand All @@ -144,7 +144,7 @@ def create_time_entry(self, json_data):
}
}
"""
response = self.query("/time_entries", method="POST", json_data=json_data)
response = self.query("/workspaces/%i/time_entries" % self.workspace_id, method="POST", json_data=json_data)

if response.status_code != requests.codes.ok:
response.raise_for_status()
Expand Down