python-terminusgps 24.2.0__py3-none-any.whl → 24.4.0__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 python-terminusgps might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 24.2.0
3
+ Version: 24.4.0
4
4
  Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
5
5
  Project-URL: Documentation, https://app.terminusgps.com/docs/apps/python-terminusgps/index.html
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -7,15 +7,16 @@ terminusgps/authorizenet/utils.py,sha256=5aczO2EcMX2bi-kRg8_fnzLzE7qMA9K1qBxAo2A
7
7
  terminusgps/authorizenet/profiles/__init__.py,sha256=QKjMKcXpCSCEhv6LBCz0yGP8t0VxAyKyYRS4_HLYnxQ,114
8
8
  terminusgps/authorizenet/profiles/addresses.py,sha256=7yrOrb9kIsiiazgWbeH8v_YUBiWG3Y61g46R3S5DD-k,6592
9
9
  terminusgps/authorizenet/profiles/base.py,sha256=TOUHr22QRQBLErdysOkfcpJBusTjrUTqOmWEyNvMacA,2240
10
- terminusgps/authorizenet/profiles/customers.py,sha256=xe7LNsqSB_oRCY-teojDTt0O6a5yVf0dyuu86ftc4hA,8377
10
+ terminusgps/authorizenet/profiles/customers.py,sha256=kxYj9naCsHhFkHdWl8dLk0ketORMxMMhO2XzVOyGd4g,8363
11
11
  terminusgps/authorizenet/profiles/payments.py,sha256=O_oZGUwO8XTApzr0itu-1XQYnWFR4gDpNCusWNzBh7A,11152
12
12
  terminusgps/authorizenet/subscriptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- terminusgps/authorizenet/subscriptions/subscriptions.py,sha256=JQHo2FxQyRPJp1jlbD2mIt9RKEJZbADZcfozNTKWbz0,1514
13
+ terminusgps/authorizenet/subscriptions/subscriptions.py,sha256=yg0rZw0Zzm3v7daLPR0PsdfCWBU6RyoE_gNPDBMkCjM,1621
14
14
  terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
16
16
  terminusgps/aws/ses.py,sha256=sDca2GjMaZvUt3kUPtGCpcqHiOkij9lMV1ogZofgYUU,2372
17
17
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
18
- terminusgps/twilio/caller.py,sha256=nHCIwUulo-C_v2orsp6OY0nuJA6YetSkxpMTwrRQ-uA,1831
18
+ terminusgps/twilio/caller.py,sha256=12r2GR_3un4uJvJWegTmvkb4ValDhnUPJVI-KaE1dGM,2175
19
+ terminusgps/twilio/logger.py,sha256=qlbOUvqBt7dNUOQGgn_N8_nwiqo0ewbqP9VN4N7dCrM,968
19
20
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
21
  terminusgps/wialon/constants.py,sha256=n1ux68oWYWnzeZdN811Iw_Lk78KBM0YMJMoonn67uZY,1723
21
22
  terminusgps/wialon/flags.py,sha256=_NIL3mrEGhvI5YISVjimjYtUatdgOqhZPJX368MtKSU,13959
@@ -30,7 +31,7 @@ terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFne
30
31
  terminusgps/wialon/items/unit.py,sha256=K0kmzFEInR3dAQVtMUA6M7KNy7HlD5IKl7f7YElr2sQ,9116
31
32
  terminusgps/wialon/items/unit_group.py,sha256=Stp-WfCGbOqcnxV6FU1AKtV7KIxIwCHa0NwhNJfgRoM,5032
32
33
  terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
33
- python_terminusgps-24.2.0.dist-info/METADATA,sha256=bbVaXq63-hNzcN6anqXZROwwpiLiQCVGaysMjctFxRY,946
34
- python_terminusgps-24.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- python_terminusgps-24.2.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
36
- python_terminusgps-24.2.0.dist-info/RECORD,,
34
+ python_terminusgps-24.4.0.dist-info/METADATA,sha256=6t37XrDAaX_Vh8qQlVCQYAkGqOz8LNvy9FDJrrJK1Lk,946
35
+ python_terminusgps-24.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ python_terminusgps-24.4.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
37
+ python_terminusgps-24.4.0.dist-info/RECORD,,
@@ -58,7 +58,7 @@ class CustomerProfile(AuthorizenetProfileBase):
58
58
  """A list of the customer's payment profiles, if any."""
