python-terminusgps 43.2.0__tar.gz → 44.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.
Files changed (77) hide show
  1. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/PKG-INFO +1 -1
  2. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/authorizenet/api.rst +2 -2
  3. python_terminusgps-44.0.0/docs/source/authorizenet/auth.rst +22 -0
  4. python_terminusgps-44.0.0/docs/source/authorizenet/constants.rst +20 -0
  5. python_terminusgps-43.2.0/docs/source/authorizenet/controllers.rst → python_terminusgps-44.0.0/docs/source/authorizenet/exceptions.rst +2 -2
  6. python_terminusgps-44.0.0/docs/source/authorizenet/index.rst +33 -0
  7. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/conf.py +5 -3
  8. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/index.rst +4 -10
  9. python_terminusgps-44.0.0/docs/source/mixins.rst +5 -0
  10. python_terminusgps-44.0.0/docs/source/validators.rst +5 -0
  11. python_terminusgps-44.0.0/docs/source/wialon/exceptions.rst +5 -0
  12. python_terminusgps-44.0.0/docs/source/wialon/index.rst +14 -0
  13. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/wialon/items.rst +12 -7
  14. python_terminusgps-44.0.0/docs/source/wialon/session.rst +6 -0
  15. python_terminusgps-44.0.0/docs/source/wialon/usage.rst +70 -0
  16. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/pyproject.toml +1 -1
  17. python_terminusgps-44.0.0/terminusgps/authorizenet/auth.py +56 -0
  18. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/constants.py +21 -5
  19. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/controllers.py +2 -13
  20. python_terminusgps-43.2.0/terminusgps/django/settings.py → python_terminusgps-44.0.0/terminusgps/default_settings.py +5 -5
  21. python_terminusgps-44.0.0/terminusgps/validators.py +219 -0
  22. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/account.py +10 -10
  23. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/base.py +7 -7
  24. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/resource.py +3 -3
  25. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/retranslator.py +3 -21
  26. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/route.py +1 -1
  27. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/unit.py +5 -5
  28. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/unit_group.py +2 -2
  29. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/user.py +5 -5
  30. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/session.py +25 -22
  31. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/uv.lock +1 -1
  32. python_terminusgps-43.2.0/docs/source/authorizenet/auth.rst +0 -7
  33. python_terminusgps-43.2.0/docs/source/authorizenet/constants.rst +0 -9
  34. python_terminusgps-43.2.0/docs/source/authorizenet/index.rst +0 -15
  35. python_terminusgps-43.2.0/docs/source/django/forms.rst +0 -65
  36. python_terminusgps-43.2.0/docs/source/django/index.rst +0 -13
  37. python_terminusgps-43.2.0/docs/source/django/mixins.rst +0 -31
  38. python_terminusgps-43.2.0/docs/source/django/settings.rst +0 -61
  39. python_terminusgps-43.2.0/docs/source/django/validators.rst +0 -6
  40. python_terminusgps-43.2.0/docs/source/wialon/index.rst +0 -11
  41. python_terminusgps-43.2.0/docs/source/wialon/session.rst +0 -37
  42. python_terminusgps-43.2.0/terminusgps/authorizenet/auth.py +0 -43
  43. python_terminusgps-43.2.0/terminusgps/django/forms/__init__.py +0 -1
  44. python_terminusgps-43.2.0/terminusgps/django/forms/fields.py +0 -57
  45. python_terminusgps-43.2.0/terminusgps/django/forms/forms.py +0 -0
  46. python_terminusgps-43.2.0/terminusgps/django/forms/renderer.py +0 -10
  47. python_terminusgps-43.2.0/terminusgps/django/forms/widgets.py +0 -56
  48. python_terminusgps-43.2.0/terminusgps/django/utils.py +0 -7
  49. python_terminusgps-43.2.0/terminusgps/django/validators.py +0 -99
  50. python_terminusgps-43.2.0/terminusgps/wialon/__init__.py +0 -0
  51. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/.github/workflows/sphinx.yml +0 -0
  52. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/.gitignore +0 -0
  53. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/.python-version +0 -0
  54. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/COPYING +0 -0
  55. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/README.md +0 -0
  56. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/Makefile +0 -0
  57. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/make.bat +0 -0
  58. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/requirements.txt +0 -0
  59. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/authorizenet/usage.rst +0 -0
  60. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/docs/source/authorizenet/validators.rst +0 -0
  61. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/__init__.py +0 -0
  62. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/__init__.py +0 -0
  63. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/__init__.py +0 -0
  64. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/address_profiles.py +0 -0
  65. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/customer_profiles.py +0 -0
  66. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/payment_profiles.py +0 -0
  67. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/subscriptions.py +0 -0
  68. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/api/transactions.py +0 -0
  69. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/authorizenet/validators.py +0 -0
  70. {python_terminusgps-43.2.0/terminusgps/django → python_terminusgps-44.0.0/terminusgps}/mixins.py +0 -0
  71. {python_terminusgps-43.2.0/terminusgps/django → python_terminusgps-44.0.0/terminusgps/wialon}/__init__.py +0 -0
  72. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/constants.py +0 -0
  73. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/flags.py +0 -0
  74. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/__init__.py +0 -0
  75. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/items/factory.py +0 -0
  76. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/utils.py +0 -0
  77. {python_terminusgps-43.2.0 → python_terminusgps-44.0.0}/terminusgps/wialon/validators.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 43.2.0
