Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ with AxmeClient(config) as client:
idempotency_key="reply-001",
)
print(replied)
approval = client.decide_approval(
"55555555-5555-4555-8555-555555555555",
decision="approve",
comment="Looks good",
idempotency_key="approval-001",
)
print(approval["approval"]["decision"])
capabilities = client.get_capabilities()
print(capabilities["supported_intent_types"])
subscription = client.upsert_webhook_subscription(
{
"callback_url": "https://integrator.example/webhooks/axme",
Expand Down
24 changes: 24 additions & 0 deletions axme_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,30 @@ def reply_inbox_thread(
retryable=idempotency_key is not None,
)

def decide_approval(
self,
approval_id: str,
*,
decision: str,
comment: str | None = None,
idempotency_key: str | None = None,
trace_id: str | None = None,
) -> dict[str, Any]:
payload: dict[str, Any] = {"decision": decision}
if comment is not None:
payload["comment"] = comment
return self._request_json(
"POST",
f"/v1/approvals/{approval_id}/decision",
json_body=payload,
idempotency_key=idempotency_key,
trace_id=trace_id,
retryable=idempotency_key is not None,
)

def get_capabilities(self, *, trace_id: str | None = None) -> dict[str, Any]:
return self._request_json("GET", "/v1/capabilities", trace_id=trace_id, retryable=True)

def upsert_webhook_subscription(
self,
payload: dict[str, Any],
Expand Down
47 changes: 47 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,53 @@ def handler(request: httpx.Request) -> httpx.Response:
}


def test_decide_approval_success() -> None:
approval_id = "55555555-5555-4555-8555-555555555555"

def handler(request: httpx.Request) -> httpx.Response:
assert request.method == "POST"
assert request.url.path == f"/v1/approvals/{approval_id}/decision"
assert request.headers["idempotency-key"] == "approval-1"
assert request.read() == b'{"decision":"approve","comment":"approved"}'
return httpx.Response(
200,
json={
"ok": True,
"approval": {
"approval_id": approval_id,
"decision": "approve",
"comment": "approved",
"decided_at": "2026-02-28T00:00:01Z",
},
},
)

client = _client(handler)
assert client.decide_approval(
approval_id,
decision="approve",
comment="approved",
idempotency_key="approval-1",
)["approval"]["approval_id"] == approval_id


def test_get_capabilities_success() -> None:
def handler(request: httpx.Request) -> httpx.Response:
assert request.method == "GET"
assert request.url.path == "/v1/capabilities"
return httpx.Response(
200,
json={
"ok": True,
"capabilities": ["inbox", "intents"],
"supported_intent_types": ["intent.ask.v1", "intent.notify.v1"],
},
)

client = _client(handler)
assert client.get_capabilities()["ok"] is True


@pytest.mark.parametrize(
("status_code", "expected_exception"),
[
Expand Down