telesign 2.2.3__py2.py3-none-any.whl → 2.2.4__py2.py3-none-any.whl

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.
telesign/phoneid.py CHANGED
@@ -24,31 +24,5 @@ class PhoneIdClient(RestClient):
24
24
  See https://developer.telesign.com/docs/phoneid-api for detailed API documentation.
25
25
  """
26
26
  return self.post(PHONEID_RESOURCE.format(phone_number=phone_number),
27
- **params)
28
-
29
- def _execute(self, method_function, method_name, resource, **params):
30
- resource_uri = "{api_host}{resource}".format(api_host=self.api_host, resource=resource)
31
-
32
- json_fields = json.dumps(params)
33
-
34
- content_type = "application/json" if method_name in ("POST", "PUT") else ""
35
-
36
- headers = self.generate_telesign_headers(self.customer_id,
37
- self.api_key,
38
- method_name,
39
- resource,
40
- json_fields,
41
- user_agent=self.user_agent,
42
- content_type=content_type)
43
-
44
- if method_name in ['POST', 'PUT']:
45
- payload = {'data': json_fields}
46
- else:
47
- payload = {'params': json_fields}
48
-
49
- response = self.Response(method_function(resource_uri,
50
- headers=headers,
51
- timeout=self.timeout,
52
- **payload))
53
-
54
- return response
27
+ json_fields=params,
28
+ **params)
telesign/rest.py CHANGED
@@ -8,6 +8,7 @@ from hashlib import sha256
8
8
  from platform import python_version
9
9
 
10
10
  import requests
11
+ import json
11
12
 
12
13
  import telesign
13
14
  from telesign.util import AuthMethod
@@ -118,14 +119,14 @@ class RestClient(requests.models.RequestEncodingMixin):
118
119
  content_type = "application/x-www-form-urlencoded" if method_name in ("POST", "PUT") else ""
119
120
 
120
121
  # Default auth_method is Digest if not explicitly specified
121
- if auth_method == AuthMethod.BASIC.value:
122
+ if auth_method == AuthMethod.BASIC:
122
123
  usr_apikey = "{customer_id}:{api_key}".format(customer_id=customer_id,
123
124
  api_key=api_key)
124
125
  b64val = b64encode(usr_apikey.encode())
125
- authorization = "{auth_method} {b64val}".format(auth_method=AuthMethod.BASIC.value,
126
+ authorization = "{auth_method} {b64val}".format(auth_method=AuthMethod.BASIC,
126
127
  b64val=b64val.decode())
127
128
  else:
128
- auth_method = AuthMethod.HMAC_SHA256.value
129
+ auth_method = AuthMethod.HMAC_SHA256
129
130
 
130
131
  string_to_sign_builder = ["{method}".format(method=method_name)]
131
132
 
@@ -164,7 +165,7 @@ class RestClient(requests.models.RequestEncodingMixin):
164
165
 
165
166
  return headers
166
167
 
167
- def post(self, resource, body=None, **query_params):
168
+ def post(self, resource, body=None, json_fields=None, **query_params):
168
169
  """
169
170
  Generic TeleSign REST API POST handler.
170
171
 
@@ -173,9 +174,9 @@ class RestClient(requests.models.RequestEncodingMixin):
173
174
  :param query_params: query_params to perform the POST request with, as a dictionary.
174
175
  :return: The RestClient Response object.
175
176
  """
176
- return self._execute(self.session.post, 'POST', resource, body, **query_params)
177
+ return self._execute(self.session.post, 'POST', resource, body, json_fields, **query_params)
177
178
 
178
- def get(self, resource, body=None, **query_params):
179
+ def get(self, resource, body=None, json_fields=None, **query_params):
179
180
  """
180
181
  Generic TeleSign REST API GET handler.
181
182
 
@@ -184,9 +185,9 @@ class RestClient(requests.models.RequestEncodingMixin):
184
185
  :param query_params: query_params to perform the GET request with, as a dictionary.