3
+ Version: 44.0.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://terminusgps.github.io/python-terminusgps
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -1,5 +1,5 @@
1
- Authorizenet API Endpoints
2
- ==========================
1
+ Functions
2
+ =========
3
3
 
4
4
  ================
5
5
  Address Profiles
@@ -0,0 +1,22 @@
1
+ Authentication
2
+ ==============
3
+
4
+ Authentication for each Authorizenet API call is handled by values defined in a Django ``settings.py`` module.
5
+
6
+ Required settings:
7
+
8
+ +-----------------------------------+---------------+
9
+ | setting | type |
10
+ +===================================+===============+
11
+ | ``MERCHANT_AUTH_ENVIRONMENT`` | :py:obj:`str` |
12
+ +-----------------------------------+---------------+
13
+ | ``MERCHANT_AUTH_LOGIN_ID`` | :py:obj:`str` |
14
+ +-----------------------------------+---------------+
15
+ | ``MERCHANT_AUTH_TRANSACTION_KEY`` | :py:obj:`str` |
16
+ +-----------------------------------+---------------+
17
+ | ``MERCHANT_AUTH_VALIDATION_MODE`` | :py:obj:`str` |
18
+ +-----------------------------------+---------------+
19
+
20
+ .. automodule:: terminusgps.authorizenet.auth
21
+ :synopsis: Provides functions for authenticating Authorizenet API calls.
22
+ :members:
@@ -0,0 +1,20 @@
1
+ Constants
2
+ =========
3
+
4
+ These constants inherit from :py:obj:`~django.db.models.TextChoices`, not the built-in Python :py:obj:`~enum.StrEnum` type.
5
+
6
+ Django :py:obj:`~django.db.models.TextChoices` provides attributes such as :py:attr:`~django.db.models.TextChoices.choices`, :py:attr:`~django.db.models.TextChoices.values`, :py:attr:`~django.db.models.TextChoices.labels` and more.
7
+
8
+ .. py:currentmodule:: terminusgps.authorizenet.constants
9
+
10
+ .. autoclass:: Environment
11
+ :members:
12
+
13
+ .. autoclass:: SubscriptionStatus
14
+ :members:
15
+
16
+ .. autoclass:: SubscriptionIntervalUnit
17
+ :members:
18
+
19
+ .. autoclass:: ValidationMode
20
+ :members:
@@ -1,4 +1,4 @@
1
- API Controllers
2
- ===============
1
+ Exceptions
2
+ ==========
3
3
 
