Update the caller class

- has now ErrorResponse return values instead of None on errors
- changed parameter cafile to ca_file and its position in the init method
- Proxy has ProxyConfig Typed Dict format

Tests updates to reflect those changes
This commit is contained in:
Clemens Schwaighofer
2026-01-30 18:17:41 +09:00
parent 163b8c4018
commit 5319a059ad
2 changed files with 116 additions and 81 deletions

View File

@@ -45,14 +45,14 @@ class Caller:
def __init__(
self,
header: dict[str, str],
verify: bool = True,
timeout: int = 20,
proxy: ProxyConfig | None = None,
cafile: str | None = None
verify: bool = True,
ca_file: str | None = None
):
self.headers = header
self.timeout: int = timeout
self.cafile = cafile
self.ca_file = ca_file
self.verify = verify
self.proxy = cast(dict[str, str], proxy) if proxy is not None else None
@@ -93,7 +93,7 @@ class Caller:
timeout=self.__timeout(timeout),
verify=self.verify,
proxies=self.proxy,
cert=self.cafile
cert=self.ca_file
)
if action == "post":
return requests.post(
@@ -104,7 +104,7 @@ class Caller:
timeout=self.__timeout(timeout),
verify=self.verify,
proxies=self.proxy,
cert=self.cafile
cert=self.ca_file
)
if action == "put":
return requests.put(
@@ -115,7 +115,7 @@ class Caller:
timeout=self.__timeout(timeout),
verify=self.verify,
proxies=self.proxy,
cert=self.cafile
cert=self.ca_file
)
if action == "patch":
return requests.patch(
@@ -126,7 +126,7 @@ class Caller:
timeout=self.__timeout(timeout),
verify=self.verify,
proxies=self.proxy,
cert=self.cafile
cert=self.ca_file
)
if action == "delete":
return requests.delete(
@@ -136,7 +136,7 @@ class Caller:
timeout=self.__timeout(timeout),
verify=self.verify,
proxies=self.proxy,
cert=self.cafile
cert=self.ca_file
)
return ErrorResponse(
100,