Compare commits

..

No commits in common. "master" and "1.0.1" have entirely different histories.

4 changed files with 9 additions and 13 deletions

1
.gitignore vendored
View file

@ -15,7 +15,6 @@ Homestead.yaml
npm-debug.log
yarn-error.log
public/robots.txt
__pycache__
# OS generated files #
######################

View file

@ -47,8 +47,6 @@ class Client:
# Close socket connection when class instance removed
def __del__(self):
# Close socket if connected
if (self._con == Connection.AF_UNIX):
self._socket.close()
# Resolve connection type from endpoint string.
@ -66,9 +64,9 @@ class Client:
"Content-Type": "application/json"
}
# Append Authorization header if API key is provided
# Append Authentication header if API key is provided
if (self._key):
headers["Authorization"] = f"Bearer {self._key}"
headers["Authentication"] = f"Bearer {self._key}"
return headers
@ -77,9 +75,9 @@ class Client:
# Remove leading "/" if present, as it's already present in self._endpoint
endpoint = endpoint if endpoint[-1] != "/" else endpoint[:-1]
resp = requests.request(method.name, self._endpoint + endpoint, verify=self._https_peer_verify, headers=self.http_headers(), data=json.dumps(payload))
# Return response as tuple of response code and response body as decoded JSON (mixed)
return (resp.status_code, json.loads(resp.text))
resp = requests.request(method.name, self._endpoint + endpoint, headers=self.http_headers(), data=json.dumps(payload))
# Return response as tuple of response code and response body as plain text
return (resp.status_code, resp.text)
def socket_txn(self, endpoint: str, method: Union[Method, str] = None, payload: list = None) -> tuple:
data = f'["{endpoint}","{method.name}","{json.dumps(payload)}"]'

View file

@ -1,3 +1,2 @@
# the "install_requires" array should also be updated when changing this
validators
requests

View file

@ -2,12 +2,12 @@ from setuptools import setup, find_packages
setup(
name = "reflect-client",
version = "1.1.2",
version = "1.0.1",
description = "Python library for communicating with an API built with Reflect over HTTP or UNIX sockets",
author = "Victor Westerlund",
author_email = "victor.vesterlund@gmail.com",
url = "https://github.com/victorwesterlund/reflect-client-python",
packages = ["reflect_client"],
# The requirement.txt file should also be updated when changing this
install_requires = ["validators", "requests"]
install_requires = ["validators"]
)