4
4
  .. autoexception:: terminusgps.authorizenet.controllers.AuthorizenetControllerExecutionError
@@ -0,0 +1,33 @@
1
+ Authorizenet
2
+ ============
3
+
4
+ The :py:mod:`terminusgps.authorizenet` package provides convenient functions for interacting with the Authorizenet API in a Pythonic interface.
5
+
6
+ Most `Authorizenet API endpoints <https://developer.authorize.net/api/reference/index.html>`_ are represented as plain Python functions.
7
+
8
+ .. attention:: These functions require the following settings to be present in your Django project's ``settings.py`` module.
9
+
10
+ Using this package without setting these settings will raise :py:exc:`~django.core.exceptions.ImproperlyConfigured`.
11
+
12
+ +-----------------------------------+---------------+
13
+ | setting | type |
14
+ +===================================+===============+
15
+ | ``MERCHANT_AUTH_ENVIRONMENT`` | :py:obj:`str` |
16
+ +-----------------------------------+---------------+
17
+ | ``MERCHANT_AUTH_LOGIN_ID`` | :py:obj:`str` |
18
+ +-----------------------------------+---------------+
19
+ | ``MERCHANT_AUTH_TRANSACTION_KEY`` | :py:obj:`str` |
20
+ +-----------------------------------+---------------+
21
+ | ``MERCHANT_AUTH_VALIDATION_MODE`` | :py:obj:`str` |
22
+ +-----------------------------------+---------------+
23
+
24
+ .. toctree::
25
+ :maxdepth: 2
26
+ :caption: Contents:
27
+
28
+ api.rst
29
+ auth.rst
30
+ constants.rst
31
+ exceptions.rst
32
+ usage.rst
33
+ validators.rst
@@ -12,7 +12,7 @@ sys.path.insert(0, os.path.abspath("../../"))
12
12
  project = "python-terminusgps"
13
13
  copyright = "2025, Terminus GPS, LLC"
14
14
  author = "Terminus GPS, LLC"
15
- release = "43.2.0"
15
+ release = "44.0.0"
16
16
 
17
17
  # -- General configuration ---------------------------------------------------
