55
66from gopay .enums import ContentType , Language
77from gopay .http import ApiClient , Request , Response
8- from gopay .services import DefaultCache , default_logger
98
109
1110@dataclass
@@ -24,15 +23,29 @@ def __post_init__(self):
2423 # Make sure URL will be in the form of example.com/api
2524 urlparts = urlsplit (self .config ["gateway_url" ])
2625 self .base_url = urlunsplit ((urlparts .scheme , urlparts .netloc , "/api" , "" , "" ))
26+
27+ # Prepare
28+ api_client_config = {
29+ "client_id" : self .config ["client_id" ],
30+ "client_secret" : self .config ["client_secret" ],
31+ "gateway_url" : self .base_url ,
32+ "scope" : self .config ["scope" ],
33+ }
34+
35+ # Add optional parameters if found
36+ if (timeout := self .config .get ("timeout" )) is not None :
37+ api_client_config .update ({"timeout" : timeout })
38+
39+ if (logger := self .services .get ("logger" )) is not None :
40+ api_client_config .update ({"logger" : logger })
41+
42+ if (cache := self .services .get ("cache" )) is not None :
43+ api_client_config .update ({"cache" : cache })
44+
2745
2846 # Create the API client
2947 self .api_client = ApiClient (
30- client_id = self .config ["client_id" ],
31- client_secret = self .config ["client_secret" ],
32- gateway_url = self .base_url ,
33- scope = self .config ["scope" ],
34- logger = self .services .get ("logger" ) or default_logger ,
35- cache = self .services .get ("cache" ) or DefaultCache (),
48+ ** api_client_config
3649 )
3750
3851 def call (
0 commit comments