185
186
  :return: The RestClient Response object.
186
187
  """
187
- return self._execute(self.session.get, 'GET', resource, body, **query_params)
188
+ return self._execute(self.session.get, 'GET', resource, body, json_fields, **query_params)
188
189
 
189
- def put(self, resource, body=None, **query_params):
190
+ def put(self, resource, body=None, json_fields=None, **query_params):
190
191
  """
191
192
  Generic TeleSign REST API PUT handler.
192
193
 
@@ -195,9 +196,9 @@ class RestClient(requests.models.RequestEncodingMixin):
195
196
  :param query_params: query_params to perform the PUT request with, as a dictionary.
196
197
  :return: The RestClient Response object.
197
198
  """
198
- return self._execute(self.session.put, 'PUT', resource, body, **query_params)
199
+ return self._execute(self.session.put, 'PUT', resource, body, json_fields, **query_params)
199
200
 
200
- def delete(self, resource, body=None, **query_params):
201
+ def delete(self, resource, body=None, json_fields=None, **query_params):
201
202
  """
202
203
  Generic TeleSign REST API DELETE handler.
203
204
 
@@ -206,9 +207,9 @@ class RestClient(requests.models.RequestEncodingMixin):
206
207
  :param query_params: query_params to perform the DELETE request with, as a dictionary.
207
208
  :return: The RestClient Response object.
208
209
  """
209
- return self._execute(self.session.delete, 'DELETE', resource, body, **query_params)
210
+ return self._execute(self.session.delete, 'DELETE', resource, body, json_fields, **query_params)
210
211
 
211
- def _execute(self, method_function, method_name, resource, body=None, **query_params):
212
+ def _execute(self, method_function, method_name, resource, body=None, json_fields=None, **query_params):
212
213
  """
213
214
  Generic TeleSign REST API request handler.
214
215
 
@@ -222,7 +223,11 @@ class RestClient(requests.models.RequestEncodingMixin):
222
223
  resource_uri = "{api_host}{resource}".format(api_host=self.api_host, resource=resource)
223
224
 
224
225
  url_encoded_fields = self._encode_params(query_params)
225
- if body:
226
+ if json_fields:
227
+ fields = json.dumps(json_fields)
228
+ url_encoded_fields = fields
229
+
230
+ if body or json_fields:
226
231
  content_type = "application/json"
227
232
  else:
228
233
  content_type = None # set later
@@ -235,13 +240,14 @@ class RestClient(requests.models.RequestEncodingMixin):
235
240
  user_agent=self.user_agent,
236
241
  content_type=content_type,
237
242
  auth_method=self.auth_method)
238
-
239
243
  if method_name in ['POST', 'PUT']:
240
244
  payload = {}
241
245
  if body:
242
246
  payload['json'] = body
243
247
  if query_params:
244
248
  payload['data'] = url_encoded_fields
249
+ if json_fields:
250
+ payload = {'data': url_encoded_fields}
245
251
  else:
246
252
  payload = {'params': url_encoded_fields}
247
253
 
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: telesign
3
- Version: 2.2.3
3
+ Version: 2.2.4
4
4
  Summary: TeleSign SDK
5
5
  Home-page: https://github.com/telesign/python_telesign
6
6
  Author: TeleSign Corp.
7
7
  Author-email: support@telesign.com
8
8
  License: MIT
9
9
  Keywords: telesign,sms,voice,mobile,authentication,identity,messaging
10
+ Platform: UNKNOWN
10
11
  Classifier: Development Status :: 5 - Production/Stable
11
12
  Classifier: Intended Audience :: Developers
12
13
  Classifier: License :: OSI Approved :: MIT License
@@ -20,7 +21,6 @@ Classifier: Programming Language :: Python :: 3.3
20
21
  Classifier: Programming Language :: Python :: 3.4
21
22
  Classifier: Programming Language :: Python :: 3.5
22
23
  Classifier: Programming Language :: Python :: 3.6
23
- License-File: LICENSE.txt
24
24
  Requires-Dist: requests
