Junaidb commited on
Commit
973a992
·
verified ·
1 Parent(s): d5537b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -22
app.py CHANGED
@@ -488,31 +488,40 @@ def UpdateDynamicEndpointPriceRoute(data:UpdatePrice):
488
  @app.post("/invoices")
489
  def getaudit(data:Invoice):
490
  invoices=GetInvoices(data.owner)
491
- filtered_invoices=[]
492
- return invoices
493
 
494
- '''
495
- for data in invoices:
496
 
497
- accepts=data["details"]["payment_request"]["accepts"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
 
499
- filtered_invoices.append(
500
-
501
- {
502
-
503
- "owner":data["owner"] ,
504
- "endpoint_linker":data["endpoint_linker"],
505
- "endpoint":data["endpoint"],
506
- "signature":data["signature"],
507
- "payTo":accepts[0]["payTo"],
508
- "asset":accepts[0]["asset"],
509
- "Amount":accepts[0]["maxAmountRequired"]
510
-
511
- }
512
-
513
- )
514
- '''
515
-
516
 
517
 
518
 
 
488
  @app.post("/invoices")
489
  def getaudit(data:Invoice):
490
  invoices=GetInvoices(data.owner)
491
+ result = []
 
492
 
493
+ for item in invoices:
 
494
 
495
+ owner = item.get("owner")
496
+ endpoint = item.get("endpoint")
497
+ endpoint_linker = item.get("endpoint_linker")
498
+ signature = item.get("signature")
499
+
500
+ #Navigate into nested fields
501
+ payment = item["details"]["payment_request"]
502
+
503
+ #Some entries use "accepts", some use flat structure
504
+ if "accepts" in payment:
505
+ pay_info = payment["accepts"][0]
506
+ else:
507
+ pay_info = payment
508
+
509
+ payTo = pay_info.get("payTo")
510
+ asset = pay_info.get("asset")
511
+ amount = pay_info.get("maxAmountRequired")
512
+
513
+ result.append({
514
+ "owner": owner,
515
+ "endpoint_linker": endpoint_linker,
516
+ "endpoint": endpoint,
517
+ "signature": signature,
518
+ "payTo": payTo,
519
+ "asset": asset,
520
+ "amount": amount
521
+ })
522
 
523
+ return result
524
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
 
526
 
527