From 2f62670fe5cf2d69993761e593a0124b1734ea77 Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Sat, 1 Mar 2025 23:04:56 +0000 Subject: [PATCH 1/2] BaseAPIClient: add request_session constructor argument for injecting an externally constructed/configured requests.Session object --- notifications_python_client/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/notifications_python_client/base.py b/notifications_python_client/base.py index 333c346..49a4326 100644 --- a/notifications_python_client/base.py +++ b/notifications_python_client/base.py @@ -13,7 +13,13 @@ class BaseAPIClient: - def __init__(self, api_key, base_url="https://api.notifications.service.gov.uk", timeout=30): + def __init__( + self, + api_key, + base_url="https://api.notifications.service.gov.uk", + timeout=30, + request_session=None, + ): """ Initialise the client Error if either of base_url or secret missing @@ -32,7 +38,7 @@ def __init__(self, api_key, base_url="https://api.notifications.service.gov.uk", self.service_id = service_id self.api_key = api_key self.timeout = timeout - self.request_session = requests.Session() + self.request_session = request_session or requests.Session() def put(self, url, data): return self.request("PUT", url, data=data) From 5eafd129144f5006e2d7bf501a9c38450979d4b6 Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Sat, 1 Mar 2025 23:09:02 +0000 Subject: [PATCH 2/2] Bump version to 10.1.0 --- CHANGELOG.md | 4 ++++ notifications_python_client/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc3b85..9572383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 10.1.0 + +* BaseAPIClient: add request_session constructor argument + ## 10.0.1 * Fix get_received_texts_iterator() method diff --git a/notifications_python_client/__init__.py b/notifications_python_client/__init__.py index 436df44..887bf8d 100644 --- a/notifications_python_client/__init__.py +++ b/notifications_python_client/__init__.py @@ -7,7 +7,7 @@ # # -- http://semver.org/ -__version__ = "10.0.1" +__version__ = "10.1.0" from notifications_python_client.errors import ( # noqa REQUEST_ERROR_MESSAGE,