telesign 2.2.6__py2.py3-none-any.whl → 2.3.0__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/rest.py +38 -16
- {telesign-2.2.6.dist-info → telesign-2.3.0.dist-info}/METADATA +1 -1
- {telesign-2.2.6.dist-info → telesign-2.3.0.dist-info}/RECORD +6 -6
- {telesign-2.2.6.dist-info → telesign-2.3.0.dist-info}/LICENSE.txt +0 -0
- {telesign-2.2.6.dist-info → telesign-2.3.0.dist-info}/WHEEL +0 -0
- {telesign-2.2.6.dist-info → telesign-2.3.0.dist-info}/top_level.txt +0 -0
telesign/rest.py
CHANGED
|
@@ -16,18 +16,14 @@ from telesign.util import AuthMethod
|
|
|
16
16
|
|
|
17
17
|
class RestClient(requests.models.RequestEncodingMixin):
|
|
18
18
|
"""
|
|
19
|
-
The
|
|
20
|
-
|
|
19
|
+
The Telesign RestClient is a generic HTTP REST client that can be extended to make requests against any of
|
|
20
|
+
Telesign's REST API endpoints.
|
|
21
21
|
|
|
22
22
|
RequestEncodingMixin offers the function _encode_params for url encoding the body for use in string_to_sign outside
|
|
23
23
|
of a regular HTTP request.
|
|
24
24
|
|
|
25
25
|
See https://developer.telesign.com for detailed API documentation.
|
|
26
26
|
"""
|
|
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
27
|
|
|
32
28
|
class Response(object):
|
|
33
29
|
"""
|
|
@@ -51,11 +47,14 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
51
47
|
customer_id,
|
|
52
48
|
api_key,
|
|
53
49
|
rest_endpoint='https://rest-api.telesign.com',
|
|
50
|
+
source="python_telesign",
|
|
51
|
+
sdk_version_origin=None,
|
|
52
|
+
sdk_version_dependency=None,
|
|
54
53
|
proxies=None,
|
|
55
54
|
timeout=10,
|
|
56
55
|
auth_method=None):
|
|
57
56
|
"""
|
|
58
|
-
|
|
57
|
+
Telesign RestClient useful for making generic RESTful requests against our API.
|
|
59
58
|
|
|
60
59
|
:param customer_id: Your customer_id string associated with your account.
|
|
61
60
|
:param api_key: Your api_key string associated with your account.
|
|
@@ -77,6 +76,17 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
77
76
|
|
|
78
77
|
self.auth_method = auth_method
|
|
79
78
|
|
|
79
|
+
current_version_sdk = telesign.__version__ if source == "python_telesign" else sdk_version_origin
|
|
80
|
+
|
|
81
|
+
self.user_agent = "TeleSignSDK/python Python/{python_version} Requests/{requests_version} OriginatingSDK/{source} SDKVersion/{sdk_version}".format(
|
|
82
|
+
python_version=python_version(),
|
|
83
|
+
requests_version=requests.__version__,
|
|
84
|
+
source=source,
|
|
85
|
+
sdk_version=current_version_sdk)
|
|
86
|
+
|
|
87
|
+
if source != "python_telesign":
|
|
88
|
+
self.user_agent = self.user_agent + " DependencySDKVersion/{sdk_version_dependency}".format(sdk_version_dependency=sdk_version_dependency)
|
|
89
|
+
|
|
80
90
|
@staticmethod
|
|
81
91
|
def generate_telesign_headers(customer_id,
|
|
82
92
|
api_key,
|
|
@@ -89,17 +99,17 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
89
99
|
content_type=None,
|
|
90
100
|
auth_method=None):
|
|
91
101
|
"""
|
|
92
|
-
Generates the
|
|
102
|
+
Generates the Telesign REST API headers used to authenticate requests.
|
|
93
103
|
|
|
94
104
|
Creates the canonicalized string_to_sign and generates the HMAC signature. This is used to authenticate requests
|
|
95
|
-
against the
|
|
105
|
+
against the Telesign REST API.
|
|
96
106
|
|
|
97
107
|
See https://developer.telesign.com/docs/authentication for detailed API documentation.
|
|
98
108
|
|
|
99
109
|
:param customer_id: Your account customer_id.
|
|
100
110
|
:param api_key: Your account api_key.
|
|
101
111
|
: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'.
|
|
112
|
+
'PUT', 'PATCH' or 'DELETE'.
|
|
103
113
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
104
114
|
:param url_encoded_fields: HTTP body parameters to perform the HTTP request with, must be a urlencoded string.
|
|
105
115
|
:param date_rfc2616: The date and time of the request formatted in rfc 2616, as a string.
|
|
@@ -107,7 +117,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
107
117
|
:param user_agent: (optional) User Agent associated with the request, as a string.
|
|
108
118
|
:param content_type: (optional) ContentType of the request, as a string.
|
|
109
119
|
:param auth_method: (optional) Authentication type ex: Basic, HMAC etc
|
|
110
|
-
:return: The
|
|
120
|
+
:return: The Telesign authentication headers.
|
|
111
121
|
"""
|
|
112
122
|
if date_rfc2616 is None:
|
|
113
123
|
date_rfc2616 = formatdate(usegmt=True)
|
|
@@ -167,7 +177,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
167
177
|
|
|
168
178
|
def post(self, resource, body=None, json_fields=None, **query_params):
|
|
169
179
|
"""
|
|
170
|
-
Generic
|
|
180
|
+
Generic Telesign REST API POST handler.
|
|
171
181
|
|
|
172
182
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
173
183
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -178,7 +188,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
178
188
|
|
|
179
189
|
def get(self, resource, body=None, json_fields=None, **query_params):
|
|
180
190
|
"""
|
|
181
|
-
Generic
|
|
191
|
+
Generic Telesign REST API GET handler.
|
|
182
192
|
|
|
183
193
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
184
194
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -189,7 +199,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
189
199
|
|
|
190
200
|
def put(self, resource, body=None, json_fields=None, **query_params):
|
|
191
201
|
"""
|
|
192
|
-
Generic
|
|
202
|
+
Generic Telesign REST API PUT handler.
|
|
193
203
|
|
|
194
204
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
195
205
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -203,7 +213,7 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
203
213
|
|
|
204
214
|
def delete(self, resource, body=None, json_fields=None, **query_params):
|
|
205
215
|
"""
|
|
206
|
-
Generic
|
|
216
|
+
Generic Telesign REST API DELETE handler.
|
|
207
217
|
|
|
208
218
|
:param resource: The partial resource URI to perform the request against, as a string.
|
|
209
219
|
:param body: (optional) A dictionary sent as a part of request body.
|
|
@@ -211,10 +221,22 @@ class RestClient(requests.models.RequestEncodingMixin):
|
|
|
211
221
|
:return: The RestClient Response object.
|
|
212
222
|
"""
|
|
213
223
|
return self._execute(self.session.delete, 'DELETE', resource, body, json_fields, **query_params)
|
|
224
|
+
|
|
225
|
+
def patch(self, resource, body=None, json_fields=None, **query_params):
|
|
226
|
+
"""
|
|
227
|
+
Generic Telesign REST API PATCH handler.
|
|
228
|
+
|
|
229
|
+
:param resource: The partial resource URI to perform the request against, as a string.
|
|
230
|
+
:param body: (optional) A dictionary sent as a part of request body.
|
|
231
|
+
:param json_fields: (optional) A dictionary sent as a JSON body.
|
|
232
|
+
:param query_params: query_params to perform the PATCH request with, as a dictionary.
|
|
233
|
+
:return: The RestClient Response object.
|
|
234
|
+
"""
|
|
235
|
+
return self._execute(self.session.patch, 'PATCH', resource, body, json_fields, **query_params)
|
|
214
236
|
|
|
215
237
|
def _execute(self, method_function, method_name, resource, body=None, json_fields=None, **query_params):
|
|
216
238
|
"""
|
|
217
|
-
Generic
|
|
239
|
+
Generic Telesign REST API request handler.
|
|
218
240
|
|
|
219
241
|
:param method_function: The Requests HTTP request function to perform the request.
|
|
220
242
|
:param method_name: The HTTP method name, as an upper case string.
|
|
@@ -3,12 +3,12 @@ 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
5
|
telesign/phoneid.py,sha256=mk03NxL3wlaXpd8b-BB6q_SKfCxbtuTO19ayAHxmzz0,954
|
|
6
|
-
telesign/rest.py,sha256=
|
|
6
|
+
telesign/rest.py,sha256=26EESKSPzSPIAf3VpVmCEPE8HSpAZRfGw5koIHsJeh8,12653
|
|
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.
|
|
11
|
-
telesign-2.
|
|
12
|
-
telesign-2.
|
|
13
|
-
telesign-2.
|
|
14
|
-
telesign-2.
|
|
10
|
+
telesign-2.3.0.dist-info/LICENSE.txt,sha256=a--xZ4PCKUL5rpct8RrUC6ODU_8ZKIU51kJPfsA4HUs,1058
|
|
11
|
+
telesign-2.3.0.dist-info/METADATA,sha256=7pxOUYH6cvpiHfYp7v0GFYN9Wgz3ZWqahdN3qHfm__g,4532
|
|
12
|
+
telesign-2.3.0.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
13
|
+
telesign-2.3.0.dist-info/top_level.txt,sha256=6LG7Jcr1jnpVhOWaIShoTdwYJn0QCfPhfudyVJNz1qg,9
|
|
14
|
+
telesign-2.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|