python-terminusgps 45.5.0__py3-none-any.whl → 45.6.1__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: 45.5.0
3
+ Version: 45.6.1
4
4
  Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
5
5
  Project-URL: Documentation, https://terminusgps.github.io/python-terminusgps
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -4,9 +4,9 @@ terminusgps/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
4
4
  terminusgps/validators.py,sha256=Mf0c7ku_wTQ7uv4hcLRyz0r2eRjvznIL77LLTE5uJ6E,9152
5
5
  terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  terminusgps/authorizenet/auth.py,sha256=T4lPm6eq2ZRoPffLg6GrLZn7wUZ-RTBNi0epyw6ph_w,1035
7
- terminusgps/authorizenet/constants.py,sha256=eukAZQVuv3XHL-Kd1gqxf8IYUqNC67ClTz4ZU7JPNYE,1459
8
- terminusgps/authorizenet/controllers.py,sha256=wuyKDLTpBmnfyPsHnN9uVnWlrMDUF059ctW-OiZQL-I,2055
9
- terminusgps/authorizenet/services.py,sha256=IGW1xuc7uZBAZ4KHJGEp7dFlMb-u7Q3SmSpNmAmrkTY,2344
7
+ terminusgps/authorizenet/constants.py,sha256=--3DNOw3_gjh2BIEqP3Jel5TvZsdoptYV17B4sg9bK0,2131
8
+ terminusgps/authorizenet/controllers.py,sha256=gmsvCVzGglmhIu3_TJpzOlel19cNuLiN7CCnaNM-Lm0,2072
9
+ terminusgps/authorizenet/services.py,sha256=oNnY9Sk4k7IbASnggavPUqlCj98OfBa-uuUE2xlKtXg,2496
10
10
  terminusgps/authorizenet/api/__init__.py,sha256=VXR4Yco1yz5R-R7vgaH2zTP9VFqzfvvGy_XJVjyb3i0,154
11
11
  terminusgps/authorizenet/api/address_profiles.py,sha256=VouUN6dIxlnuE3qEiacFqqDBi_VtwvSbsELqTqFZ0BE,4746
12
12
  terminusgps/authorizenet/api/customer_profiles.py,sha256=oya9KMRE10nKLjECTIdanfV_P8-gnNZLE0sYmRYVkgM,4505
@@ -29,7 +29,7 @@ terminusgps/wialon/items/route.py,sha256=9hmRBEFRJF3lKukv_y3blZxqxv75YgFCcRALrU6
29
29
  terminusgps/wialon/items/unit.py,sha256=B5iuGEghu89SL8KzYLUytYNRa8cogsVtf-bJ_RybPTA,5522
30
30
  terminusgps/wialon/items/unit_group.py,sha256=MIR0x5IlTjcnwx8Y9wXLNTql-wwVVj7NCe7dL2vOw4c,2131
31
31
  terminusgps/wialon/items/user.py,sha256=CRSICiJ-qzybEO_gXuKyzW5oa2RQeIp0SzX9ARcdME4,5151
32
- python_terminusgps-45.5.0.dist-info/METADATA,sha256=JlfYlqfaOdBlzkckUZ4ToaOlcyo9qxx82mmYLknbr9I,938
33
- python_terminusgps-45.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
- python_terminusgps-45.5.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
35
- python_terminusgps-45.5.0.dist-info/RECORD,,
32
+ python_terminusgps-45.6.1.dist-info/METADATA,sha256=BBwcaIviUs-BQVicJ4DQiWMo7OO32HOVdzUoim0ryhk,938
33
+ python_terminusgps-45.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
+ python_terminusgps-45.6.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
35
+ python_terminusgps-45.6.1.dist-info/RECORD,,
@@ -4,6 +4,29 @@ from django.db import models
4
4
  from django.utils.translation import gettext_lazy as _
5
5
 
6
6
 
7
+ class CurrencyCode(models.TextChoices):
8
+ USD = "USD", _("United States Dollar")
9
+ """US dollar."""
10
+ CAD = "CAD", _("Canadian Dollar")
11
+ """Canadian dollar."""
12
+ GBP = "GBP", _("Great British Pound")
13
+ """Great British pound."""
14
+ DKK = "DKK", _("Danish Krone")
15
+ """Danish krone."""
16
+ NOK = "NOK", _("Norwegian Krone")
17
+ """Norwegian krone."""
18
+ PLN = "PLN", _("Polish Złoty")
19
+ """Polish zloty."""
20
+ SEK = "SEK", _("Swedish Krona")
21
+ """Swedish krona."""
22
+ EUR = "EUR", _("Euro")
23
+ """Euro."""
24
+ AUD = "AUD", _("Australian Dollar")
25
+ """Australian dollar."""
26
+ NZD = "NZD", _("New Zealand Dollar")
27
+ """New Zealand dollar."""
28
+
29
+
7
30
  class SubscriptionStatus(models.TextChoices):
