Skip to content

BaseAPIClient: add request_session constructor argument #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.1.0

* BaseAPIClient: add request_session constructor argument

## 10.0.1

* Fix get_received_texts_iterator() method
Expand Down
2 changes: 1 addition & 1 deletion notifications_python_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions notifications_python_client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down