Coverage for atlas_ecommerce/clients/auth_proxy.py: 75%

8 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-25 16:36 +0000

1"""Auth-proxy client. 

2 

3Subclasses the SDK client so provisioning inherits its downstream HMAC signing, 

4nonce handling and retry behaviour. The request model comes from the SDK; only 

5the call itself lives here. Collapse this into a plain ``AuthProxyClient`` if 

6``provision_user`` ever ships in the SDK too. 

7""" 

8 

9from logging import getLogger 

10 

11from auth_proxy.sdk.clients.auth_proxy import AuthProxyClient 

12from auth_proxy.sdk.models import CommonUser, UserProvision 

13 

14logger = getLogger(__name__) 

15 

16 

17class EcommerceAuthProxyClient(AuthProxyClient): 

18 async def provision_user(self, payload: UserProvision) -> CommonUser: 

19 """Create, or return, a credential-less Stytch user for this email. 

20 

21 Idempotent by contract: an email that already has an account returns 

22 that account rather than erroring, so a repeat customer's order links 

23 to the user they already have. 

24 """ 

25 data = await self._make_request( 

26 "POST", 

27 "/users/provision", 

28 json_body=payload.model_dump(mode="json", exclude_none=True), 

29 ) 

30 return CommonUser(**data)