Skip to content

Commit

Permalink
List coupons as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
1-Byte authored Nov 12, 2023
1 parent 9aa21a7 commit 05b8ea6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lidlplus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def get_arguments():
receipt.add_argument("receipt", help="output last receipts as json", action="store_true")
receipt.add_argument("-a", "--all", help="fetch all receipts", action="store_true")
coupon = subparser.add_parser("coupon", help="activate coupons")
coupon.add_argument("coupon", help="activate coupons", action="store_true")
coupon.add_argument("-a", "--all", help="activate all coupons", action="store_true", required=True)
coupon.add_argument("coupon", help="output all coupons", action="store_true")
coupon.add_argument("-a", "--all", help="activate all coupons", action="store_true")
return vars(parser.parse_args())


Expand Down Expand Up @@ -127,10 +127,12 @@ def print_tickets(args):
def activate_coupons(args):
"""Activate all available coupons"""
lidl_plus = lidl_plus_login(args)
coupons = lidl_plus.coupons()
if not args.get("all"):
print(json.dumps(coupons, indent=4))
return
i = 0
for section in lidl_plus.coupons().get("sections", {}):
for section in coupons.get("sections", {}):
for coupon in section.get("coupons", {}):
if coupon["isActivated"]:
continue
Expand Down

0 comments on commit 05b8ea6

Please sign in to comment.