Python client
Only needs requests:
# inboxdome.py
import os
import requests
BASE = "https://inboxdome.com"
class InboxDome:
def __init__(self, api_key: str | None = None):
self.key = api_key or os.environ["INBOXDOME_KEY"]
def _req(self, method: str, path: str, **kwargs):
res = requests.request(
method,
BASE + path,
headers={"Authorization": f"Bearer {self.key}"},
timeout=55,
**kwargs,
)
res.raise_for_status()
return res.json() if res.status_code != 204 else None
def create_inbox(self, **opts) -> dict:
return self._req("POST", "/v1/inboxes", json=opts)["inbox"]
def list_messages(self, inbox_id: str) -> list[dict]:
return self._req("GET", f"/v1/inboxes/{inbox_id}/messages")["data"]
def wait_for_otp(self, inbox_id: str, timeout: int = 30) -> str:
r = self._req("GET", f"/v1/inboxes/{inbox_id}/wait?for=otp&timeoutSeconds={timeout}")
return r["otp"]["value"]
def delete_inbox(self, inbox_id: str) -> None:
self._req("DELETE", f"/v1/inboxes/{inbox_id}")pytest example
# test_signup.py
from inboxdome import InboxDome
def test_signup_sends_verification_code(app_client):
dome = InboxDome()
inbox = dome.create_inbox()
app_client.post("/signup", data={"email": inbox["emailAddress"], "password": "S3cure!pass"})
code = dome.wait_for_otp(inbox["id"], timeout=45)
assert len(code) == 6
res = app_client.post("/verify", data={"email": inbox["emailAddress"], "code": code})
assert res.status_code == 200