25
25
 
26
26
  .. image:: https://raw.github.com/TeleSign/python_telesign/master/python_banner.jpg
@@ -105,7 +105,7 @@ Here is a basic code example with the JSON response.
105
105
  print(response.json)
106
106
 
107
107
  .. code-block:: javascript
108
-
108
+
109
109
  {'reference_id': 'DGFDF6E11AB86303ASDFD425BE00000657',
110
110
  'status': {'code': 103,
111
111
  'description': 'Call in progress',
@@ -113,3 +113,5 @@ Here is a basic code example with the JSON response.
113
113
 
114
114
  For more examples, see the `examples <https://github.com/TeleSign/python_telesign/tree/master/examples>`_ folder or
115
115
  visit the `TeleSign Standard Documentation <https://standard.telesign.com/>`_.
116
+
117
+
@@ -2,13 +2,13 @@ telesign/__init__.py,sha256=D8kANX0FKxBD7-a7xQ21xPz3ojM2WAOK8lThGLtDZuE,367
2
2
  telesign/appverify.py,sha256=wBeaeUxGmYcZkrbxkkXlG3-0oZr5sVvegzVpdvaoO2A,1195
3
3
  telesign/intelligence.py,sha256=t-xwlgxkXw1OMupF5K4_UKWeTArOr9XPvddmqgZftPI,1452
4
4
  telesign/messaging.py,sha256=v7l-eKUPqz7Nrwka0YNPMkC2TaoFUvQm3yp_djuTPu0,1367
5
- telesign/phoneid.py,sha256=czEVgjDmbbWgDGanqclNhlmAYkD1jLYhEOXQs7M9F88,2111
6
- telesign/rest.py,sha256=BtiRi0dc5h4OiWapdsfSBvLLwXB5swrwiACT7R-UAkc,11058
5
+ telesign/phoneid.py,sha256=mk03NxL3wlaXpd8b-BB6q_SKfCxbtuTO19ayAHxmzz0,954
6
+ telesign/rest.py,sha256=PsrVpzRznfJVv7QxXM-1x62BdAuAUJeNqsXRaIYaYOc,11401
7
7
  telesign/score.py,sha256=Kceu6IrirN9SsuT1geEWs0QHAn6H9ZNFyIDVHcBJdwg,908
8
8
  telesign/util.py,sha256=stDxpL5ZQeGskE_OSGP04UFHs3ZP2ACaRpW1WyQGMHg,1624
9
9
  telesign/voice.py,sha256=DJaWyQpun-T7LfNjpxpsUjupiv2ShW1jqoFQA-CE2-Y,1341
10
- telesign-2.2.3.dist-info/LICENSE.txt,sha256=a--xZ4PCKUL5rpct8RrUC6ODU_8ZKIU51kJPfsA4HUs,1058
11
- telesign-2.2.3.dist-info/METADATA,sha256=0XcO1v2ZEwFJt2yzWdUH_L6tc7zAXLJeRxZQ3WieMF0,4545
12
- telesign-2.2.3.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
13
- telesign-2.2.3.dist-info/top_level.txt,sha256=6LG7Jcr1jnpVhOWaIShoTdwYJn0QCfPhfudyVJNz1qg,9
14
- telesign-2.2.3.dist-info/RECORD,,
10
+ telesign-2.2.4.dist-info/LICENSE.txt,sha256=a--xZ4PCKUL5rpct8RrUC6ODU_8ZKIU51kJPfsA4HUs,1058
11
+ telesign-2.2.4.dist-info/METADATA,sha256=AydnJnTgwrypVvEq8hcDJosiAx1TJPZPP4zpxgszbw0,4532
12
+ telesign-2.2.4.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
13
+ telesign-2.2.4.dist-info/top_level.txt,sha256=6LG7Jcr1jnpVhOWaIShoTdwYJn0QCfPhfudyVJNz1qg,9
14
+ telesign-2.2.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: bdist_wheel (0.37.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any