8
31
  """An Authorizenet subscription status."""
9
32
 
@@ -4,7 +4,7 @@ from lxml.objectify import ObjectifiedElement
4
4
 
5
5
  def execute_controller(
6
6
  controller: APIOperationBase, environment: str
7
- ) -> ObjectifiedElement | None:
7
+ ) -> ObjectifiedElement:
8
8
  """
9
9
  Executes an Authorizenet API controller and returns its response.
10
10
 
@@ -15,19 +15,19 @@ def execute_controller(
15
15
  :param merchant_auth: Authorizenet merchant authentication element.
16
16
  :type merchant_auth: ~authorizenet.apicontractsv1.merchantAuthenticationType
17
17
  :raises AuthorizenetControllerExecutionError: If the API call fails.
18
- :returns: An Authorizenet API response, if any.
19
- :rtype: ~lxml.objectify.ObjectifiedElement | None
18
+ :returns: An Authorizenet API response.
19
+ :rtype: ~lxml.objectify.ObjectifiedElement
20
20
 
21
21
  """
22
22
  controller.setenvironment(environment)
23
23
  controller.execute()
24
- response = controller.getresponse()
24
+ response: ObjectifiedElement | None = controller.getresponse()
25
25
 
26
26
  if response is None:
27
27
  raise AuthorizenetControllerExecutionError(
28
28
  message="Authorizenet controller response didn't exist.", code="1"
29
29
  )
30
- if response is not None and response.messages.resultCode != "Ok":
30
+ elif response is not None and response.messages.resultCode != "Ok":
31
31
  raise AuthorizenetControllerExecutionError(
32
32
  message=response.messages.message[0]["text"].text,
33
33
  code=response.messages.message[0]["code"].text,
@@ -40,8 +40,8 @@ class AuthorizenetControllerExecutionError(Exception):
40
40
 
41
41
  def __init__(self, message: str, code: str, *args, **kwargs) -> None:
42
42
  super().__init__(message, *args, **kwargs)
43
- self._message = message
44
- self._code = code
43
+ self._message: str = message
44
+ self._code: str = code
45
45
 
46
46
  def __str__(self) -> str:
47
47
  return f"{self.code}: {self.message}"
@@ -1,4 +1,3 @@
1
- from abc import ABC
2
1
  from functools import cached_property
3
2
  from typing import Callable
4
3
 
@@ -8,11 +7,14 @@ from django.core.exceptions import ImproperlyConfigured
8
7
  from lxml.objectify import ObjectifiedElement
9
8
 
10
9
  from .auth import get_environment, get_merchant_auth, get_validation_mode
11
- from .controllers import execute_controller
10
+ from .controllers import (
11
+ AuthorizenetControllerExecutionError,
12
+ execute_controller,
13
+ )
12
14
 
13
15
 
14
- class AuthorizenetService(ABC):
15
- """Base class for services that interact with the Authorizenet API."""
16
+ class AuthorizenetService:
17
+ """A service for safely interacting with the Authorizenet API."""
16
18
 
17
19
  REQUIRED_SETTINGS = (
18
20
  "MERCHANT_AUTH_ENVIRONMENT",
@@ -27,7 +29,7 @@ class AuthorizenetService(ABC):
27
29
  if not hasattr(settings, setting):
28
30
  raise ImproperlyConfigured(f"'{setting}' setting is required.")
29
31
 
30
- def call_api(self, func: Callable, *args, **kwargs) -> ObjectifiedElement:
32
+ def request(self, func: Callable, *args, **kwargs) -> ObjectifiedElement:
31
33
  """
32
34
  Calls the Authorizenet API function with arguments and returns the result.
33
35
 
@@ -40,9 +42,13 @@ class AuthorizenetService(ABC):
40
42
  :rtype: ~lxml.objectify.ObjectifiedElement
41
43
 
42
44
  """
43
- request, controller_cls = func(*args, **kwargs)
44
- request.merchantAuthentication = self.merchantAuthentication
45
- return execute_controller(controller_cls(request), self.environment)
45
+ try:
46
+ request, controller_cls = func(*args, **kwargs)
47
+ request.merchantAuthentication = self.merchantAuthentication
48
+ controller = controller_cls(request)
49
+ return execute_controller(controller, self.environment)
50
+ except AuthorizenetControllerExecutionError:
51
+ raise
46
52
 
47
53
  @cached_property
48
54
  def merchantAuthentication(self) -> merchantAuthenticationType: