Skip to content

Commit

Permalink
Add Current User info methods
Browse files Browse the repository at this point in the history
Return User Usage Limits / Current Usage towards Throttle Limits with `receive_user_rate_info`
Return full account info with `receive_user_info`
Fixes #126
  • Loading branch information
tyeth committed Aug 5, 2024
1 parent 99bd004 commit d538233
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions adafruit_io/adafruit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,35 @@ def receive_random_data(self, generator_id: int):
path = self._compose_path("integrations/words/{0}".format(generator_id))
return self._get(path)

def receive_user_info(self):
"""
Get detailed account information for the current user.
See https://io.adafruit.com/api/docs/#get-user-info
"""
return self._get("https://io.adafruit.com/api/v2/user")

def receive_user_rate_info(self):
"""
Get rate limit and usage information for the current user.
See https://io.adafruit.com/api/docs/#get-detailed-user-info
:code-block: json
{
"data_rate_limit": 90,
"active_data_rate": 2,
"authentication_rate": 0,
"subscribe_authorization_rate": 0,
"publish_authorization_rate": 0,
"hourly_ban_rate": 0,
"mqtt_ban_error_message": null,
"sms_message_limit": 0
}
"""
path = self._compose_path("throttle".format(self.username))

Check failure on line 884 in adafruit_io/adafruit_io.py

View workflow job for this annotation

GitHub Actions / test

Using formatting for a string that does not have any interpolated variables

Check failure on line 884 in adafruit_io/adafruit_io.py

View workflow job for this annotation

GitHub Actions / test

Using formatting for a string that does not have any interpolated variables
return self._get(path)

def receive_time(self, timezone: str = None):
"""
Returns a struct_time from the Adafruit IO Server based on the device's IP address.
Expand Down

0 comments on commit d538233

Please sign in to comment.