File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,9 @@ async def get_messages(self):
1414 async def clear_messages (self ):
1515 async with AsyncClient (verify = False ) as client :
1616 response = await client .post (f"{ self .url } /clear" )
17- return response .json ().get ("ok" )
17+ return response .json ().get ("ok" )
18+
19+ async def delete_message (self , id : str ):
20+ async with AsyncClient (verify = False ) as client :
21+ response = await client .delete (f"{ self .url } /inbox/{ id } " )
22+ return response .json ().get ("ok" )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44
55[project ]
66name = " appwrite-lab"
7- version = " 0.1.3 "
7+ version = " 0.1.4 "
88description = " Zero-click Appwrite test environments."
99readme = " README.md"
1010requires-python = " >=3.11"
Original file line number Diff line number Diff line change 11from fastapi import FastAPI , Body , Form , Request
22from fastapi .responses import HTMLResponse , JSONResponse
3- from typing import List , Dict
43from datetime import datetime
4+ from uuid import uuid4
55
66app = FastAPI ()
7- MESSAGES : List [ Dict ] = []
7+ MESSAGES : list [ dict ] = []
88
99
1010@app .post ("/inbox" )
11- async def inbox (payload : Dict = Body (...)):
11+ async def inbox (payload : dict = Body (...)):
1212 payload ["ts" ] = datetime .utcnow ().isoformat () + "Z"
1313 MESSAGES .append (payload )
1414 if len (MESSAGES ) > 100 :
@@ -27,6 +27,13 @@ def clear_inbox():
2727 return {"ok" : True }
2828
2929
30+ @app .delete ("/inbox/{id}" )
31+ def delete_message (id : str ):
32+ global MESSAGES
33+ MESSAGES = [m for m in MESSAGES if m .get ("id" ) != id ]
34+ return {"ok" : True }
35+
36+
3037# Twilio-compatible endpoint
3138@app .post ("/2010-04-01/Accounts/{sid}/Messages.json" )
3239async def send_sms (sid : str , request : Request ):
@@ -45,6 +52,7 @@ async def send_sms(sid: str, request: Request):
4552 "frm" : from_ ,
4653 "body" : body ,
4754 "ts" : datetime .utcnow ().isoformat () + "Z" ,
55+ "id" : str (uuid4 ()),
4856 }
4957 )
5058
You can’t perform that action at this time.
0 commit comments