diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..d92c4d0 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/README.md b/README.md index 6dbfd0e..2a2c292 100644 --- a/README.md +++ b/README.md @@ -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() ``` diff --git a/setup.py b/setup.py index 8c567e1..19f0587 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tests/tests_live.py b/tests/tests_live.py index b2d71e4..7c61bf6 100644 --- a/tests/tests_live.py +++ b/tests/tests_live.py @@ -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") diff --git a/toggl/api_client.py b/toggl/api_client.py index 0f89226..3bfd6ad 100644 --- a/toggl/api_client.py +++ b/toggl/api_client.py @@ -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 = {} @@ -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 """ @@ -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() @@ -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()