Skip to content

Commit

Permalink
Merge pull request #47 from rfverbruggen/1.0.3
Browse files Browse the repository at this point in the history
1.0.3
  • Loading branch information
rfverbruggen committed Oct 10, 2020
2 parents 00a74be + 58bfc6f commit e078d33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions rachiopy/rachioobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@
class RachioObject:
"""The Rachio base object."""

def __init__(self, authtoken: str, http_session=None):
def __init__(self, authtoken: str, http_session=None, timeout=25):
"""Rachioobject class initializer.
:param authtoken: The API authentication token.
:type authtoken: str
:param http_session: The HTTP Session
:type http_session: Session
:param timeout: How long to wait for the server to send data before
giving up, as a float, or a (connect timeout, read timeout) tuple.
:type timeout: float
:type timeout: tuple
"""
self.authtoken = authtoken
self._headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {authtoken}",
}
self._http_session = http_session or Session()
self.timeout = timeout

def _request(self, path: str, method: str, body=None):
"""Make a request from the API.
Expand All @@ -39,7 +45,7 @@ def _request(self, path: str, method: str, body=None):

url = f"{_API_URL}/{path}"
response = self._http_session.request(
method, url, headers=self._headers, data=body
method, url, headers=self._headers, data=body, timeout=self.timeout
)

content_type = response.headers.get("content-type")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Rachiopy setup script."""
from setuptools import find_packages, setup

VERSION = "1.0.2"
VERSION = "1.0.3"

GITHUB_USERNAME = "rfverbruggen"
GITHUB_REPOSITORY = "rachiopy"
Expand Down

0 comments on commit e078d33

Please sign in to comment.