This pull request implements getting user data from https://www.duolingo.com/2017-06-30/users/{self.user_data.id}.
This URL is currently used by Duolingo web app, also it is used in this library in the get_daily_xp_progress. However, it seems reasonable to have it implemented in a generic way to give users opportunity to request different data.
The reason for introducing fields is that the response is generally quite large, 760 bytes in my case and takes about 3 seconds to receive. One option is to get data on initialisation, but it is dynamic, for example after purchasing an item it has to be requested again.
It should also help users to solve #91 while keeping library code purely for an API interaction, sample code for this:
import duolingo
lingo = duolingo.Duolingo('I2UpM5so', '<password>')
user_data_resp = lingo._get_data_by_user_id(['shopItems'])
search_for = 'streak_freeze'
shop_items = list(filter(
lambda item: item["id"] == search_for,
user_data_resp['shopItems']
))
item = shop_items[0] if shop_items else None
if item and item["quantity"]:
print(f'Current quantity of {search_for}: {item["quantity"]}')
This pull request implements getting user data from
https://www.duolingo.com/2017-06-30/users/{self.user_data.id}
.This URL is currently used by Duolingo web app, also it is used in this library in the
get_daily_xp_progress
. However, it seems reasonable to have it implemented in a generic way to give users opportunity to request different data.The reason for introducing fields is that the response is generally quite large, 760 bytes in my case and takes about 3 seconds to receive. One option is to get data on initialisation, but it is dynamic, for example after purchasing an item it has to be requested again.
It should also help users to solve #91 while keeping library code purely for an API interaction, sample code for this:
Sample output: