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 Base API URL #9

Merged
merged 5 commits into from
Jun 25, 2021
Merged
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
26 changes: 14 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ version: 2
jobs:
build:
docker:
- image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:tap-tester
- image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:tap-tester-v4
steps:
- checkout
- run:
name: 'Setup virtual env'
command: |
virtualenv -p python3 /usr/local/share/virtualenvs/tap-toggl
python3 -m venv /usr/local/share/virtualenvs/tap-toggl
source /usr/local/share/virtualenvs/tap-toggl/bin/activate
pip install .[dev]
- run:
name: 'pylint'
name: 'Unit Tests'
command: |
source /usr/local/share/virtualenvs/tap-toggl/bin/activate
make test
Expand All @@ -23,18 +23,19 @@ jobs:
aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/sandbox dev_env.sh
source dev_env.sh
source /usr/local/share/virtualenvs/tap-tester/bin/activate
run-a-test --tap=tap-toggl \
--target=target-stitch \
--orchestrator=stitch-orchestrator \
--email=harrison+sandboxtest@stitchdata.com \
--password=$SANDBOX_PASSWORD \
--client-id=50 \
tap_tester_toggl_base
run-test --tap=tap-toggl \
--target=target-stitch \
--orchestrator=stitch-orchestrator \
--email=harrison+sandboxtest@stitchdata.com \
--password=$SANDBOX_PASSWORD \
--client-id=50 \
tests
workflows:
version: 2
commit:
jobs:
- build
- build:
context: circleci-user
build_daily:
triggers:
- schedule:
Expand All @@ -44,4 +45,5 @@ workflows:
only:
- master
jobs:
- build
- build:
context: circleci-user
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ release:

# Test.
test:
@python3 tests/test_tap_toggl.py
@python3 tests/unittests/test_tap_toggl.py

#
# Phonies.
Expand Down
22 changes: 11 additions & 11 deletions tap_toggl/toggl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, api_token=None, start_date=None, user_agent=None, trailing_da
self.start_date = start_date
self.workspace_ids = []
self.user_agent = user_agent
res = self._get('https://www.toggl.com/api/v8/workspaces')
res = self._get('https://api.track.toggl.com/api/v8/workspaces')
for item in res:
self.workspace_ids.append(item['id'])

Expand Down Expand Up @@ -101,47 +101,47 @@ def _get_from_endpoints(self, endpoints, column_name=None, bookmark=None, key=No


def is_authorized(self):
return self._get('https://www.toggl.com/api/v8/me')
return self._get('https://api.track.toggl.com/api/v8/me')


def workspaces(self, column_name=None, bookmark=None):
res = self._get('https://www.toggl.com/api/v8/workspaces')
res = self._get('https://api.track.toggl.com/api/v8/workspaces')
for item in res:
yield item


def clients(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/clients')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/clients')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def groups(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/groups')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/groups')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def projects(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/projects')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/projects')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def tasks(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/tasks')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/tasks')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def tags(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/tags')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/tags')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def users(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/users')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/users')
return self._get_from_endpoints(endpoints, column_name, bookmark)


def workspace_users(self, column_name=None, bookmark=None):
endpoints = self._get_workspace_endpoints('https://www.toggl.com/api/v8/workspaces/{workspace_id}/workspace_users')
endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/api/v8/workspaces/{workspace_id}/workspace_users')
return self._get_from_endpoints(endpoints, column_name, bookmark)


Expand All @@ -160,7 +160,7 @@ def time_entries(self, column_name=None, bookmark=None):
moving_start_date = utils.strptime_with_tz(start_date)
moving_end_date = moving_start_date + timedelta(days=30)
while moving_start_date <= utils.strptime_with_tz(end_date):
new_endpoints = self._get_workspace_endpoints('https://toggl.com/reports/api/v2/details?workspace_id={{workspace_id}}&since={start_date}&until={end_date}&user_agent={user_agent}'.format(start_date=moving_start_date.strftime(fmt), end_date=moving_end_date.strftime(fmt), user_agent=self.user_agent))
new_endpoints = self._get_workspace_endpoints('https://api.track.toggl.com/reports/api/v2/details?workspace_id={{workspace_id}}&since={start_date}&until={end_date}&user_agent={user_agent}'.format(start_date=moving_start_date.strftime(fmt), end_date=moving_end_date.strftime(fmt), user_agent=self.user_agent))
endpoints.extend(new_endpoints)
moving_start_date += timedelta(days=30)
moving_end_date = moving_start_date + timedelta(days=30)
Expand Down
Loading