stage24-self-hosted-gateway.py
TEXT FILE723 B · Public source code for developers, search crawlers and AI agents
1def dispatch(operation, payload, handlers):
2 if operation not in ("receive", "observe"): raise PermissionError("operation denied")
3 if type(payload) is not dict or set(payload) != {"order_id"} or type(payload["order_id"]) is not str or not payload["order_id"]:
4 raise ValueError("invalid request")
5 return handlers[operation](payload["order_id"])
6
7if __name__ == "__main__":
8 handlers={"receive":lambda order:{"order":order,"address":"fixture-only"},"observe":lambda order:{"state":"pending"}}
9 assert dispatch("observe",{"order_id":"o"},handlers)=={"state":"pending"}
10 try: dispatch("send",{"order_id":"o"},handlers)
11 except PermissionError: pass
12 else: raise AssertionError("send allowed")Read-only source · Select a line number to link directly · Raw download above
