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

Feature Request: Generic API Calls #228

Open
linuxlurak opened this issue Oct 5, 2024 · 2 comments
Open

Feature Request: Generic API Calls #228

linuxlurak opened this issue Oct 5, 2024 · 2 comments

Comments

@linuxlurak
Copy link
Contributor

linuxlurak commented Oct 5, 2024

Hi,

What do you think of the idea of having some kind of generic API call option? This would allow me to do weigh-ins with date, for example. The call on the garmin connect website is like this:

{
	‘POST": {
		"scheme": “https”,
		"host": “connect.garmin.com”,
		"filename": “/weight-service/user-weight”,
		"remote": {
			"address": "104.17.168.14:443’
		}
	}
}

Payload:

{
    "dateTimestamp": “2024-10-05T16:04:00.00”,
    "gmtTimestamp": “2024-10-05T14:04:00.00”,
    "unitKey": “kg”,
    "value": 100
}

The remote part in the POST is most likely not necessary.

@linuxlurak
Copy link
Contributor Author

Another idea would be to move these API definitions to an external file so that the community can react more quickly to changes. Systematic monitoring might even be conceivable.

@psdupvi
Copy link
Contributor

psdupvi commented Oct 5, 2024

I think there is already the connectapi method

    def connectapi(self, path, **kwargs):
        return self.garth.connectapi(path, **kwargs)

There are some examples of its usage to POST in add_body_composition and add_weigh_in, and I think it actually serves as the requester for all the get_ endpoints. There's also a PUT for add_hydration_data

It's not particularly well documented here, since it's technically a garth method:

    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:
            rv = resp.json()
        return rv

I think this should roughly allow what you want, although it's not a bad idea to add some more formal documentation. I don't necessarily think it's worth adding our own version of the method here, since then we're just duplicating work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants