telesign 3.0.0__tar.gz → 4.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-3.0.0/telesign.egg-info → telesign-4.0.0}/PKG-INFO +7 -1
- telesign-4.0.0/examples/score/1_check_phone_number_risk_level.py +25 -0
- telesign-4.0.0/setup.py +51 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/__init__.py +0 -2
- telesign-4.0.0/telesign/score.py +35 -0
- {telesign-3.0.0 → telesign-4.0.0/telesign.egg-info}/PKG-INFO +7 -1
- {telesign-3.0.0 → telesign-4.0.0}/telesign.egg-info/SOURCES.txt +1 -0
- telesign-4.0.0/tests/test_score.py +45 -0
- telesign-3.0.0/examples/score/1_check_phone_number_risk_level.py +0 -17
- telesign-3.0.0/setup.py +0 -47
- telesign-3.0.0/telesign/score.py +0 -25
- {telesign-3.0.0 → telesign-4.0.0}/LICENSE.txt +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/MANIFEST.in +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/README.rst +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/messaging/1_send_message.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/messaging/2_send_message_with_verification_code.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/phoneid/1_check_phone_type_to_block_voip.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/phoneid/2_cleansing.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/voice/1_send_voice_call.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/voice/2_send_voice_call_with_verification_code.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/examples/voice/3_send_voice_call_french.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/setup.cfg +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/messaging.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/phoneid.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/rest.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/util.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign/voice.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign.egg-info/dependency_links.txt +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign.egg-info/requires.txt +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/telesign.egg-info/top_level.txt +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/tests/__init__.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/tests/test_phoneid.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/tests/test_rest.py +0 -0
- {telesign-3.0.0 → telesign-4.0.0}/tests/test_util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: telesign
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: TeleSign SDK
|
|
5
5
|
Home-page: https://github.com/telesign/python_telesign
|
|
6
6
|
Author: TeleSign Corp.
|
|
@@ -112,3 +112,9 @@ Classifier: Programming Language :: Python :: 3.3
|
|
|
112
112
|
Classifier: Programming Language :: Python :: 3.4
|
|
113
113
|
Classifier: Programming Language :: Python :: 3.5
|
|
114
114
|
Classifier: Programming Language :: Python :: 3.6
|
|
115
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
116
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
117
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
118
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
119
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
120
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import print_function
|
|
2
|
+
from telesign.score import ScoreClient
|
|
3
|
+
|
|
4
|
+
customer_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"
|
|
5
|
+
api_key = "ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="
|
|
6
|
+
|
|
7
|
+
phone_number = "phone_number"
|
|
8
|
+
account_lifecycle_event = "create"
|
|
9
|
+
|
|
10
|
+
score_client = ScoreClient(customer_id, api_key)
|
|
11
|
+
response = score_client.score(phone_number, account_lifecycle_event)
|
|
12
|
+
|
|
13
|
+
if response.ok:
|
|
14
|
+
print(
|
|
15
|
+
"Phone number {} has a '{}' risk level and the recommendation is to '{}' the transaction.".format(
|
|
16
|
+
phone_number,
|
|
17
|
+
response.json['risk']['level'],
|
|
18
|
+
response.json['risk']['recommendation'])
|
|
19
|
+
)
|
|
20
|
+
else:
|
|
21
|
+
print(
|
|
22
|
+
"Request failed with status code: {}. Details: {}".format(
|
|
23
|
+
response.status_code,
|
|
24
|
+
response.json)
|
|
25
|
+
)
|
telesign-4.0.0/setup.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from codecs import open
|
|
3
|
+
from os import path
|
|
4
|
+
|
|
5
|
+
from setuptools import setup, find_packages
|
|
6
|
+
|
|
7
|
+
EXCLUDE_FROM_PACKAGES = ["tests"]
|
|
8
|
+
|
|
9
|
+
here = path.abspath(path.dirname(__file__))
|
|
10
|
+
|
|
11
|
+
version = "4.0.0"
|
|
12
|
+
|
|
13
|
+
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
|
14
|
+
long_description = f.read()
|
|
15
|
+
|
|
16
|
+
setup(
|
|
17
|
+
name="telesign",
|
|
18
|
+
version=version,
|
|
19
|
+
description="TeleSign SDK",
|
|
20
|
+
license="MIT",
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Development Status :: 5 - Production/Stable",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Natural Language :: English",
|
|
26
|
+
"Programming Language :: Python",
|
|
27
|
+
"Programming Language :: Python :: 2",
|
|
28
|
+
"Programming Language :: Python :: 2.6",
|
|
29
|
+
"Programming Language :: Python :: 2.7",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.3",
|
|
32
|
+
"Programming Language :: Python :: 3.4",
|
|
33
|
+
"Programming Language :: Python :: 3.5",
|
|
34
|
+
"Programming Language :: Python :: 3.6",
|
|
35
|
+
"Programming Language :: Python :: 3.7",
|
|
36
|
+
"Programming Language :: Python :: 3.8",
|
|
37
|
+
"Programming Language :: Python :: 3.9",
|
|
38
|
+
"Programming Language :: Python :: 3.10",
|
|
39
|
+
"Programming Language :: Python :: 3.11",
|
|
40
|
+
"Programming Language :: Python :: 3.12",
|
|
41
|
+
],
|
|
42
|
+
long_description=long_description,
|
|
43
|
+
keywords="telesign, sms, voice, mobile, authentication, identity, messaging",
|
|
44
|
+
author="TeleSign Corp.",
|
|
45
|
+
author_email="support@telesign.com",
|
|
46
|
+
url="https://github.com/telesign/python_telesign",
|
|
47
|
+
install_requires=["requests"],
|
|
48
|
+
test_suite="nose.collector",
|
|
49
|
+
tests_require=["nose", "pytz"],
|
|
50
|
+
packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
|
|
51
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from telesign.rest import RestClient
|
|
2
|
+
|
|
3
|
+
DETECT_HOST = "https://detect.telesign.com"
|
|
4
|
+
INTELLIGENCE_RESOURCE = "/intelligence/phone"
|
|
5
|
+
|
|
6
|
+
class ScoreClient(RestClient):
|
|
7
|
+
"""
|
|
8
|
+
ScoreClient for TeleSign Intelligence Cloud.
|
|
9
|
+
Supports POST /intelligence/phone endpoint(Cloud migration).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, customer_id, api_key, rest_endpoint=DETECT_HOST, **kwargs):
|
|
13
|
+
super(ScoreClient, self).__init__(customer_id, api_key, rest_endpoint, **kwargs)
|
|
14
|
+
|
|
15
|
+
def score(self, phone_number, account_lifecycle_event, **params):
|
|
16
|
+
"""
|
|
17
|
+
Obtain a risk recommendation for a phone number using Telesign Intelligence Cloud API.
|
|
18
|
+
Required parameters:
|
|
19
|
+
- phone_number
|
|
20
|
+
- account_lifecycle_event ("create", "sign-in", "transact", "update", "delete")
|
|
21
|
+
Optional parameters: account_id, device_id, email_address, external_id, originating_ip, etc.
|
|
22
|
+
"""
|
|
23
|
+
if not phone_number:
|
|
24
|
+
raise ValueError("phone_number cannot be null or empty")
|
|
25
|
+
|
|
26
|
+
if not account_lifecycle_event:
|
|
27
|
+
raise ValueError("account_lifecycle_event cannot be null or empty")
|
|
28
|
+
|
|
29
|
+
params["phone_number"] = phone_number
|
|
30
|
+
params["account_lifecycle_event"] = account_lifecycle_event
|
|
31
|
+
|
|
32
|
+
return self.post(
|
|
33
|
+
INTELLIGENCE_RESOURCE,
|
|
34
|
+
**params
|
|
35
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: telesign
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: TeleSign SDK
|
|
5
5
|
Home-page: https://github.com/telesign/python_telesign
|
|
6
6
|
Author: TeleSign Corp.
|
|
@@ -112,3 +112,9 @@ Classifier: Programming Language :: Python :: 3.3
|
|
|
112
112
|
Classifier: Programming Language :: Python :: 3.4
|
|
113
113
|
Classifier: Programming Language :: Python :: 3.5
|
|
114
114
|
Classifier: Programming Language :: Python :: 3.6
|
|
115
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
116
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
117
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
118
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
119
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
120
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from __future__ import unicode_literals
|
|
2
|
+
import os
|
|
3
|
+
from unittest import TestCase, mock
|
|
4
|
+
from telesign.score import ScoreClient
|
|
5
|
+
|
|
6
|
+
class TestScoreClient(TestCase):
|
|
7
|
+
def setUp(self):
|
|
8
|
+
self.customer_id = os.getenv('CUSTOMER_ID', 'FFFFFFFF-EEEE-DDDD-1234-AB1234567890')
|
|
9
|
+
self.api_key = os.getenv('API_KEY', 'ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==')
|
|
10
|
+
self.phone_number_test = os.getenv('PHONE_NUMBER', 'phone_number')
|
|
11
|
+
self.account_lifecycle_event = "create"
|
|
12
|
+
|
|
13
|
+
@mock.patch('telesign.rest.requests.Session.post')
|
|
14
|
+
def test_score_method(self, mock_post):
|
|
15
|
+
mock_response = mock.Mock()
|
|
16
|
+
mock_response.ok = True
|
|
17
|
+
mock_response.status_code = 200
|
|
18
|
+
mock_response.headers = {'Content-Type': 'application/json'}
|
|
19
|
+
mock_response.json.return_value = {
|
|
20
|
+
"risk": {
|
|
21
|
+
"level": "LOW",
|
|
22
|
+
"recommendation": "allow"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
mock_post.return_value = mock_response
|
|
26
|
+
|
|
27
|
+
client = ScoreClient(self.customer_id, self.api_key)
|
|
28
|
+
response = client.score(self.phone_number_test, self.account_lifecycle_event)
|
|
29
|
+
|
|
30
|
+
called_url = mock_post.call_args[0][0]
|
|
31
|
+
self.assertIn('/intelligence/phone', called_url)
|
|
32
|
+
|
|
33
|
+
called_kwargs = mock_post.call_args[1] if mock_post.call_args else {}
|
|
34
|
+
called_data = called_kwargs.get('data', '')
|
|
35
|
+
|
|
36
|
+
self.assertTrue(called_data, "POST data is empty, expected form parameters")
|
|
37
|
+
self.assertIn(f'phone_number={self.phone_number_test}', called_data)
|
|
38
|
+
self.assertIn(f'account_lifecycle_event={self.account_lifecycle_event}', called_data)
|
|
39
|
+
|
|
40
|
+
self.assertEqual(response.status_code, 200)
|
|
41
|
+
self.assertTrue(response.ok)
|
|
42
|
+
self.assertEqual(response.headers.get('Content-Type'), 'application/json')
|
|
43
|
+
self.assertIn('risk', response.json)
|
|
44
|
+
self.assertEqual(response.json['risk']['level'], 'LOW')
|
|
45
|
+
self.assertEqual(response.json['risk']['recommendation'], 'allow')
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from __future__ import print_function
|
|
2
|
-
from telesign.score import ScoreClient
|
|
3
|
-
|
|
4
|
-
customer_id = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"
|
|
5
|
-
api_key = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="
|
|
6
|
-
|
|
7
|
-
phone_number = "phone_number"
|
|
8
|
-
account_lifecycle_event = "create"
|
|
9
|
-
|
|
10
|
-
data = ScoreClient(customer_id, api_key)
|
|
11
|
-
response = data.score(phone_number, account_lifecycle_event)
|
|
12
|
-
|
|
13
|
-
if response.ok:
|
|
14
|
-
print("Phone number {} has a '{}' risk level and the recommendation is to '{}' the transaction.".format(
|
|
15
|
-
phone_number,
|
|
16
|
-
response.json['risk']['level'],
|
|
17
|
-
response.json['risk']['recommendation']))
|
telesign-3.0.0/setup.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from codecs import open
|
|
3
|
-
from os import path
|
|
4
|
-
|
|
5
|
-
from setuptools import setup, find_packages
|
|
6
|
-
|
|
7
|
-
EXCLUDE_FROM_PACKAGES = ['tests']
|
|
8
|
-
|
|
9
|
-
needs_mock = sys.version_info < (3, 3)
|
|
10
|
-
mock = ['mock'] if needs_mock else []
|
|
11
|
-
|
|
12
|
-
here = path.abspath(path.dirname(__file__))
|
|
13
|
-
|
|
14
|
-
version = "3.0.0"
|
|
15
|
-
|
|
16
|
-
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
|
17
|
-
long_description = f.read()
|
|
18
|
-
|
|
19
|
-
setup(name='telesign',
|
|
20
|
-
version=version,
|
|
21
|
-
description="TeleSign SDK",
|
|
22
|
-
license="MIT",
|
|
23
|
-
classifiers=[
|
|
24
|
-
"Development Status :: 5 - Production/Stable",
|
|
25
|
-
"Intended Audience :: Developers",
|
|
26
|
-
"License :: OSI Approved :: MIT License",
|
|
27
|
-
"Natural Language :: English",
|
|
28
|
-
"Programming Language :: Python",
|
|
29
|
-
"Programming Language :: Python :: 2",
|
|
30
|
-
"Programming Language :: Python :: 2.6",
|
|
31
|
-
"Programming Language :: Python :: 2.7",
|
|
32
|
-
"Programming Language :: Python :: 3",
|
|
33
|
-
"Programming Language :: Python :: 3.3",
|
|
34
|
-
"Programming Language :: Python :: 3.4",
|
|
35
|
-
"Programming Language :: Python :: 3.5",
|
|
36
|
-
"Programming Language :: Python :: 3.6",
|
|
37
|
-
],
|
|
38
|
-
long_description=long_description,
|
|
39
|
-
keywords='telesign, sms, voice, mobile, authentication, identity, messaging',
|
|
40
|
-
author='TeleSign Corp.',
|
|
41
|
-
author_email='support@telesign.com',
|
|
42
|
-
url="https://github.com/telesign/python_telesign",
|
|
43
|
-
install_requires=['requests'],
|
|
44
|
-
test_suite='nose.collector',
|
|
45
|
-
tests_require=['nose', 'pytz'] + mock,
|
|
46
|
-
packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
|
|
47
|
-
)
|
telesign-3.0.0/telesign/score.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from __future__ import unicode_literals
|
|
2
|
-
|
|
3
|
-
from telesign.rest import RestClient
|
|
4
|
-
|
|
5
|
-
SCORE_RESOURCE = "/v1/score/{phone_number}"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ScoreClient(RestClient):
|
|
9
|
-
"""
|
|
10
|
-
Score provides risk information about a specified phone number.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, customer_id, api_key, **kwargs):
|
|
14
|
-
super(ScoreClient, self).__init__(customer_id, api_key, **kwargs)
|
|
15
|
-
|
|
16
|
-
def score(self, phone_number, account_lifecycle_event, **params):
|
|
17
|
-
"""
|
|
18
|
-
Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
|
|
19
|
-
learning, and a global data consortium.
|
|
20
|
-
|
|
21
|
-
See https://developer.telesign.com/docs/score-api for detailed API documentation.
|
|
22
|
-
"""
|
|
23
|
-
return self.post(SCORE_RESOURCE.format(phone_number=phone_number),
|
|
24
|
-
account_lifecycle_event=account_lifecycle_event,
|
|
25
|
-
**params)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telesign-3.0.0 → telesign-4.0.0}/examples/messaging/2_send_message_with_verification_code.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telesign-3.0.0 → telesign-4.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
|
|
File without changes
|