59
59
  try:
60
60
  response = self._authorizenet_get_customer_profile(issuer_info=False)
61
- return response.get("paymentProfiles") if response else None
61
+ return response.paymentProfiles if response else None
62
62
  except ControllerExecutionError:
63
63
  return
64
64
 
@@ -67,7 +67,7 @@ class CustomerProfile(AuthorizenetProfileBase):
67
67
  """A list of the customer's address profiles, if any."""
68
68
  try:
69
69
  response = self._authorizenet_get_customer_profile(issuer_info=False)
70
- return response.get("shipToList") if response else None
70
+ return response.shipToList if response else None
71
71
  except ControllerExecutionError:
72
72
  return
73
73
 
@@ -36,4 +36,6 @@ class Subscription(ControllerExecutionMixin):
36
36
  )
37
37
  controller = apicontrollers.ARBCreateSubscriptionController(request)
38
38
  response = self.execute_controller(controller)
39
+ if response is None:
40
+ raise ValueError("Failed to retrieve Authorizenet API response.")
39
41
  return int(response.subscriptionId)
@@ -1,18 +1,23 @@
1
+ import asyncio
2
+ import logging
1
3
  from typing import Any
2
4
 
3
- import asyncio
4
5
  import twilio.rest
5
-
6
6
  from django.conf import settings
7
7
  from twilio.http.async_http_client import AsyncTwilioHttpClient
8
8
 
9
+ from terminusgps.twilio.logger import TwilioLogger
10
+
9
11
 
10
12
  class TwilioCaller:
11
- def __init__(self) -> None:
13
+ def __init__(self, log_level: int = logging.CRITICAL) -> None:
12
14
  self.client_sid = settings.TWILIO_SID
13
15
  self.client_token = settings.TWILIO_TOKEN
14
16
  self.from_number = settings.TWILIO_FROM_NUMBER
15
17
  self.messaging_sid = settings.TWILIO_MESSAGING_SID
18
+ self.logger = TwilioLogger(
19
+ logging.getLogger(self.__class__.__name__), level=log_level
20
+ ).get_logger()
16
21
 
17
22
  def __enter__(self) -> "TwilioCaller":
18
23
  self.client = twilio.rest.Client(
@@ -26,6 +31,9 @@ class TwilioCaller:
26
31
  async def create_notification(
27
32
  self, to_number: str, message: str, method: str = "sms"
28
33
  ) -> asyncio.Task[Any]:
34
+ self.logger.debug(
35
+ f"Creating '{method}' notification targeting '{to_number}'..."
36
+ )
29
37
  match method:
30
38
  case "sms":
31
39
  task = asyncio.create_task(
@@ -0,0 +1,29 @@
1
+ import logging
2
+
3
+
4
+ class TwilioLogger:
5
+ def __init__(
6
+ self,
7
+ logger: logging.Logger,
8
+ level: int = logging.DEBUG,
9
+ format: str = "%(name)s - %(levelname)s - %(asctime)s - %(message)s",
10
+ use_stream_handler: bool = True,
11
+ use_file_handler: bool = False,
12
+ filename: str = "twilio_debug.log",
13
+ ) -> None:
14
+ self.logger = logger
15
+ self.logger.setLevel(level)
16
+ formatter = logging.Formatter(format)
17
+
18
+ if use_stream_handler and not self.logger.handlers:
19
+ stream_handler = logging.StreamHandler()
20
+ stream_handler.setFormatter(formatter)
21
+ self.logger.addHandler(stream_handler)
22
+
23
+ if use_file_handler and not self.logger.handlers:
24
+ file_handler = logging.FileHandler(filename)
25
+ file_handler.setFormatter(formatter)
26
+ self.logger.addHandler(file_handler)
27
+
28
+ def get_logger(self) -> logging.Logger:
29
+ return self.logger