22import os
33import pathlib
44
5- from dependency_injector .wiring import inject
5+ from dependency_injector .wiring import Provide , inject
66
77from mpt_api_client import AsyncMPTClient
88from mpt_api_client .resources .accounts .buyers import Buyer
9+ from seed .container import Container
910from seed .context import Context
10- from seed .defaults import DEFAULT_CONTEXT , DEFAULT_MPT_OPERATIONS
1111
1212logger = logging .getLogger (__name__ )
1313
14- icon = pathlib .Path ("seed/ data/logo.png"). resolve ()
14+ icon = pathlib .Path (__file__ ). parent . parent / " data/logo.png"
1515
1616
1717@inject
1818async def get_buyer (
19- context : Context = DEFAULT_CONTEXT ,
20- mpt_operations : AsyncMPTClient = DEFAULT_MPT_OPERATIONS ,
19+ context : Context = Provide [ Container . context ] ,
20+ mpt_operations : AsyncMPTClient = Provide [ Container . mpt_operations ] ,
2121) -> Buyer | None :
2222 """Get buyer from context or fetch from API."""
2323 buyer_id = context .get_string ("accounts.buyer.id" )
@@ -36,7 +36,7 @@ async def get_buyer(
3636
3737
3838@inject
39- def build_buyer_data (context : Context = DEFAULT_CONTEXT ) -> dict [str , object ]:
39+ def build_buyer_data (context : Context = Provide [ Container . context ] ) -> dict [str , object ]:
4040 """Build buyer data dictionary for creation."""
4141 buyer_account_id = os .getenv ("CLIENT_ACCOUNT_ID" )
4242 if not buyer_account_id :
@@ -65,8 +65,8 @@ def build_buyer_data(context: Context = DEFAULT_CONTEXT) -> dict[str, object]:
6565
6666@inject
6767async def init_buyer (
68- context : Context = DEFAULT_CONTEXT ,
69- mpt_operations : AsyncMPTClient = DEFAULT_MPT_OPERATIONS ,
68+ context : Context = Provide [ Container . context ] ,
69+ mpt_operations : AsyncMPTClient = Provide [ Container . mpt_operations ] ,
7070) -> Buyer :
7171 """Get or create buyer."""
7272 buyer = await get_buyer (context = context , mpt_operations = mpt_operations )
0 commit comments