Junaidb commited on
Commit
a0558d6
·
verified ·
1 Parent(s): 3e1fbcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -110,9 +110,7 @@ class Update(BaseModel):
110
 
111
 
112
  class Owner(BaseModel):
113
- owner:str
114
-
115
-
116
 
117
 
118
  class Delete(BaseModel):
@@ -143,7 +141,7 @@ def saveToMarket(payload):
143
 
144
 
145
 
146
- def UpdateMarketData(endpoint,endpoint_linker,status_code):
147
 
148
 
149
  call_success = 200 <= status_code < 300
@@ -151,7 +149,11 @@ def UpdateMarketData(endpoint,endpoint_linker,status_code):
151
  marketplace.update_one(
152
  { owner: "system" },
153
  {
154
- "$set": { "marketplace.$[elem].mcp_endpoint": endpoint },
 
 
 
 
155
  "$inc": {
156
  "marketplace.$[elem].calls": 1,
157
  "marketplace.$[elem].failures": 0 if call_success else 1
@@ -308,9 +310,11 @@ def RegisterEndpoint(data:RegisterPayload):
308
  "endpoint_linker":short_id_e,
309
  "meta":data.meta,
310
  "description":data.description,
311
- "mcp_endpoint":"",
 
 
312
  "calls":0,
313
- "failures":0
314
 
315
 
316
  }
@@ -362,7 +366,9 @@ def RegisterDynamicEndpoint(data:RegisterPayloadDynamic):
362
  "endpoint_linker":short_id_e,
363
  "meta":data.meta,
364
  "description":data.description,
365
- "mcp_endpoint":""
 
 
366
  "calls":0,
367
  "failures":0
368
 
@@ -447,7 +453,7 @@ def checkDEP(data:Owner):
447
 
448
 
449
 
450
-
451
  #''' Dynamic Endpoint Updation '''
452
 
453
  @app.post("/update_dynamic_endpoint")
@@ -598,7 +604,7 @@ async def FetchVelocityGET(x402id:str,request:Request):
598
  #proxying here
599
 
600
  response=await X402Proxy_GET(request,found_endpoint)
601
- UpdateMarketData(found_endpoint,x402id,response.status_code)
602
 
603
 
604
 
@@ -853,7 +859,7 @@ async def FetchVelocityPost(request:Request):
853
  updateInvoice(owner=wallet,endpoint_linker=x402id,data=invoicePayload)
854
  #proxying here
855
  response=await X402Proxy_POST(request,found_endpoint)
856
- UpdateMarketData(found_endpoint,x402id,response.status_code)
857
 
858
 
859
 
 
110
 
111
 
112
  class Owner(BaseModel):
113
+ owner:str
 
 
114
 
115
 
116
  class Delete(BaseModel):
 
141
 
142
 
143
 
144
+ def UpdateMarketData(resource,endpoint,endpoint_linker,endpoint_method,status_code):
145
 
146
 
147
  call_success = 200 <= status_code < 300
 
149
  marketplace.update_one(
150
  { owner: "system" },
151
  {
152
+ "$set": {
153
+ "marketplace.$[elem].endpoint": endpoint ,
154
+ "endpoint_method":endpoint_method,
155
+ "resource":resource
156
+ },
157
  "$inc": {
158
  "marketplace.$[elem].calls": 1,
159
  "marketplace.$[elem].failures": 0 if call_success else 1
 
310
  "endpoint_linker":short_id_e,
311
  "meta":data.meta,
312
  "description":data.description,
313
+ "endpoint":"",
314
+ "endpoint_method":"",
315
+ "resource":"",
316
  "calls":0,
317
+ "failures":0
318
 
319
 
320
  }
 
366
  "endpoint_linker":short_id_e,
367
  "meta":data.meta,
368
  "description":data.description,
369
+ "endpoint":"",
370
+ "endpoint_method":"",
371
+ "resource":"",
372
  "calls":0,
373
  "failures":0
374
 
 
453
 
454
 
455
 
456
+
457
  #''' Dynamic Endpoint Updation '''
458
 
459
  @app.post("/update_dynamic_endpoint")
 
604
  #proxying here
605
 
606
  response=await X402Proxy_GET(request,found_endpoint)
607
+ UpdateMarketData(found_endpoint,resource,x402id,"GET",response.status_code)
608
 
609
 
610
 
 
859
  updateInvoice(owner=wallet,endpoint_linker=x402id,data=invoicePayload)
860
  #proxying here
861
  response=await X402Proxy_POST(request,found_endpoint)
862
+ UpdateMarketData(found_endpoint,resource,x402id,response.status_code)
863
 
864
 
865