Skip to content

Commit 31c7fb5

Browse files
authored
feat: support for delete sms (#13)
1 parent 6ec6075 commit 31c7fb5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

appwrite_lab/tools/sms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "appwrite-lab"
7-
version = "0.1.3"
7+
version = "0.1.4"
88
description = "Zero-click Appwrite test environments."
99
readme = "README.md"
1010
requires-python = ">=3.11"

twilio-shim/main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from fastapi import FastAPI, Body, Form, Request
22
from fastapi.responses import HTMLResponse, JSONResponse
3-
from typing import List, Dict
43
from datetime import datetime
4+
from uuid import uuid4
55

66
app = 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")
3239
async 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

0 commit comments

Comments
 (0)