From 655b2799d10a49f52d437951e490209ecde217f8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-10GD4VQ\\Sufyan" Date: Tue, 28 Oct 2025 11:12:49 +0500 Subject: [PATCH] feat(core-http): add HttpClientProvider for custom client injection Introduce an abstract base class `HttpClientProvider` to define a consistent contract for custom HTTP clients. * Enforces `timeout` and `session` properties for injected clients * Ensures uniform configuration handling across SDK HTTP operations * Improves extensibility, type safety, and maintainability of the HTTP layer --- .../client/http_client_provider.py | 33 +++++++++++++++++++ requirements.txt | 3 +- setup.py | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 apimatic_core_interfaces/client/http_client_provider.py diff --git a/apimatic_core_interfaces/client/http_client_provider.py b/apimatic_core_interfaces/client/http_client_provider.py new file mode 100644 index 0000000..0107a83 --- /dev/null +++ b/apimatic_core_interfaces/client/http_client_provider.py @@ -0,0 +1,33 @@ +from abc import ABC, abstractmethod +from requests import Session + + +class HttpClientProvider(ABC): + """Defines a contract for providing HTTP client configuration. + + Classes implementing this interface are expected to supply a configured + HTTP session and timeout value that will be used by the SDK's internal + HTTP layer when making network requests. + + This allows developers to inject their own custom HTTP clients while + maintaining compatibility with the SDK's request/response handling. + """ + + @property + @abstractmethod + def timeout(self) -> float: + """The default request timeout in seconds. + + Returns: + float: The timeout duration to apply to all outgoing HTTP requests. + """ + + @property + @abstractmethod + def session(self) -> Session: + """The underlying HTTP session instance. + + Returns: + Session: A configured ``requests.Session`` object used to perform + network operations such as GET, POST, and PUT calls. + """ diff --git a/requirements.txt b/requirements.txt index 0fefbd5..900b795 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -setuptools>=68.0.0 \ No newline at end of file +setuptools>=68.0.0 +requests~=2.31 \ No newline at end of file diff --git a/setup.py b/setup.py index cfb7a70..03be376 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core-interfaces', - version='0.1.7', + version='0.1.8', description='An abstract layer of the functionalities provided by apimatic-core-library, requests-client-adapter ' 'and APIMatic SDKs.', long_description=long_description,