telesign 2.2.4__tar.gz → 3.0.0__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.
- {telesign-2.2.4/telesign.egg-info → telesign-3.0.0}/PKG-INFO +1 -1
- {telesign-2.2.4 → telesign-3.0.0}/setup.py +1 -1
- {telesign-2.2.4 → telesign-3.0.0}/telesign/rest.py +69 -21
- {telesign-2.2.4 → telesign-3.0.0/telesign.egg-info}/PKG-INFO +1 -1
- {telesign-2.2.4 → telesign-3.0.0}/telesign.egg-info/SOURCES.txt +0 -4
- {telesign-2.2.4 → telesign-3.0.0}/tests/test_phoneid.py +0 -19
- {telesign-2.2.4 → telesign-3.0.0}/tests/test_rest.py +34 -1
- telesign-2.2.4/examples/appverify/1_get_status_by_external_id.py +0 -16
- telesign-2.2.4/examples/intelligence/1_get_risk_score_and_related_insights.py +0 -29
- telesign-2.2.4/telesign/appverify.py +0 -28
- telesign-2.2.4/telesign/intelligence.py +0 -39
- {telesign-2.2.4 → telesign-3.0.0}/LICENSE.txt +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/MANIFEST.in +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/README.rst +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/messaging/1_send_message.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/messaging/2_send_message_with_verification_code.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/phoneid/1_check_phone_type_to_block_voip.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/phoneid/2_cleansing.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/score/1_check_phone_number_risk_level.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/voice/1_send_voice_call.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/voice/2_send_voice_call_with_verification_code.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/examples/voice/3_send_voice_call_french.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/setup.cfg +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/__init__.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/messaging.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/phoneid.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/score.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/util.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign/voice.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign.egg-info/dependency_links.txt +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign.egg-info/requires.txt +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/telesign.egg-info/top_level.txt +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/tests/__init__.py +0 -0
- {telesign-2.2.4 → telesign-3.0.0}/tests/test_util.py +0 -0
|
@@ -6,6 +6,7 @@ from base64 import b64encode, b64decode
|
|
|
6
6
|
from email.utils import formatdate
|
|
7
7
|
from hashlib import sha256
|
|
8
8
|
from platform import python_version
|
|
9
|
+
import time
|
|
9
10
|
|
|
10
11
|
import requests
|
|
11
12
|
import json
|
|
@@ -16,18 +17,14 @@ from telesign.util import AuthMethod
|
|
|
16
17
|
|
|
17
18
|
class RestClient(requests.models.RequestEncodingMixin):
|
|
18
19
|
"""
|
|
19
|
-
The
|
|
20
|
-
|
|
20
|
+
The Telesign RestClient is a generic HTTP REST client that can be extended to make requests against any of
|
|
21
|
+
Telesign's REST API endpoints.
|
|
21
22
|
|
|
22
23
|
RequestEncodingMixin offers the function _encode_params for url encoding the body for use in string_to_sign outside
|
|
23
24
|
of a regular HTTP request.
|
|
24
25
|
|
|
25
26
|
See https://developer.telesign.com for detailed API documentation.
|
|
26
27
|
"""
|
|
27
|
-
user_agent = "TeleSignSDK/python-{sdk_version} Python/{python_version} Requests/{requests_version}".format(
|
|
28
|
-
sdk_version=telesign.__version__,
|
|
29
|
-
python_version=python_version(),
|
|
30
|
-
requests_version=requests.__version__)
|
|
31
28
|
|
|
32
29
|
class Response(object):
|
|
33
30
|
"""
|
|
@@ -51,11 +48,15 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
51
48
|
customer_id,
|
|
52
49
|
api_key,
|
|
53
50
|
rest_endpoint='https://rest-api.telesign.com',
|
|
51
|
+
source="python_telesign",
|
|
52
|
+
sdk_version_origin=None,
|
|
53
|
+
sdk_version_dependency=None,
|
|
54
54
|
proxies=None,
|
|
55
55
|
timeout=10,
|
|
56
|
-
auth_method=None
|
|
56
|
+
auth_method=None,
|
|
57
|
+
pool_recycle=480):
|
|
57
58
|
"""
|
|
58
|
-
|
|
59
|
+
Telesign RestClient useful for making generic RESTful requests against our API.
|
|
59
60
|
|
|
60
61
|
:param customer_id: Your customer_id string associated with your account.
|
|
61
62
|
:param api_key: Your api_key string associated with your account.
|
|
@@ -63,13 +64,22 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
63
64
|
:param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy.
|
|
64
65
|
:param timeout: (optional) How long to wait for the server to send data before giving up, as a float,
|
|
65
66
|
or as a (connect timeout, read timeout) tuple
|
|
67
|
+
:param pool_recycle: (optional) Time in seconds to recycle the HTTP session to avoid stale connections (default 480).
|
|
68
|
+
If a session is older than this value, it will be closed and a new session will be created automatically before each request.
|
|
69
|
+
This helps prevent errors due to HTTP keep-alive connections being closed by the server after inactivity.
|
|
70
|
+
|
|
71
|
+
HTTP Keep-Alive behavior:
|
|
72
|
+
TeleSign endpoints close idle HTTP keep-alive connections after 499 seconds. If you attempt to reuse a connection older than this, you may get a 'connection reset by peer' error.
|
|
73
|
+
By default, pool_recycle=480 ensures sessions are refreshed before this limit.
|
|
66
74
|
"""
|
|
67
75
|
self.customer_id = customer_id
|
|
68
76
|
self.api_key = api_key
|
|
69
77
|
|
|
70
78
|
self.api_host = rest_endpoint
|
|
71
79
|
|
|
72
|
-
self.
|
|
80
|
+
self.pool_recycle = pool_recycle
|
|
81
|
+
self._session_created_at = None
|
|
82
|
+
self.session = self._create_session()
|
|
73
83
|
|
|
74
84
|
self.session.proxies = proxies if proxies else {}
|
|
75
85
|
|
|
@@ -77,6 +87,17 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
77
87
|
|
|
78
88
|
self.auth_method = auth_method
|
|
79
89
|
|
|
90
|
+
current_version_sdk = telesign.__version__ if source == "python_telesign" else sdk_version_origin
|
|
91
|
+
|
|
92
|
+
self.user_agent = "TeleSignSDK/python Python/{python_version} Requests/{requests_version} OriginatingSDK/{source} SDKVersion/{sdk_version}".format(
|
|
93
|
+
python_version=python_version(),
|
|
94
|
+
requests_version=requests.__version__,
|
|
95
|
+
source=source,
|
|
96
|
+
sdk_version=current_version_sdk)
|
|
97
|
+
|
|
98
|
+
if source != "python_telesign":
|
|
99
|
+
self.user_agent = self.user_agent + " DependencySDKVersion/{sdk_version_dependency}".format(sdk_version_dependency=sdk_version_dependency)
|
|
100
|
+
|
|
80
101
|
@staticmethod
|
|
81
102
|
def generate_telesign_headers(customer_id,
|
|
82
103
|
api_key,
|
|
@@ -89,17 +110,17 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
89
110
|
content_type=None,
|
|
90
111
|
auth_method=None):
|
|
91
112
|
"""
|
|
92
|
-
Generates the
|
|
113
|
+
Generates the Telesign REST API headers used to authenticate requests.
|
|
93
114
|
|
|
94
115
|
Creates the canonicalized string_to_sign and generates the HMAC signature. This is used to authenticate requests
|
|
95
|
-
against the
|
|
116
|
+
against the Telesign REST API.
|
|
96
117
|
|
|
97
118
|
See https://developer.telesign.com/docs/authentication for detailed API documentation.
|
|
98
119
|
|
|
99
120
|
:param customer_id: Your account customer_id.
|
|
100
121
|
:param api_key: Your account api_key.
|
|
101
122
|
:param method_name: The HTTP method name of the request as a upper case string, should be one of 'POST', 'GET',
|
|
102
|
-
'PUT' or 'DELETE'.
|
|
123
|
+
'PUT', 'PATCH' or 'DELETE'.
|
|
103
124
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
104
125
|
:param url_encoded_fields: HTTP body parameters to perform the HTTP request with, must be a urlencoded string.
|
|
105
126
|
:param date_rfc2616: The date and time of the request formatted in rfc 2616, as a string.
|
|
@@ -107,7 +128,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
107
128
|
:param user_agent: (optional) User Agent associated with the request, as a string.
|
|
108
129
|
:param content_type: (optional) ContentType of the request, as a string.
|
|
109
130
|
:param auth_method: (optional) Authentication type ex: Basic, HMAC etc
|
|
110
|
-
:return: The
|
|
131
|
+
:return: The Telesign authentication headers.
|
|
111
132
|
"""
|
|
112
133
|
if date_rfc2616 is None:
|
|
113
134
|
date_rfc2616 = formatdate(usegmt=True)
|
|
@@ -119,14 +140,14 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
119
140
|
content_type = "application/x-www-form-urlencoded" if method_name in ("POST", "PUT") else ""
|
|
120
141
|
|
|
121
142
|
# Default auth_method is Digest if not explicitly specified
|
|
122
|
-
if auth_method == AuthMethod.BASIC:
|
|
143
|
+
if auth_method == AuthMethod.BASIC.value:
|
|
123
144
|
usr_apikey = "{customer_id}:{api_key}".format(customer_id=customer_id,
|
|
124
145
|
api_key=api_key)
|
|
125
146
|
b64val = b64encode(usr_apikey.encode())
|
|
126
|
-
authorization = "{auth_method} {b64val}".format(auth_method=AuthMethod.BASIC,
|
|
147
|
+
authorization = "{auth_method} {b64val}".format(auth_method=AuthMethod.BASIC.value,
|
|
127
148
|
b64val=b64val.decode())
|
|
128
149
|
else:
|
|
129
|
-
auth_method = AuthMethod.HMAC_SHA256
|
|
150
|
+
auth_method = AuthMethod.HMAC_SHA256.value
|
|
130
151
|
|
|
131
152
|
string_to_sign_builder = ["{method}".format(method=method_name)]
|
|
132
153
|
|
|
@@ -167,7 +188,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
167
188
|
|
|
168
189
|
def post(self, resource, body=None, json_fields=None, **query_params):
|
|
169
190
|
"""
|
|
170
|
-
Generic
|
|
191
|
+
Generic Telesign REST API POST handler.
|
|
171
192
|
|
|
172
193
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
173
194
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -178,7 +199,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
178
199
|
|
|
179
200
|
def get(self, resource, body=None, json_fields=None, **query_params):
|
|
180
201
|
"""
|
|
181
|
-
Generic
|
|
202
|
+
Generic Telesign REST API GET handler.
|
|
182
203
|
|
|
183
204
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
184
205
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -189,7 +210,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
189
210
|
|
|
190
211
|
def put(self, resource, body=None, json_fields=None, **query_params):
|
|
191
212
|
"""
|
|
192
|
-
Generic
|
|
213
|
+
Generic Telesign REST API PUT handler.
|
|
193
214
|
|
|
194
215
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
195
216
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -198,9 +219,12 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
198
219
|
"""
|
|
199
220
|
return self._execute(self.session.put, 'PUT', resource, body, json_fields, **query_params)
|
|
200
221
|
|
|
222
|
+
def set_endpoint(self, rest_endpoint):
|
|
223
|
+
self.api_host = rest_endpoint
|
|
224
|
+
|
|
201
225
|
def delete(self, resource, body=None, json_fields=None, **query_params):
|
|
202
226
|
"""
|
|
203
|
-
Generic
|
|
227
|
+
Generic Telesign REST API DELETE handler.
|
|
204
228
|
|
|
205
229
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
206
230
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -208,10 +232,33 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
208
232
|
:return: The RestClient Response object.
|
|
209
233
|
"""
|
|
210
234
|
return self._execute(self.session.delete, 'DELETE', resource, body, json_fields, **query_params)
|
|
235
|
+
|
|
236
|
+
def patch(self, resource, body=None, json_fields=None, **query_params):
|
|
237
|
+
"""
|
|
238
|
+
Generic Telesign REST API PATCH handler.
|
|
239
|
+
|
|
240
|
+
:param resource: The partial resource URI to perform the request against, as a string.
|
|
241
|
+
:param body: (optional) A dictionary sent as a part of request body.
|
|
242
|
+
:param json_fields: (optional) A dictionary sent as a JSON body.
|
|
243
|
+
:param query_params: query_params to perform the PATCH request with, as a dictionary.
|
|
244
|
+
:return: The RestClient Response object.
|
|
245
|
+
"""
|
|
246
|
+
return self._execute(self.session.patch, 'PATCH', resource, body, json_fields, **query_params)
|
|
247
|
+
|
|
248
|
+
def _create_session(self):
|
|
249
|
+
session = requests.Session()
|
|
250
|
+
self._session_created_at = time.time()
|
|
251
|
+
return session
|
|
252
|
+
|
|
253
|
+
def _ensure_session(self):
|
|
254
|
+
if self._session_created_at is None or (time.time() - self._session_created_at > self.pool_recycle):
|
|
255
|
+
if self.session:
|
|
256
|
+
self.session.close()
|
|
257
|
+
self.session = self._create_session()
|
|
211
258
|
|
|
212
259
|
def _execute(self, method_function, method_name, resource, body=None, json_fields=None, **query_params):
|
|
213
260
|
"""
|
|
214
|
-
Generic
|
|
261
|
+
Generic Telesign REST API request handler.
|
|
215
262
|
|
|
216
263
|
:param method_function: The Requests HTTP request function to perform the request.
|
|
217
264
|
:param method_name: The HTTP method name, as an upper case string.
|
|
@@ -220,6 +267,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
220
267
|
:param query_params: query_params to perform the HTTP request with, as a dictionary.
|
|
221
268
|
:return: The RestClient Response object.
|
|
222
269
|
"""
|
|
270
|
+
self._ensure_session()
|
|
223
271
|
resource_uri = "{api_host}{resource}".format(api_host=self.api_host, resource=resource)
|
|
224
272
|
|
|
225
273
|
url_encoded_fields = self._encode_params(query_params)
|
|
@@ -3,8 +3,6 @@ MANIFEST.in
|
|
|
3
3
|
README.rst
|
|
4
4
|
setup.cfg
|
|
5
5
|
setup.py
|
|
6
|
-
examples/appverify/1_get_status_by_external_id.py
|
|
7
|
-
examples/intelligence/1_get_risk_score_and_related_insights.py
|
|
8
6
|
examples/messaging/1_send_message.py
|
|
9
7
|
examples/messaging/2_send_message_with_verification_code.py
|
|
10
8
|
examples/phoneid/1_check_phone_type_to_block_voip.py
|
|
@@ -14,8 +12,6 @@ examples/voice/1_send_voice_call.py
|
|
|
14
12
|
examples/voice/2_send_voice_call_with_verification_code.py
|
|
15
13
|
examples/voice/3_send_voice_call_french.py
|
|
16
14
|
telesign/__init__.py
|
|
17
|
-
telesign/appverify.py
|
|
18
|
-
telesign/intelligence.py
|
|
19
15
|
telesign/messaging.py
|
|
20
16
|
telesign/phoneid.py
|
|
21
17
|
telesign/rest.py
|
|
@@ -17,25 +17,6 @@ class TestPhoneId(TestCase):
|
|
|
17
17
|
self.assertEqual(client.customer_id, self.customer_id)
|
|
18
18
|
self.assertEqual(client.api_key, self.api_key)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
def test_phoneid_pid_contact(self):
|
|
22
|
-
|
|
23
|
-
client = PhoneIdClient(self.customer_id, self.api_key)
|
|
24
|
-
content_type_expected = 'application/json'
|
|
25
|
-
status_code_expected = 200
|
|
26
|
-
|
|
27
|
-
payload = {
|
|
28
|
-
"addons": {
|
|
29
|
-
"contact": {}
|
|
30
|
-
},
|
|
31
|
-
"phone_number": self.phone_number_test
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
response = client.phoneid(**payload)
|
|
35
|
-
|
|
36
|
-
self.assertEqual(response.headers.get('Content-Type'), content_type_expected, "Content-Type args do not match expected")
|
|
37
|
-
self.assertEqual(response.status_code, status_code_expected, "Status code args do not match expected")
|
|
38
|
-
|
|
39
20
|
def test_phoneid_pid(self):
|
|
40
21
|
|
|
41
22
|
client = PhoneIdClient(self.customer_id, self.api_key)
|
|
@@ -18,6 +18,7 @@ class TestRest(TestCase):
|
|
|
18
18
|
def setUp(self):
|
|
19
19
|
self.customer_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"
|
|
20
20
|
self.api_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="
|
|
21
|
+
self.rest_endpoint = "https://rest-api.telesign.com"
|
|
21
22
|
|
|
22
23
|
def test_rest_client_constructor_basic(self):
|
|
23
24
|
|
|
@@ -43,6 +44,19 @@ class TestRest(TestCase):
|
|
|
43
44
|
self.assertEqual(response.ok, requests_response.ok)
|
|
44
45
|
self.assertEqual(response.json, requests_response.json())
|
|
45
46
|
|
|
47
|
+
def test_rest_client_response_constructor_from_full_service(self):
|
|
48
|
+
|
|
49
|
+
client = RestClient(self.customer_id,
|
|
50
|
+
self.api_key,
|
|
51
|
+
self.rest_endpoint,
|
|
52
|
+
"python_telesign_enterprise",
|
|
53
|
+
"1.0.0",
|
|
54
|
+
"2.0.0")
|
|
55
|
+
|
|
56
|
+
self.assertIn("OriginatingSDK/python_telesign_enterprise", client.user_agent)
|
|
57
|
+
self.assertIn("SDKVersion/1.0.0", client.user_agent)
|
|
58
|
+
self.assertIn("DependencySDKVersion/2.0.0", client.user_agent)
|
|
59
|
+
|
|
46
60
|
def test_generate_telesign_headers_with_post(self):
|
|
47
61
|
method_name = 'POST'
|
|
48
62
|
date_rfc2616 = 'Wed, 14 Dec 2016 18:20:12 GMT'
|
|
@@ -276,4 +290,23 @@ class TestRest(TestCase):
|
|
|
276
290
|
self.assertEqual(post_args, expected_post_args,
|
|
277
291
|
"client.session.post.call_args args do not match expected")
|
|
278
292
|
self.assertEqual(post_kwargs, expected_post_kwargs,
|
|
279
|
-
"client.session.post.call_args kwargs do not match expected")
|
|
293
|
+
"client.session.post.call_args kwargs do not match expected")
|
|
294
|
+
|
|
295
|
+
def test_session_adapter_is_httpadapter(self):
|
|
296
|
+
client = RestClient(self.customer_id, self.api_key)
|
|
297
|
+
https_adapter = client.session.adapters["https://"]
|
|
298
|
+
import requests
|
|
299
|
+
self.assertIsInstance(https_adapter, requests.adapters.HTTPAdapter)
|
|
300
|
+
|
|
301
|
+
@patch("time.time")
|
|
302
|
+
def test_session_refresh_on_pool_recycle(self, mock_time):
|
|
303
|
+
# Simulate time to force session recycling
|
|
304
|
+
mock_time.return_value = 1000
|
|
305
|
+
client = RestClient(self.customer_id, self.api_key, pool_recycle=10)
|
|
306
|
+
created_at_first = client._session_created_at
|
|
307
|
+
# Advance time beyond the threshold
|
|
308
|
+
mock_time.return_value = 1012
|
|
309
|
+
# Force a request (any method calls _ensure_session)
|
|
310
|
+
client._ensure_session()
|
|
311
|
+
created_at_second = client._session_created_at
|
|
312
|
+
self.assertNotEqual(created_at_first, created_at_second)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from __future__ import print_function
|
|
2
|
-
from telesign.appverify import AppVerifyClient
|
|
3
|
-
|
|
4
|
-
customer_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"
|
|
5
|
-
api_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="
|
|
6
|
-
|
|
7
|
-
external_id = "external_id"
|
|
8
|
-
|
|
9
|
-
appverify = AppVerifyClient(customer_id, api_key)
|
|
10
|
-
response = appverify.status(external_id)
|
|
11
|
-
|
|
12
|
-
if response.ok:
|
|
13
|
-
print("App Verify transaction with external_id {} has status code {} and status description {}.".format(
|
|
14
|
-
external_id,
|
|
15
|
-
response.json['status']['code'],
|
|
16
|
-
response.json['status']['description']))
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"""Example code that makes requests to intelligence API."""
|
|
2
|
-
from __future__ import print_function
|
|
3
|
-
from telesign.intelligence import IntelligenceClient
|
|
4
|
-
|
|
5
|
-
customer_1 = "your_customer_id-44ZA-47B5-95B9-ACXM9B1E5CAA"
|
|
6
|
-
api_key_1 = "your_api_key_or_password"
|
|
7
|
-
|
|
8
|
-
phone_number = "15555551212"
|
|
9
|
-
account_lifecycle_event = "create"
|
|
10
|
-
|
|
11
|
-
body = {
|
|
12
|
-
"contact_details": {"email": "ghopper@gmail.com", "phone_number": "15555551212"},
|
|
13
|
-
"external_id": "REG432538",
|
|
14
|
-
"account_lifecycle_event": "create",
|
|
15
|
-
"ip": "1.1.1.1",
|
|
16
|
-
"device_id": "2e4fa042234d",
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
client = IntelligenceClient(customer_1, api_key_1)
|
|
20
|
-
response = client.intelligence(body)
|
|
21
|
-
|
|
22
|
-
if response.ok:
|
|
23
|
-
print(
|
|
24
|
-
"Phone number {} has a '{}' risk level and the score is '{}'.".format(
|
|
25
|
-
response.json["phone_details"]["numbering"]["original"]["phone_number"],
|
|
26
|
-
response.json["risk"]["level"],
|
|
27
|
-
response.json["risk"]["score"],
|
|
28
|
-
)
|
|
29
|
-
)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from __future__ import unicode_literals
|
|
2
|
-
|
|
3
|
-
from telesign.rest import RestClient
|
|
4
|
-
|
|
5
|
-
APPVERIFY_STATUS_RESOURCE = "/v1/mobile/verification/status/{external_id}"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AppVerifyClient(RestClient):
|
|
9
|
-
"""
|
|
10
|
-
App Verify is a secure, lightweight SDK that integrates a frictionless user verification process into existing
|
|
11
|
-
native mobile applications.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
def __init__(self, customer_id, api_key, **kwargs):
|
|
15
|
-
super(AppVerifyClient, self).__init__(customer_id, api_key, **kwargs)
|
|
16
|
-
|
|
17
|
-
def status(self, external_id, **params):
|
|
18
|
-
"""
|
|
19
|
-
Retrieves the verification result for an App Verify transaction by external_id. To ensure a secure verification
|
|
20
|
-
flow you must check the status using TeleSign's servers on your backend. Do not rely on the SDK alone to
|
|
21
|
-
indicate a successful verification.
|
|
22
|
-
|
|
23
|
-
See https://developer.telesign.com/docs/app-verify-android-sdk-self#section-get-status-service or
|
|
24
|
-
https://developer.telesign.com/docs/app-verify-ios-sdk-self#section-get-status-service for detailed
|
|
25
|
-
API documentation.
|
|
26
|
-
"""
|
|
27
|
-
return self.get(APPVERIFY_STATUS_RESOURCE.format(external_id=external_id),
|
|
28
|
-
**params)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"""Client to make requests to intelligence API."""
|
|
2
|
-
from __future__ import unicode_literals
|
|
3
|
-
|
|
4
|
-
from telesign.rest import RestClient
|
|
5
|
-
from telesign.util import AuthMethod
|
|
6
|
-
|
|
7
|
-
INTELLIGENCE_BASE_URL = "https://detect.telesign.com"
|
|
8
|
-
INTELLIGENCE_ENDPOINT_PATH = "/intelligence"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class IntelligenceClient(RestClient):
|
|
12
|
-
"""
|
|
13
|
-
It is critical today to evaluate fraud risk throughout the entire customer journey.
|
|
14
|
-
|
|
15
|
-
Telesign Intelligence makes it easy to understand the risk and the reason behind it with tailored scoring models
|
|
16
|
-
and comprehensive reason codes.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def __init__(self, customer_id, api_key, **kwargs):
|
|
20
|
-
super(IntelligenceClient, self).__init__(
|
|
21
|
-
customer_id=customer_id,
|
|
22
|
-
api_key=api_key,
|
|
23
|
-
rest_endpoint=INTELLIGENCE_BASE_URL,
|
|
24
|
-
auth_method=AuthMethod.BASIC.value,
|
|
25
|
-
**kwargs
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
def intelligence(self, params):
|
|
29
|
-
"""
|
|
30
|
-
Telesign Intelligence is like a credit check for digital profiles.
|
|
31
|
-
|
|
32
|
-
You submit a phone number, IP, and email to the service, the individual
|
|
33
|
-
identifiers are each evaluated, and then a score is returned telling you how risky
|
|
34
|
-
that user is. You decide whether to proceed based on the score.
|
|
35
|
-
|
|
36
|
-
See https://developer.telesign.com/enterprise/docs/intelligence-overview
|
|
37
|
-
for detailed API documentation.
|
|
38
|
-
"""
|
|
39
|
-
return self.post(INTELLIGENCE_ENDPOINT_PATH, body=params, query_params=None)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telesign-2.2.4 → telesign-3.0.0}/examples/messaging/2_send_message_with_verification_code.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telesign-2.2.4 → telesign-3.0.0}/examples/voice/2_send_voice_call_with_verification_code.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|