Skip to content

Commit

Permalink
Custom method for Client.connectapi() (#45)
Browse files Browse the repository at this point in the history
* custom method for Client.connectapi()
  • Loading branch information
matin committed Jan 14, 2024
1 parent 34dc0a1 commit 3a5ebbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions garth/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def refresh_oauth2(self):
# appears even Garmin uses this approach when the OAuth2 is expired
self.oauth2_token = sso.exchange(self.oauth1_token, self)

def connectapi(self, path: str, **kwargs):
resp = self.get("connectapi", path, api=True, **kwargs)
def connectapi(self, path: str, method="GET", **kwargs):
resp = self.request(method, "connectapi", path, api=True, **kwargs)
if resp.status_code == 204:
rv = None
else:
Expand All @@ -182,13 +182,11 @@ def upload(
) -> Dict[str, Any]:
fname = os.path.basename(fp.name)
files = {"file": (fname, fp)}
resp = self.post(
"connectapi",
return self.connectapi(
path,
api=True,
method="POST",
files=files,
)
return resp.json()

def dump(self, dir_path: str):
dir_path = os.path.expanduser(dir_path)
Expand Down
2 changes: 1 addition & 1 deletion garth/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.43"
__version__ = "0.4.44"

0 comments on commit 3a5ebbc

Please sign in to comment.