Skip to content

Commit

Permalink
Merge pull request #16 from kquinsland/bug/user-account-country
Browse files Browse the repository at this point in the history
Bug/user account country
  • Loading branch information
kquinsland authored Oct 30, 2024
2 parents 6c9c63e + 0ba320e commit 6d16da3
Show file tree
Hide file tree
Showing 15 changed files with 929 additions and 577 deletions.
11 changes: 10 additions & 1 deletion .vscode/lib-toggl.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
}
],
"settings": {
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.autoComplete.extraPaths": [
"${workspaceFolder}/.venv/lib/python3.12/site-packages"
Expand All @@ -15,11 +21,13 @@
"asyncio",
"autoenv",
"autofix",
"booleaness",
"cafile",
"celerybeat",
"certifi",
"dataclasses",
"doctoc",
"dunder",
"duronly",
"excinfo",
"htmlcov",
Expand All @@ -41,13 +49,14 @@
"pylint",
"pyrfc",
"pytest",
"PYTHONPATH",
"Quinsalnd",
"scrapy",
"sdist",
"stdlib",
"structlog",
"togglpy",
"toggl",
"togglpy",
"virtualenv",
"virtualenvs",
"webassets"
Expand Down
3 changes: 2 additions & 1 deletion lib_toggl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""lib-toggl
"""
lib-toggl
"""

from importlib.metadata import PackageNotFoundError, version
Expand Down
5 changes: 3 additions & 2 deletions lib_toggl/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ENDPOINT = f"{BASE}/me"


class Account(BaseModel):
class Account(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""
https://developers.track.toggl.com/docs/api/me#200
"""
Expand All @@ -36,7 +36,8 @@ class Account(BaseModel):
updated_at: datetime
openid_email: Optional[str]
openid_enabled: bool
country_id: int
# See: https://github.com/kquinsland/lib-toggl/issues/15
country_id: Optional[int]
has_password: bool
at: datetime
# Analytics?
Expand Down
13 changes: 5 additions & 8 deletions lib_toggl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import aiohttp
from pyrfc3339 import generate

from lib_toggl import __version__ as version

from .account import ENDPOINT as ACCOUNT_ENDPOINT
from .account import Account
Expand Down Expand Up @@ -336,17 +335,15 @@ async def get_time_entries(
# When
params = {"start_date": _start, "end_date": _end}

time_enttrries = await self.do_get_request(TIME_ENTRY_ENDPOINT, data=params)
log.debug("get_time_entries", extra={"time_enttrries": time_enttrries})
time_entries = await self.do_get_request(TIME_ENTRY_ENDPOINT, data=params)
log.debug("get_time_entries", extra={"time_entries": time_entries})
# As of now, not a ton of error handling in the do_*_request functions.
# We do basic checking here to make sure pylance is happy.
if time_enttrries is None:
if time_entries is None:
log.debug("No time entries found")
return []
# Assuming nothing went wrong, `time_enttrries` will be a list with one json object per time entry
return [
TimeEntry(**x) for x in time_enttrries # pyright: ignore reportCallIssue
]
# Assuming nothing went wrong, `time_entries` will be a list with one json object per time entry
return [TimeEntry(**x) for x in time_entries] # pyright: ignore reportCallIssue

async def get_current_time_entry(self) -> TimeEntry | None:
"""Returns active Time Entry if one is running, else None"""
Expand Down
2 changes: 1 addition & 1 deletion lib_toggl/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
ENDPOINT = f"{BASE}/organizations"


class Organization(BaseModel):
class Organization(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""Class representing the Toggl organization object.
Leverages dataclass to cut down on boilerplate code.
See: https://developers.track.toggl.com/docs/api/workspaces#200
Expand Down
2 changes: 1 addition & 1 deletion lib_toggl/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def TAGS_ENDPOINT(workspace_id: int | None) -> str:
return f"{BASE}/workspaces/{workspace_id}/tags"


class Tag(BaseModel):
class Tag(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""Class representing Tag object.
Leverages dataclass to cut down on boilerplate code.
See: https://engineering.toggl.com/docs/api/tags
Expand Down
2 changes: 1 addition & 1 deletion lib_toggl/time_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def EXPLICIT_ENDPOINT(time_entry_id: int) -> str:
return f"{BASE}/me/time_entries/{time_entry_id}"


class TimeEntry(BaseModel): # pyright: ignore reportGeneralTypeIssues
class TimeEntry(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""Class representing the Toggl organization object.
Leverages dataclass to cut down on boilerplate code.
See: https://developers.track.toggl.com/docs/api/time_entries#200
Expand Down
6 changes: 3 additions & 3 deletions lib_toggl/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
ENDPOINT = f"{BASE}/workspaces"


class CSVUpload(BaseModel):
class CSVUpload(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""_summary_"""

at: datetime
log_id: int


class Subscription(BaseModel):
class Subscription(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""Machine generated class representing the Toggl Subscription object."""

auto_renew: bool
Expand Down Expand Up @@ -55,7 +55,7 @@ class Subscription(BaseModel):
workspace_id: int


class Workspace(BaseModel):
class Workspace(BaseModel): # pyright: ignore[reportGeneralTypeIssues]
"""Class representing the Toggl Workspace object.
Leverages dataclass to cut down on boilerplate code.
See: https://developers.track.toggl.com/docs/api/workspaces#200
Expand Down
Loading

0 comments on commit 6d16da3

Please sign in to comment.