Skip to content

Commit

Permalink
fixed time entries and project streams
Browse files Browse the repository at this point in the history
  • Loading branch information
jlloyd-widen committed Mar 14, 2024
1 parent 42a1faf commit 1cc4fc0
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 168 deletions.
26 changes: 0 additions & 26 deletions .github/dependabot.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/test.yml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ tap-toggl --about --format=markdown
| api_token | True | None | The token to authenticate against the Toggl API |
| detailed_report_trailing_days| False | 1 | Provided for backwards compatibility. Does nothing. |
| start_date | False | | The earliest record date to sync. In the format YYYY-MM-DD. |
| user_agent | False | | Inserts a user agent into the request header |
| stream_maps | False | None | Config object for stream maps capability. For more information check out [Stream Maps](https://sdk.meltano.com/en/latest/stream_maps.html). |
| stream_map_config | False | None | User-defined config values to be used within map expressions. |
| faker_config | False | None | Config for the [`Faker`](https://faker.readthedocs.io/en/master/) instance variable `fake` used within map expressions. Only applicable if the plugin specifies `faker` as an addtional dependency (through the `singer-sdk` `faker` extra or directly). |
Expand Down
19 changes: 6 additions & 13 deletions tap_toggl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from singer_sdk.pagination import BasePageNumberPaginator, BaseAPIPaginator
from singer_sdk.streams import RESTStream

if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
import importlib_resources

_Auth = Callable[[requests.PreparedRequest], requests.PreparedRequest]


Expand All @@ -25,7 +20,7 @@ class TogglStream(RESTStream):
@property
def url_base(self) -> str:
"""Return the API URL root, configurable via tap settings."""
return "https://api.track.toggl.com/api/v9"
return "https://api.track.toggl.com"

records_jsonpath = "$[*]"

Expand All @@ -36,15 +31,13 @@ def http_headers(self) -> dict:
Returns:
A dictionary of HTTP headers.
"""
auth_str = bytes(f"{self.config.get('api_token')}:api_token", 'utf-8')
auth_str = bytes(f"{self.config.get('api_token')}:api_token", "utf-8")
encoded_token = b64encode(auth_str).decode("ascii")
headers = {"content-type": "application/json"}
if "api_token" in self.config:
headers["Authorization"] = f"Basic {encoded_token}"
else:
self.logger.error("No API token provided")
if "user_agent" in self.config:
headers["User-Agent"] = self.config.get("user_agent")
return headers

def start_time_to_epoch(self, start_time: str) -> int:
Expand Down Expand Up @@ -73,9 +66,9 @@ def get_new_paginator(self) -> BaseAPIPaginator:
return BasePageNumberPaginator(1)

def get_url_params(
self,
context: dict | None, # noqa: ARG002
next_page_token: Any | None, # noqa: ANN401
self,
context: dict | None, # noqa: ARG002
next_page_token: Any | None, # noqa: ANN401
) -> dict[str, Any]:
"""Return a dictionary of values to be used in URL parameterization.
Expand All @@ -87,7 +80,7 @@ def get_url_params(
A dictionary of URL query parameters.
"""
params: dict = {}
if self.config.get("start_date"):
if self.config.get("start_date") and self.name != "projects":
params["since"] = self.start_time_to_epoch(self.config.get("start_date"))
if next_page_token:
params["page"] = next_page_token
Expand Down
Loading

0 comments on commit 1cc4fc0

Please sign in to comment.