kbot-py-client 2.0.3__tar.gz → 2.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kbot-py-client
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: Client for Konverso Kbot
5
5
  Home-page: https://www.konverso.ai
6
6
  Author: Konverso
@@ -176,7 +176,11 @@ class Client:
176
176
  self.__reset_headers(r.json())
177
177
 
178
178
  def __request(self, method: str, uri : str = None, data: dict = None, params: dict = None, files: dict = None, attempt=0):
179
- dump_data = json.dumps(data or {})
179
+ if files:
180
+ # For file upload, the data must be a dictionnary
181
+ dump_data = data
182
+ else:
183
+ dump_data = json.dumps(data or {})
180
184
 
181
185
  if files:
182
186
  headers = self._headers.copy()
@@ -185,7 +189,7 @@ class Client:
185
189
  else:
186
190
  headers = self._headers
187
191
 
188
- r = requests.request(method.upper(), self.url + '/api/%s/' % (uri), params=params, data=dump_data, headers=headers, verify=self.verify)
192
+ r = requests.request(method.upper(), self.url + '/api/%s/' % (uri), params=params, data=dump_data, headers=headers, files=files, verify=self.verify)
189
193
 
190
194
  if r.status_code == 401:
191
195
  # Refresh the token
@@ -204,8 +208,8 @@ class Client:
204
208
 
205
209
  return r
206
210
 
207
- def request(self, method: str, uri: str, data: dict = None, params: dict = None):
208
- return self.__request(method, uri=uri, data=data, params=params)
211
+ def request(self, method: str, uri: str, data: dict = None, params: dict = None, files: dict = None):
212
+ return self.__request(method, uri=uri, data=data, params=params, files=files)
209
213
 
210
214
  def unit(self, name: str, params=None) -> dict:
211
215
  r = self.get(name, params)
@@ -28,9 +28,7 @@ class Client:
28
28
  else:
29
29
  proto = 'http'
30
30
 
31
- if proto == "https" and port == 443:
32
- self.url = "%s://%s" % (proto, server)
33
- elif proto == "https" and port == 443:
31
+ if port in (80, 443):
34
32
  self.url = "%s://%s" % (proto, server)
35
33
  else:
36
34
  self.url = "%s://%s:%s" % (proto, server, port)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kbot-py-client
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: Client for Konverso Kbot
5
5
  Home-page: https://www.konverso.ai
6
6
  Author: Konverso
@@ -5,7 +5,7 @@ with open("README.md", mode="r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="kbot-py-client",
8
- version="2.0.3",
8
+ version="2.0.4",
9
9
  author="Konverso",
10
10
  author_email="contact@konverso.ai",
11
11
  description="Client for Konverso Kbot",
File without changes
File without changes
File without changes