Andre0512 / lidl-plus

Fetch receipts and more from Lidl Plus
MIT License
80 stars 19 forks source link

Set Favorite Market #9

Open Griffsano opened 1 year ago

Griffsano commented 1 year ago

Hi,

thanks for providing this nice package. With feature #7 it's possible to automatically activate all coupons available to all markets. However, there may be coupons that are only available to the selected favorite market. In the app, this favorite market can be selected under settings.

Without setting a favorite market, the first part of the response of LidlPlusApi.coupons() looks like this: {'name': 'FavoriteStore', 'coupons': []} To automatically enable the coupons for the favorite market as well, it would be nice to support the selection of the favorite market per API.

By the way, in case someone runs into the same problem: Some LIDL coupon names are not UTF-8 compliant. This may lead to such an error when printing the coupon name: UnicodeEncodeError: 'latin-1' codec can't encode character '\u20ac' in position 1120: ordinal not in range(256) Therefore, it might be worth sanitizing the string before using it further. For me, the following encoding of the string worked: coupon["title"].encode('utf8', 'ignore')

Woyken commented 9 months ago

I'm just going to leave these here, maybe someone will decide to implement:

Get available stores for {country}

GET https://stores.lidlplus.com/api/v2/{country}

Lidl-Plus application does both of these requests when you change your favorite store:

Update user's favorite store

PUT https://stores.lidlplus.com/api/v1/users/me/favorite/{country}
{
  "country": "LT",
  "storeKey": "LT0218"
}
Update user country info, with favorite store

POST https://profile.lidlplus.com/profile/api/v1/updateCountryInfo
{
  "country_code": "LT",
  "language": "LT",
  "store_id": "LT0218"
}