18
18
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -28,8 +28,8 @@ extensions = [
28
28
  intersphinx_mapping = {
29
29
  "python": ("https://docs.python.org/3/", None),
30
30
  "django": (
31
- "http://docs.djangoproject.com/en/stable/",
32
- "http://docs.djangoproject.com/en/stable/_objects/",
31
+ "https://docs.djangoproject.com/en/5.2/",
32
+ "https://docs.djangoproject.com/en/5.2/objects.inv",
33
33
  ),
34
34
  }
35
35
 
@@ -40,7 +40,9 @@ exclude_patterns = []
40
40
  # -- Options for HTML output -------------------------------------------------
41
41
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
42
42
 
43
+ autodoc_member_order = "groupwise"
43
44
  html_theme = "sphinxawesome_theme"
44
45
  pygments_style = "sas"
45
46
  pygments_style_dark = "lightbulb"
46
47
  html_static_path = ["_static"]
48
+ graphviz_dot = "/usr/bin/dot"
@@ -8,7 +8,7 @@ python-terminusgps documentation
8
8
 
9
9
  `python-terminusgps <https://pypi.org/project/python-terminusgps>`_ is a package [#f1]_ of subpackages that streamlines the use of web APIs for Terminus GPS developers.
10
10
 
11
- `Terminus GPS <https://terminusgps.com/>`_ is an IoT hardware/software GPS monitoring company.
11
+ `Terminus GPS <https://terminusgps.com/>`_ is an IoT software/hardware GPS monitoring company.
12
12
 
13
13
  .. [#f1] In other programming languages, the term "library" is used to describe what Python calls a "package". Put simply, a "package" is a Python "library".
14
14
 
@@ -16,23 +16,17 @@ python-terminusgps documentation
16
16
  Installation
17
17
  ============
18
18
 
19
-
20
19
  Use pip to install from `PyPI <https://pypi.org/project/python-terminusgps/>`_.
21
20
 
22
21
  .. code:: bash
23
22
 
24
- pip install python-terminusgps
25
-
26
- All subpackages are nested within :py:mod:`terminusgps`:
27
-
28
- .. code:: python
29
-
30
- from terminusgps.wialon.session import WialonSession # Creates Wialon API sessions
23
+ pip install python-terminusgps
31
24
 
32
25
  .. toctree::
33
26
  :maxdepth: 2
34
27
  :caption: Contents:
35
28
 
36
29
  authorizenet/index.rst
37
- django/index.rst
30
+ mixins.rst
31
+ validators.rst
38
32
  wialon/index.rst
@@ -0,0 +1,5 @@
1
+ Mixins
2
+ ======
3
+
4
+ .. autoclass:: terminusgps.mixins.HtmxTemplateResponseMixin
5
+ :members:
@@ -0,0 +1,5 @@
1
+ Validators
2
+ ==========
3
+
4
+ .. automodule:: terminusgps.validators
5
+ :members:
@@ -0,0 +1,5 @@
1
+ Exceptions
2
+ ==========
3
+
4
+ .. autoexception:: terminusgps.wialon.session.WialonAPIError
5
+ :members:
@@ -0,0 +1,14 @@
1
+ Wialon
2
+ ======
3
+ The :py:mod:`terminusgps.wialon` package provides a Pythonic interface for interacting with the Wialon API.
4
+
5
+ Most Wialon objects are modeled as plain Python objects which have attributes and methods that make `Wialon API calls <https://help.wialon.com/en/api/user-guide/api-reference>`_.
6
+
7
+ .. toctree::
8
+ :maxdepth: 2
9
+ :caption: Contents:
10
+
11
+ items.rst
12
+ exceptions.rst
13
+ session.rst
14
+ usage.rst
@@ -9,38 +9,43 @@ Base
9
9
  :autoclasstoc:
10
10
  :members:
11
11
 
12
- =======
13
- Factory
14
- =======
12
+ =========
13
+ Factories
14
+ =========
15
15
 
16
16
  .. autoclass:: terminusgps.wialon.items.factory.WialonObjectFactory
17
17
  :autoclasstoc:
18
- :members:
18
+
19
19
 
20
20
  ==============
21
21
  Wialon objects
22
22
  ==============
23
23
 
24
24
  .. autoclass:: terminusgps.wialon.items.account.WialonAccount
25
+ :autoclasstoc:
25
26
  :members:
26
27
 
27
28
  .. autoclass:: terminusgps.wialon.items.resource.WialonResource
29
+ :autoclasstoc:
28
30
  :members:
29
31
 
30
32
  .. autoclass:: terminusgps.wialon.items.retranslator.WialonRetranslator
31
- :members:
32
-
33
- .. autoclass:: terminusgps.wialon.items.retranslator.WialonRetranslatorConfiguration
33
+ :autoclasstoc:
34
34
  :members:
35
35
 
36
36
  .. autoclass:: terminusgps.wialon.items.route.WialonRoute
37
+ :autoclasstoc:
37
38
  :members:
38
39
 
39
40
  .. autoclass:: terminusgps.wialon.items.unit.WialonUnit
41
+ :autoclasstoc:
40
42
  :members:
41
43
 
42
44
  .. autoclass:: terminusgps.wialon.items.unit_group.WialonUnitGroup
45
+ :autoclasstoc:
43
46
  :members:
44
47
 
45
48
  .. autoclass:: terminusgps.wialon.items.user.WialonUser
49
+ :autoclasstoc:
46
50
  :members:
51
+
@@ -0,0 +1,6 @@
1
+ Sessions
2
+ ========
3
+
4
+ .. autoclass:: terminusgps.wialon.session.WialonSession
5
+ :members:
6
+ :class-doc-from: init
@@ -0,0 +1,70 @@
1
+ Usage
2
+ =====
3
+
4
+ To perform Wialon API operations, open a :py:obj:`~terminusgps.wialon.session.WialonSession` in a context manager, passing in your desired Wialon API token to use during the session's lifetime.
5
+
6
+ If :py:data:`token` isn't provided, the environment variable ``"WIALON_TOKEN"`` is passed instead.
7
+
8
+ .. code:: python
9
+
10
+ from terminusgps.wialon.session import WialonSession
11
+
12
+ # Context manager handles logging in and out of the Wialon API session
13
+ with WialonSession(token="my_wialon_api_token") as session:
14
+ # Perform Wialon API calls within this block
15
+ # Session is logged out when the interpreter exits this block
16
+ session.wialon_api.core_search_item(**{"id": 123, "flags": 0x1})
17
+
18
+ # Will raise WialonAPIError because the session is now invalid (logged out)
19
+ session.wialon_api.core_search_item(**{"id": 123, "flags": 0x1})
20
+
21
+ Instead of remembering every `Wialon API endpoint <https://help.wialon.com/en/api/user-guide/api-reference>`_, initialize a :py:obj:`~terminusgps.wialon.items.factory.WialonObjectFactory` in a :py:obj:`~terminusgps.wialon.session.WialonSession` to retrieve objects with convenient methods for calling the Wialon API:
22
+
23
+ .. code:: python
24
+
25
+ from terminusgps.wialon.items import WialonObjectFactory
26
+ from terminusgps.wialon.session import WialonSession
27
+
28
+ with WialonSession(token="my_wialon_api_token") as session:
29
+ # A valid Wialon API session is the only argument passed to the factory
30
+ factory = WialonObjectFactory(session)
31
+ # Call get() or create() on the factory to retrieve a WialonObject instance
32
+ # The 'items_type' argument mirrors Wialon's definition of Wialon objects, e.g. 'avl_unit' for WialonUnit, 'avl_resource' for WialonResource, etc.
33
+ unit = factory.get("avl_unit", 123)
34
+ # Refer to your IDE or this documentation for available attributes and methods of each Wialon object type.
35
+
36
+ ========
37
+ Examples
38
+ ========
39
+
40
+ Creating a new Wialon user
41
+ --------------------------
42
+
43
+ .. code:: python
44
+
45
+ from terminusgps.wialon.items import WialonObjectFactory
46
+ from terminusgps.wialon.session import WialonSession
47
+
48
+ with WialonSession() as session:
49
+ factory = WialonObjectFactory(session)
50
+ user = factory.create(
51
+ "user",
52
+ creator_id=12345678,
53
+ name="New User",
54
+ password="my_secure_password!1",
55
+ )
56
+
57
+ .. seealso:: :py:meth:`~terminusgps.wialon.items.user.WialonUser.create` for details on creating a Wialon user.
58
+
59
+ Update an existing Wialon user's name
60
+ -------------------------------------
61
+
62
+ .. code:: python
63
+
64
+ from terminusgps.wialon.items import WialonObjectFactory
65
+ from terminusgps.wialon.session import WialonSession
66
+
67
+ with WialonSession() as session:
68
+ factory = WialonObjectFactory(session)
69
+ user = factory.get("user", id=12345678)
70
+ user.set_name("New User")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "43.2.0"
3
+ version = "44.0.0"
4
4
  description = "Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more."
5
5
  readme = "README.md"
6
6
  authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
@@ -0,0 +1,56 @@
1
+ from authorizenet.apicontractsv1 import merchantAuthenticationType
2
+ from django.conf import settings
3
+ from django.core.exceptions import ImproperlyConfigured
4
+
5
+
6
+ def get_merchant_auth() -> merchantAuthenticationType:
7
+ """
8
+ Returns the merchant authentication information for Authorizenet API controller execution.
9
+
10
+ :raises ~django.core.exceptions.ImproperlyConfigured: If the :py:data:`MERCHANT_AUTH_LOGIN_ID` or the :py:data:`MERCHANT_AUTH_TRANSACTION_KEY` settings weren't set.
11
+ :returns: A merchant authentication object.
12
+ :rtype: ~authorizenet.apicontractsv1.merchantAuthenticationType
13
+
14
+ """
15
+ if not all(
16
+ [
17
+ hasattr(settings, "MERCHANT_AUTH_LOGIN_ID"),
18
+ hasattr(settings, "MERCHANT_AUTH_TRANSACTION_KEY"),
19
+ ]
20
+ ):
21
+ error_msg: str = "'MERCHANT_AUTH_LOGIN_ID' and 'MERCHANT_AUTH_TRANSACTION_KEY' settings are required."
22
+ raise ImproperlyConfigured(error_msg)
23
+ return merchantAuthenticationType(
24
+ name=str(settings.MERCHANT_AUTH_LOGIN_ID),
25
+ transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
26
+ )
27
+
28
+
29
+ def get_environment() -> str:
30
+ """
31
+ Returns the environment for Authorizenet API controller execution.
32
+
33
+ :raises ~django.core.exceptions.ImproperlyConfigured: If the :py:data:`MERCHANT_AUTH_ENVIRONMENT` setting wasn't set.
34
+ :returns: An Authorizenet API environment string.
35
+ :rtype: str
36
+
37
+ """
38
+ if not hasattr(settings, "MERCHANT_AUTH_ENVIRONMENT"):
39
+ error_msg: str = "'MERCHANT_AUTH_ENVIRONMENT' setting is required."
40
+ raise ImproperlyConfigured(error_msg)
41
+ return settings.MERCHANT_AUTH_ENVIRONMENT
42
+
43
+
44
+ def get_validation_mode() -> str:
45
+ """
46
+ Returns the validation mode for Authorizenet API controller execution.
47
+
48
+ :raises ~django.core.exceptions.ImproperlyConfigured: If the :py:data:`MERCHANT_AUTH_VALIDATION_MODE` setting wasn't set.
49
+ :returns: An Authorizenet API validation string.
50
+ :rtype: str
51
+
52
+ """
53
+ if not hasattr(settings, "MERCHANT_AUTH_VALIDATION_MODE"):
54
+ error_msg: str = "'MERCHANT_AUTH_VALIDATION_MODE' setting is required."
55
+ raise ImproperlyConfigured(error_msg)
56
+ return settings.MERCHANT_AUTH_VALIDATION_MODE
@@ -1,12 +1,10 @@
1
1
  from authorizenet import apicontractsv1
2
+ from authorizenet.constants import constants as anet_constants
2
3
  from django.db import models
3
4
  from django.utils.translation import gettext_lazy as _
4
5
 
5
- ANET_XMLNS = "{AnetApi/xml/v1/schema/AnetApiSchema.xsd}"
6
- """Authorizenet XML namespace."""
7
6
 
8
-
9
- class AuthorizenetSubscriptionStatus(models.TextChoices):
7
+ class SubscriptionStatus(models.TextChoices):
10
8
  """An Authorizenet subscription status."""
11
9
 
12
10
  ACTIVE = "active", _("Active")
@@ -21,10 +19,28 @@ class AuthorizenetSubscriptionStatus(models.TextChoices):
21
19
  """Terminated subscription."""
22
20
 
23
21
 
24
- class AuthorizenetSubscriptionIntervalUnit(models.TextChoices):
22
+ class SubscriptionIntervalUnit(models.TextChoices):
25
23
  """An Authorizenet subscription interval unit."""
26
24
 
27
25
  DAYS = apicontractsv1.ARBSubscriptionUnitEnum.days, _("Days")
28
26
  """Days interval unit."""
29
27
  MONTHS = apicontractsv1.ARBSubscriptionUnitEnum.months, _("Months")
30
28
  """Months interval unit."""
29
+
30
+
31
+ class Environment(models.TextChoices):
32
+ """An Authorizenet execution environment."""
33
+
34
+ SANDBOX = anet_constants.SANDBOX, _("Sandbox Environment")
35
+ """Sandbox environment."""
36
+ PRODUCTION = anet_constants.PRODUCTION, _("Production Environment")
37
+ """Production environment."""
38
+
39
+
40
+ class ValidationMode(models.TextChoices):
41
+ """An Authorizenet validation mode."""
42
+
43
+ TEST = "testMode", _("Test Mode")
44
+ """Test mode."""
45
+ LIVE = "liveMode", _("Live Mode")
46
+ """Live mode."""
@@ -11,10 +11,10 @@ def execute_controller(
11
11
  Executes an Authorizenet API controller and returns its response.
12
12
 
13
13
  :param controller: An Authorizenet API controller.
14
- :type controller: :py:obj:`~authorizenet.apicontrollersbase.APIOperationBase`
14
+ :type controller: ~authorizenet.apicontrollersbase.APIOperationBase
15
15
  :raises AuthorizenetControllerExecutionError: If the API call fails.
16
16
  :returns: An Authorizenet API response, if any.
17
- :rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
17
+ :rtype: ~lxml.objectify.ObjectifiedElement | None
18
18
 
19
19
  """
20
20
  controller.setenvironment(get_environment())
@@ -33,17 +33,6 @@ class AuthorizenetControllerExecutionError(Exception):
33
33
  """Raised when an Authorizenet API controller fails to execute."""
34
34
 
35
35
  def __init__(self, message: str, code: str, *args, **kwargs) -> None:
36
- """
37
- Sets :py:attr:`message` and :py:attr`code` for the exception.
38
-
39
- :param message: An Authorizenet API error message.
40
- :type message: :py:obj:`str`
41
- :param code: An Authorizenet API error code.
42
- :type code: :py:obj:`str`
43
- :returns: Nothing.
44
- :rtype: :py:obj:`None`
45
-
46
- """
47
36
  super().__init__(message, *args, **kwargs)
48
37
  self._message = message
49
38
  self._code = code
@@ -1,18 +1,18 @@
1
1
  import os
2
2
  import pathlib
3
3
 
4
- from authorizenet.constants import constants
4
+ from terminusgps.authorizenet.constants import Environment, ValidationMode
5
5
 
6
6
  BASE_DIR = pathlib.Path(__file__).resolve().parent
7
+
7
8
  DEBUG = True
8
9
  SECRET_KEY = "xem*6no%8d9%^qzt2f3x3ar-uq4_+7h9myc$t0!+4%bj5us6f)"
9
10
  USE_TZ = False
10
- DEFAULT_FIELD_CLASS = "p-2 w-full bg-white dark:bg-gray-700 dark:text-white rounded border dark:border-terminus-gray-300"
11
- DEFAULT_TAX_RATE = "0.0825"
11
+
12
+ MERCHANT_AUTH_ENVIRONMENT = Environment.SANDBOX
13
+ MERCHANT_AUTH_VALIDATION_MODE = ValidationMode.TEST
12
14
 
13
15
  # Secrets
14
16
  MERCHANT_AUTH_LOGIN_ID = os.getenv("MERCHANT_AUTH_LOGIN_ID")
15
17
  MERCHANT_AUTH_TRANSACTION_KEY = os.getenv("MERCHANT_AUTH_TRANSACTION_KEY")
16
- MERCHANT_AUTH_ENVIRONMENT = constants.SANDBOX
17
- MERCHANT_AUTH_VALIDATION_MODE = "testMode"
18
18
  WIALON_TOKEN = os.getenv("WIALON_TOKEN")