telnyx 2.1.2__py2.py3-none-any.whl → 2.1.3__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.

Potentially problematic release.


This version of telnyx might be problematic. Click here for more details.

telnyx/__init__.py CHANGED
@@ -24,7 +24,7 @@ public_key = os.environ.get("TELNYX_PUBLIC_KEY")
24
24
  log = None
25
25
 
26
26
 
27
- __version__ = "2.1.2"
27
+ __version__ = "2.1.3"
28
28
 
29
29
 
30
30
  # Sets some basic information about the running application that's sent along
telnyx/api_requestor.py CHANGED
@@ -276,19 +276,22 @@ class APIRequestor(object):
276
276
  return encoded_params
277
277
 
278
278
  def interpret_response(self, rbody, rcode, rheaders):
279
- try:
280
- if hasattr(rbody, "decode"):
281
- rbody = rbody.decode("utf-8")
282
- resp = TelnyxResponse(rbody, rcode, rheaders)
283
- except Exception:
284
- raise error.APIError(
285
- "Invalid response body from API: %s "
286
- "(HTTP response code was %d)" % (rbody, rcode),
287
- rbody,
288
- rcode,
289
- rheaders,
290
- )
291
- if not (200 <= rcode < 300):
292
- self.handle_error_response(rbody, rcode, resp.data, rheaders)
279
+ if rcode == 204:
280
+ resp = TelnyxResponse("", rcode, rheaders)
281
+ else:
282
+ try:
283
+ if hasattr(rbody, "decode"):
284
+ rbody = rbody.decode("utf-8")
285
+ resp = TelnyxResponse(rbody, rcode, rheaders)
286
+ except Exception:
287
+ raise error.APIError(
288
+ "Invalid response body from API: %s "
289
+ "(HTTP response code was %d)" % (rbody, rcode),
290
+ rbody,
291
+ rcode,
292
+ rheaders,
293
+ )
294
+ if not (200 <= rcode < 300):
295
+ self.handle_error_response(rbody, rcode, resp.data, rheaders)
293
296
 
294
297
  return resp
@@ -24,9 +24,17 @@ def nested_resource_class_methods(
24
24
  parts = []
25
25
  if not path.startswith("/"):
26
26
  parts.append(cls.class_url())
27
- if id is not None:
27
+ if id is not None and "phone_number" not in path:
28
28
  parts.append(quote_plus(id, safe=util.telnyx_valid_id_parts))
29
- parts.append(quote_plus(path, safe="/"))
29
+ if id is not None:
30
+ if "phone_number" in path:
31
+ parts.append(path.format(phone_number=quote_plus(id, safe=util.telnyx_valid_id_parts + '+')))
32
+ elif "verification_id" in path:
33
+ parts.append(path.format(verification_id=quote_plus(id, safe=util.telnyx_valid_id_parts)))
34
+ else:
35
+ parts.append(path)
36
+ else:
37
+ parts.append(path)
30
38
  if nested_id is not None:
31
39
  parts.append(quote_plus(nested_id, safe=util.telnyx_valid_id_parts))
32
40
  return "/".join(parts)
@@ -55,8 +63,8 @@ def nested_resource_class_methods(
55
63
 
56
64
  elif operation == "retrieve":
57
65
 
58
- def retrieve_nested_resource(cls, id, nested_id, **params):
59
- url = getattr(cls, resource_url_method)(id, nested_id)
66
+ def retrieve_nested_resource(cls, id, nested_id=None, **params):
67
+ url = getattr(cls, resource_url_method)(id, nested_id=nested_id)
60
68
  return getattr(cls, resource_request_method)("get", url, **params)
61
69
 
62
70
  retrieve_method = "retrieve_%s" % resource
@@ -1,6 +1,7 @@
1
1
  from telnyx.api_resources.abstract import (
2
2
  CreateableAPIResource,
3
3
  ListableAPIResource,
4
+ UpdateableAPIResource,
4
5
  nested_resource_class_methods,
5
6
  )
6
7
 
@@ -20,18 +21,18 @@ from telnyx.api_resources.abstract import (
20
21
  @nested_resource_class_methods(
21
22
  "whatsapp", path="/v2/verifications/whatsapp", operations=["create"]
22
23
  )
23
- class Verification(CreateableAPIResource, ListableAPIResource):
24
+ @nested_resource_class_methods(
25
+ "verify_by_phone_number", path="by_phone_number/{phone_number}/actions/verify", operations=["create"]
26
+ )
27
+ @nested_resource_class_methods(
28
+ "verify_by_id", path="actions/verify", operations=["create"]
29
+ )
30
+ @nested_resource_class_methods(
31
+ "by_phone_number", path="by_phone_number/{phone_number}", operations=["retrieve"]
32
+ )
33
+ class Verification(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource):
24
34
  OBJECT_NAME = "verification"
25
35
 
26
- def verify_by_phone_number(self, code, phone_number, verify_profile_id):
27
- return self.request(
28
- method="post",
29
- url="/v2/verifications/by_phone_number/{}/actions/verify".format(
30
- phone_number
31
- ),
32
- params={"code": code, "verify_profile_id": verify_profile_id},
33
- )
34
-
35
36
  @classmethod
36
37
  def sms(cls, **params):
37
38
  return Verification.create_sms(None, **params)
@@ -51,3 +52,15 @@ class Verification(CreateableAPIResource, ListableAPIResource):
51
52
  @classmethod
52
53
  def whatsapp(cls, **params):
53
54
  return Verification.create_whatsapp(None, **params)
55
+
56
+ @classmethod
57
+ def verify_by_phone_number(cls, phone_number, **params):
58
+ return Verification.create_verify_by_phone_number(phone_number, **params)
59
+
60
+ @classmethod
61
+ def verify_by_id(cls, verification_id, **params):
62
+ return Verification.create_verify_by_id(verification_id, **params)
63
+
64
+ @classmethod
65
+ def by_phone_number(cls, phone_number):
66
+ return Verification.retrieve_by_phone_number(phone_number)
@@ -9,7 +9,10 @@ from telnyx.api_resources.abstract import (
9
9
  )
10
10
 
11
11
 
12
- @nested_resource_class_methods("verify", path="actions/verify", operations=["create"])
12
+ @nested_resource_class_methods("sms", path="verifications/sms", operations=["create"])
13
+ @nested_resource_class_methods("call", path="verifications/call", operations=["create"])
14
+ @nested_resource_class_methods("flashcall", path="verifications/flashcall", operations=["create"])
15
+ @nested_resource_class_methods("verify", path="verifications/{verification_id}/actions/verify", operations=["create"])
13
16
  class Verify(
14
17
  CreateableAPIResource,
15
18
  DeletableAPIResource,
@@ -18,5 +21,11 @@ class Verify(
18
21
  ):
19
22
  OBJECT_NAME = "verify"
20
23
 
21
- def verify(self, **params):
22
- return self.create_verify(**params)
24
+ def create_verification_sms(self, **params):
25
+ return self.create_sms(**params)
26
+
27
+ def create_verification_call(self, **params):
28
+ return self.create_call(**params)
29
+
30
+ def verify_verification_code_by_id(self, verification_id, **params):
31
+ return self.create_verify(verification_id=verification_id, **params)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: telnyx
3
- Version: 2.1.2
3
+ Version: 2.1.3
4
4
  Summary: Python bindings for the Telnyx API
5
5
  Home-page: https://github.com/team-telnyx/telnyx-python
6
6
  Author: Telnyx
@@ -28,8 +28,9 @@ Requires-Python: >=3.8
28
28
  Description-Content-Type: text/markdown
29
29
  License-File: LICENSE
30
30
  Requires-Dist: requests >=2.20
31
- Requires-Dist: six
31
+ Requires-Dist: six >=1.16.0
32
32
  Requires-Dist: PyNaCl
33
+ Requires-Dist: black >=23.0
33
34
 
34
35
  # Telnyx Python Library
35
36
 
@@ -1,5 +1,5 @@
1
- telnyx/__init__.py,sha256=Nsz_JBCvHlHKhgzTagXMUnlU8WJV_TF5oi_7Hf4ncUA,1012
2
- telnyx/api_requestor.py,sha256=01zqlPu3Mx58baLLAsRvGihvv5F6h9efBxUtLsAPyLw,10412
1
+ telnyx/__init__.py,sha256=t4DyTAgIKC0NbWolw0L9GzUkSfDp4fp0o3uk7RgsYI4,1012
2
+ telnyx/api_requestor.py,sha256=hkQ00gVrV6XWoJAoNx_PqXobvJzwut2YTr9M1vfI3gk,10562
3
3
  telnyx/error.py,sha256=7kwUMS7b0ec64A-Ugcwbjs4D2Pl7stEb-JjCE9T6Pic,4366
4
4
  telnyx/http_client.py,sha256=P9htOl44DhSW_m5MkRYtz2U0uLxh7tyuaf1v-ja9MiY,20042
5
5
  telnyx/multipart_data_generator.py,sha256=A6rNpe1WJ859ncFSvAEGHUFuK_fHQiLKqYJAL2Cmc6k,2597
@@ -142,10 +142,10 @@ telnyx/api_resources/sub_number_order.py,sha256=hb0hAhEv0xry7TfjWvKyybMC-WN6xaVp
142
142
  telnyx/api_resources/telephony_credential.py,sha256=_khQ2bOLoEQZ_p6qYB6-bjPwLoinPMR9JWol0_G59uE,646
143
143
  telnyx/api_resources/texml_application.py,sha256=5gubR9gjvZmZW4lva-OU0igOh6r0fLikotuVaM4uqEU,389
144
144
  telnyx/api_resources/texml_rest_command.py,sha256=Xfv4cbfikC1kundFjmBRtS1qM0uFllVhPLkuITWxcgU,327
145
- telnyx/api_resources/verification.py,sha256=qZjJZcVe1aM8h6M7OdLPfcaZ3wulXhpYWb0Iy8PoKf4,1615
145
+ telnyx/api_resources/verification.py,sha256=PDfKIOAvpTPIwDZJXXFlUFhswgdc7Ej2wJqwlQulSzU,2120
146
146
  telnyx/api_resources/verified_calls_display_profile.py,sha256=hLFpgrMtSW_jlVleXax7VROWEkBPEjNTE0a5fgKfJyg,413
147
147
  telnyx/api_resources/verified_number.py,sha256=8EGgTcC9BjBUrzH65znL15xNx4cgu1_hhF93VcMzcAw,515
148
- telnyx/api_resources/verify.py,sha256=f4q5uOhpA8mdnkAMLxHf13Y5l2K66m7HilMKnp4sEUU,567
148
+ telnyx/api_resources/verify.py,sha256=zLtuZiaGtvW8cl7HNMzTGKrjImQx0-I580_DKfIAPvQ,1132
149
149
  telnyx/api_resources/verify_profile.py,sha256=UJUUp2SRmrDzCt2oKHT_t3ynJ2G87_byx-dFffKUMkQ,383
150
150
  telnyx/api_resources/virtual_cross_connect.py,sha256=Z9eDeR7HEdZkLSTfsoxfYE2lT5x4IYjA1WIPzy86hsg,613
151
151
  telnyx/api_resources/wdr_detail_report.py,sha256=2_oJmdidVtX4DmPJsn0ff_8G0Gc-PL0Zo63Bym2FPZk,212
@@ -158,11 +158,11 @@ telnyx/api_resources/abstract/api_resource.py,sha256=I7rUSntKGM6sF_9zt8z4r5gSH4z
158
158
  telnyx/api_resources/abstract/createable_api_resource.py,sha256=BSM5A7pWO1KtIhs9jdv2l44wE7RmV75hyFW6yB9k5Q8,549
159
159
  telnyx/api_resources/abstract/deletable_api_resource.py,sha256=dB3tDxsiTxY1I04ygZFvvDbOWql0-x3Q-PJv_jxIvmc,307
160
160
  telnyx/api_resources/abstract/listable_api_resource.py,sha256=shWcUha2LYM_WPedBXQ9bB_zlwZdLWAxccjVbklM2uU,907
161
- telnyx/api_resources/abstract/nested_resource_class_methods.py,sha256=dO18YZ4iuqmsvxibbXYfFb-D8Eg9XAKs8IQDGU--gCo,4314
161
+ telnyx/api_resources/abstract/nested_resource_class_methods.py,sha256=U0NV4cJRWHrrR1jFfHt0ALmrfIUomksAHfJl62prCZE,4768
162
162
  telnyx/api_resources/abstract/singleton_api_resource.py,sha256=2g-rKkk2dT8aNJDKEFiaLFRs8wKk31kBTJpku3kpdNE,874
163
163
  telnyx/api_resources/abstract/updateable_api_resource.py,sha256=2_WN99EUfBmnHunfjS3jlwY0EIoU8V7_j9OMRsiqedk,1673
164
- telnyx-2.1.2.dist-info/LICENSE,sha256=h4YEwOcV9A9iTg1cUsg0z7uU7gxj281PMpKWj-AdQWY,1141
165
- telnyx-2.1.2.dist-info/METADATA,sha256=RK_Hvm3OSnMkh_qhs6sMIHr2Fc_hMjWgV1Qx0kn8S3I,10658
166
- telnyx-2.1.2.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
167
- telnyx-2.1.2.dist-info/top_level.txt,sha256=e59ZDpP51N6b62sY7VrNLq8aR9Ly5-IHtl7zCkGA0Yw,7
168
- telnyx-2.1.2.dist-info/RECORD,,
164
+ telnyx-2.1.3.dist-info/LICENSE,sha256=h4YEwOcV9A9iTg1cUsg0z7uU7gxj281PMpKWj-AdQWY,1141
165
+ telnyx-2.1.3.dist-info/METADATA,sha256=-xpRNYWUw-fUgOq-MMwuXBPRGOB4GgeypnfFEUYpRLA,10695
166
+ telnyx-2.1.3.dist-info/WHEEL,sha256=M4n4zmFKzQZk4mLCcycNIzIXO7YPKE_b5Cw4PnhHEg8,109
167
+ telnyx-2.1.3.dist-info/top_level.txt,sha256=e59ZDpP51N6b62sY7VrNLq8aR9Ly5-IHtl7zCkGA0Yw,7
168
+ telnyx-2.1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any