python-terminusgps 43.2.0__py3-none-any.whl → 44.0.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.
- {python_terminusgps-43.2.0.dist-info → python_terminusgps-44.0.0.dist-info}/METADATA +1 -1
- python_terminusgps-44.0.0.dist-info/RECORD +35 -0
- terminusgps/authorizenet/auth.py +24 -11
- terminusgps/authorizenet/constants.py +21 -5
- terminusgps/authorizenet/controllers.py +2 -13
- terminusgps/{django/settings.py → default_settings.py} +5 -5
- terminusgps/validators.py +219 -0
- terminusgps/wialon/items/account.py +10 -10
- terminusgps/wialon/items/base.py +7 -7
- terminusgps/wialon/items/resource.py +3 -3
- terminusgps/wialon/items/retranslator.py +3 -21
- terminusgps/wialon/items/route.py +1 -1
- terminusgps/wialon/items/unit.py +5 -5
- terminusgps/wialon/items/unit_group.py +2 -2
- terminusgps/wialon/items/user.py +5 -5
- terminusgps/wialon/session.py +25 -22
- python_terminusgps-43.2.0.dist-info/RECORD +0 -42
- terminusgps/django/__init__.py +0 -0
- terminusgps/django/forms/__init__.py +0 -1
- terminusgps/django/forms/fields.py +0 -57
- terminusgps/django/forms/forms.py +0 -0
- terminusgps/django/forms/renderer.py +0 -10
- terminusgps/django/forms/widgets.py +0 -56
- terminusgps/django/utils.py +0 -7
- terminusgps/django/validators.py +0 -99
- {python_terminusgps-43.2.0.dist-info → python_terminusgps-44.0.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-43.2.0.dist-info → python_terminusgps-44.0.0.dist-info}/licenses/COPYING +0 -0
- /terminusgps/{django/mixins.py → mixins.py} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version:
|
|
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
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
terminusgps/default_settings.py,sha256=7GLW3RlkuTbpj82KSWjcbgf-unEmrPvKCyLci14LG6g,537
|
|
3
|
+
terminusgps/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
|
|
4
|
+
terminusgps/validators.py,sha256=R6kS8X-mreNRpmsrNthoa7rxMLy8-iz6FEL-Ww2pFdI,7290
|
|
5
|
+
terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
terminusgps/authorizenet/auth.py,sha256=ZWb9ebJp22o-ImiMLQIzSMENICnbPZOlbX5RO0IEyRU,2199
|
|
7
|
+
terminusgps/authorizenet/constants.py,sha256=eukAZQVuv3XHL-Kd1gqxf8IYUqNC67ClTz4ZU7JPNYE,1459
|
|
8
|
+
terminusgps/authorizenet/controllers.py,sha256=wzCsgza5jdOfeoaQ-IHojEe8G0qVAv5I0F18Fbl1tSY,1644
|
|
9
|
+
terminusgps/authorizenet/validators.py,sha256=Wq4rqEuqG3JzOO7O1wM6oQ0FciNxxOK0HnJqTuLa8CY,3916
|
|
10
|
+
terminusgps/authorizenet/api/__init__.py,sha256=VXR4Yco1yz5R-R7vgaH2zTP9VFqzfvvGy_XJVjyb3i0,154
|
|
11
|
+
terminusgps/authorizenet/api/address_profiles.py,sha256=_BmhMbhrWnUyk7WfY6I0cDxDtS9r2H8l69OnZV6wxRU,4779
|
|
12
|
+
terminusgps/authorizenet/api/customer_profiles.py,sha256=cmXFH4a_Ng26o4u6RMVPBqLWxYSearlhNgM8n7ArZKs,4502
|
|
13
|
+
terminusgps/authorizenet/api/payment_profiles.py,sha256=etyfvivAtXeo-GdUXxyNVkDfrjPg3fLXSnp-aRsnqxY,6516
|
|
14
|
+
terminusgps/authorizenet/api/subscriptions.py,sha256=wdiD3UaKSkPQhTZLrDWq8ZFNPW5JIIjOWyPvAEgb1xg,4541
|
|
15
|
+
terminusgps/authorizenet/api/transactions.py,sha256=y1Bq0niTWsWEi_tMJzXUTYj3_GoJnL5K4fPuGER77kw,2731
|
|
16
|
+
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
terminusgps/wialon/constants.py,sha256=p2BhopeE6lXzjzdzb4ZKOz0rhJQIMUbXLrBy1Yzf57s,13730
|
|
18
|
+
terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
|
|
19
|
+
terminusgps/wialon/session.py,sha256=GdgPvhNbUrvx_-vPRWsjY5TeuI3HgjlHcy315LBpZ7o,5646
|
|
20
|
+
terminusgps/wialon/utils.py,sha256=E7J9s4p7P-OePtttxcBogxu3WiXqf4xxr_Tksbisl60,9957
|
|
21
|
+
terminusgps/wialon/validators.py,sha256=o5__H9HHnGYth8QAKErJG5rEub7FnT8ue0S3IQ8b67o,4232
|
|
22
|
+
terminusgps/wialon/items/__init__.py,sha256=RTiY9ziXqKCB8VWGoExOIErDlUMBBfzzsA7nlOlCZ2w,41
|
|
23
|
+
terminusgps/wialon/items/account.py,sha256=eN9oOuXReVR_x5P9HKg2xlk6vk7FlVnki7bjzlzaWg4,7868
|
|
24
|
+
terminusgps/wialon/items/base.py,sha256=CQwxYhW6HXMCZX8l91pWac5DTBiOqyK_FAThpUQb9fM,9360
|
|
25
|
+
terminusgps/wialon/items/factory.py,sha256=7Xjog8qJPUqKj6RVO92ZaN_fD6WWb9x9ARHkZ3VPeBo,4074
|
|
26
|
+
terminusgps/wialon/items/resource.py,sha256=XTnj6GAnKBDL6eGZsR_KMe2EocM369FXyvSwejM1aLQ,4876
|
|
27
|
+
terminusgps/wialon/items/retranslator.py,sha256=u4qJ44G7r3ntdJ2rFcfkTJhxs9DshER3GG1Yojo5kxw,1458
|
|
28
|
+
terminusgps/wialon/items/route.py,sha256=9hmRBEFRJF3lKukv_y3blZxqxv75YgFCcRALrU6A6QI,1306
|
|
29
|
+
terminusgps/wialon/items/unit.py,sha256=B5iuGEghu89SL8KzYLUytYNRa8cogsVtf-bJ_RybPTA,5522
|
|
30
|
+
terminusgps/wialon/items/unit_group.py,sha256=MIR0x5IlTjcnwx8Y9wXLNTql-wwVVj7NCe7dL2vOw4c,2131
|
|
31
|
+
terminusgps/wialon/items/user.py,sha256=CRSICiJ-qzybEO_gXuKyzW5oa2RQeIp0SzX9ARcdME4,5151
|
|
32
|
+
python_terminusgps-44.0.0.dist-info/METADATA,sha256=otSJOGlPOttJ0Aar_SwAMWze6kri5RXkdiOSGDpZx54,938
|
|
33
|
+
python_terminusgps-44.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
34
|
+
python_terminusgps-44.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
35
|
+
python_terminusgps-44.0.0.dist-info/RECORD,,
|
terminusgps/authorizenet/auth.py
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
2
|
from django.conf import settings
|
|
3
|
-
|
|
4
|
-
from terminusgps.django import settings as default_settings
|
|
5
|
-
|
|
6
|
-
if not settings.configured:
|
|
7
|
-
settings.configure(default_settings)
|
|
3
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
8
4
|
|
|
9
5
|
|
|
10
6
|
def get_merchant_auth() -> merchantAuthenticationType:
|
|
11
7
|
"""
|
|
12
|
-
Returns the
|
|
8
|
+
Returns the merchant authentication information for Authorizenet API controller execution.
|
|
13
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.
|
|
14
11
|
:returns: A merchant authentication object.
|
|
15
|
-
:rtype:
|
|
12
|
+
:rtype: ~authorizenet.apicontractsv1.merchantAuthenticationType
|
|
16
13
|
|
|
17
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)
|
|
18
23
|
return merchantAuthenticationType(
|
|
19
24
|
name=str(settings.MERCHANT_AUTH_LOGIN_ID),
|
|
20
25
|
transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
|
|
@@ -23,21 +28,29 @@ def get_merchant_auth() -> merchantAuthenticationType:
|
|
|
23
28
|
|
|
24
29
|
def get_environment() -> str:
|
|
25
30
|
"""
|
|
26
|
-
Returns the
|
|
31
|
+
Returns the environment for Authorizenet API controller execution.
|
|
27
32
|
|
|
33
|
+
:raises ~django.core.exceptions.ImproperlyConfigured: If the :py:data:`MERCHANT_AUTH_ENVIRONMENT` setting wasn't set.
|
|
28
34
|
:returns: An Authorizenet API environment string.
|
|
29
|
-
:rtype:
|
|
35
|
+
:rtype: str
|
|
30
36
|
|
|
31
37
|
"""
|
|
38
|
+
if not hasattr(settings, "MERCHANT_AUTH_ENVIRONMENT"):
|
|
39
|
+
error_msg: str = "'MERCHANT_AUTH_ENVIRONMENT' setting is required."
|
|
40
|
+
raise ImproperlyConfigured(error_msg)
|
|
32
41
|
return settings.MERCHANT_AUTH_ENVIRONMENT
|
|
33
42
|
|
|
34
43
|
|
|
35
44
|
def get_validation_mode() -> str:
|
|
36
45
|
"""
|
|
37
|
-
Returns the
|
|
46
|
+
Returns the validation mode for Authorizenet API controller execution.
|
|
38
47
|
|
|
48
|
+
:raises ~django.core.exceptions.ImproperlyConfigured: If the :py:data:`MERCHANT_AUTH_VALIDATION_MODE` setting wasn't set.
|
|
39
49
|
:returns: An Authorizenet API validation string.
|
|
40
|
-
:rtype:
|
|
50
|
+
:rtype: str
|
|
41
51
|
|
|
42
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)
|
|
43
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
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
|
|
11
|
-
|
|
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")
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import calendar
|
|
2
|
+
import datetime
|
|
3
|
+
|
|
4
|
+
from django.core.exceptions import ValidationError
|
|
5
|
+
from django.utils.translation import gettext_lazy as _
|
|
6
|
+
|
|
7
|
+
VALID_COUNTRY_CODES = ("+1", "+52")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def validate_e164_phone_number(value: str) -> None:
|
|
11
|
+
"""Raises :py:exc:`~django.core.exceptions.ValidationError` if the value is not a valid `E.164 <https://en.wikipedia.org/wiki/E.164>`_ formatted phone number."""
|
|
12
|
+
if not value:
|
|
13
|
+
raise ValidationError(
|
|
14
|
+
_("This field is required, got '%(value)s'"),
|
|
15
|
+
code="invalid",
|
|
16
|
+
params={"value": value},
|
|
17
|
+
)
|
|
18
|
+
if not value.startswith("+"):
|
|
19
|
+
raise ValidationError(
|
|
20
|
+
_("E.164 phone number must begin with a '+', got '%(char)s'."),
|
|
21
|
+
code="invalid",
|
|
22
|
+
params={"char": value[0]},
|
|
23
|
+
)
|
|
24
|
+
if " " in value:
|
|
25
|
+
raise ValidationError(
|
|
26
|
+
_("E.164 phone number cannot contain spaces, got '%(value)s'."),
|
|
27
|
+
code="invalid",
|
|
28
|
+
params={"value": value},
|
|
29
|
+
)
|
|
30
|
+
if "-" in value:
|
|
31
|
+
raise ValidationError(
|
|
32
|
+
_("E.164 phone number cannot contain hyphens, got '%(value)s'."),
|
|
33
|
+
code="invalid",
|
|
34
|
+
params={"value": value},
|
|
35
|
+
)
|
|
36
|
+
if len(value) < 12:
|
|
37
|
+
raise ValidationError(
|
|
38
|
+
_(
|
|
39
|
+
"E.164 phone number cannot be less than 12 characters in length, got %(len)s."
|
|
40
|
+
),
|
|
41
|
+
code="invalid",
|
|
42
|
+
params={"len": len(value)},
|
|
43
|
+
)
|
|
44
|
+
if len(value) > 15:
|
|
45
|
+
raise ValidationError(
|
|
46
|
+
_(
|
|
47
|
+
"E.164 phone number cannot be greater than 15 characters in length, got %(len)s."
|
|
48
|
+
),
|
|
49
|
+
code="invalid",
|
|
50
|
+
params={"len": len(value)},
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
country_code = value[:-10]
|
|
54
|
+
area_code = value[-10:-7]
|
|
55
|
+
subscriber_number = value[-7:]
|
|
56
|
+
|
|
57
|
+
if len(country_code) < 2 or len(country_code) > 5:
|
|
58
|
+
raise ValidationError(
|
|
59
|
+
_(
|
|
60
|
+
"E.164 phone number country code must be between 2 and 5 characters in length, got %(len)s."
|
|
61
|
+
),
|
|
62
|
+
code="invalid",
|
|
63
|
+
params={"len": len(country_code)},
|
|
64
|
+
)
|
|
65
|
+
if country_code not in VALID_COUNTRY_CODES:
|
|
66
|
+
raise ValidationError(
|
|
67
|
+
_(
|
|
68
|
+
"E.164 phone number cannot contain an invalid country code, got '%(country_code)s'."
|
|
69
|
+
),
|
|
70
|
+
code="invalid",
|
|
71
|
+
params={"country_code": country_code},
|
|
72
|
+
)
|
|
73
|
+
if not len(area_code) == 3:
|
|
74
|
+
raise ValidationError(
|
|
75
|
+
_(
|
|
76
|
+
"E.164 phone number must contain a 3-digit area code, got '%(area_code)s'."
|
|
77
|
+
),
|
|
78
|
+
code="invalid",
|
|
79
|
+
params={"area_code": area_code},
|
|
80
|
+
)
|
|
81
|
+
if not area_code.isdigit():
|
|
82
|
+
raise ValidationError(
|
|
83
|
+
_(
|
|
84
|
+
"E.164 phone number must have a valid area code, got '%(area_code)s'."
|
|
85
|
+
),
|
|
86
|
+
code="invalid",
|
|
87
|
+
params={"area_code": area_code},
|
|
88
|
+
)
|
|
89
|
+
if not len(subscriber_number) == 7:
|
|
90
|
+
raise ValidationError(
|
|
91
|
+
_(
|
|
92
|
+
"E.164 phone number must contain a 7-digit subscriber number, got '%(subscriber_number)s'."
|
|
93
|
+
),
|
|
94
|
+
code="invalid",
|
|
95
|
+
params={"subscriber_number": subscriber_number},
|
|
96
|
+
)
|
|
97
|
+
if not subscriber_number.isdigit():
|
|
98
|
+
raise ValidationError(
|
|
99
|
+
_(
|
|
100
|
+
"E.164 phone number must have a valid subscriber number, got '%(subscriber_number)s'."
|
|
101
|
+
),
|
|
102
|
+
code="invalid",
|
|
103
|
+
params={"subscriber_number": subscriber_number},
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def validate_credit_card_number(value: str) -> None:
|
|
108
|
+
"""
|
|
109
|
+
Raises :py:exc:`~django.core.exceptions.ValidationError` if the value is an invalid credit card number.
|
|
110
|
+
|
|
111
|
+
Uses the `Luhn algorithm <https://en.wikipedia.org/wiki/Luhn_algorithm>`_ to validate the credit card number.
|
|
112
|
+
|
|
113
|
+
:param value: A credit card number string.
|
|
114
|
+
:type value: str
|
|
115
|
+
:raises ValidationError: If the value contains non-digit characters.
|
|
116
|
+
:raises ValidationError: If the value fails the Luhn algorithm.
|
|
117
|
+
:returns: Nothing.
|
|
118
|
+
:rtype: None
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
if not value.isdigit():
|
|
122
|
+
raise ValidationError(
|
|
123
|
+
_("Credit card number can only contain digits. Got '%(value)s'."),
|
|
124
|
+
code="invalid",
|
|
125
|
+
params={"value": value},
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
card_number = [int(num) for num in reversed(value)]
|
|
129
|
+
even_digits = card_number[1::2]
|
|
130
|
+
odd_digits = card_number[0::2]
|
|
131
|
+
|
|
132
|
+
checksum = 0
|
|
133
|
+
checksum += sum(
|
|
134
|
+
[
|
|
135
|
+
digit * 2 if digit * 2 <= 9 else (digit * 2) % 9 or 9
|
|
136
|
+
for digit in even_digits
|
|
137
|
+
]
|
|
138
|
+
)
|
|
139
|
+
checksum += sum([digit for digit in odd_digits])
|
|
140
|
+
|
|
141
|
+
if checksum % 10 != 0:
|
|
142
|
+
raise ValidationError(_("Invalid credit card number."), code="invalid")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def validate_credit_card_expiry_month(value: str) -> None:
|
|
146
|
+
"""
|
|
147
|
+
Raises :py:exc:`~django.core.exceptions.ValidationError` if the value is an invalid credit card expiration date month.
|
|
148
|
+
|
|
149
|
+
:param value: A credit card expiration year string.
|
|
150
|
+
:type value: str
|
|
151
|
+
:raises ValidationError: If the value contains non-digit characters.
|
|
152
|
+
:raises ValidationError: If the value is negative.
|
|
153
|
+
:raises ValidationError: If the value isn't between 1-12.
|
|
154
|
+
:returns: Nothing.
|
|
155
|
+
:rtype: None
|
|
156
|
+
|
|
157
|
+
"""
|
|
158
|
+
if not value.isdigit():
|
|
159
|
+
raise ValidationError(
|
|
160
|
+
_("Expiration month can only contain digits, got '%(value)s'."),
|
|
161
|
+
code="invalid",
|
|
162
|
+
params={"value": value},
|
|
163
|
+
)
|
|
164
|
+
if not int(value) > 0:
|
|
165
|
+
raise ValidationError(
|
|
166
|
+
_(
|
|
167
|
+
"Expiration month can only be a positive value, got '%(value)s'."
|
|
168
|
+
),
|
|
169
|
+
code="invalid",
|
|
170
|
+
params={"value": value},
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
calendar.Month(int(value))
|
|
175
|
+
except ValueError:
|
|
176
|
+
raise ValidationError(
|
|
177
|
+
_("Expiration month must be between 1-12, got '%(value)s'."),
|
|
178
|
+
code="invalid",
|
|
179
|
+
params={"value": value},
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def validate_credit_card_expiry_year(value: str) -> None:
|
|
184
|
+
"""
|
|
185
|
+
Raises :py:exc:`~django.core.exceptions.ValidationError` if the value is an invalid credit card expiration date year.
|
|
186
|
+
|
|
187
|
+
:param value: A credit card expiration year string.
|
|
188
|
+
:type value: str
|
|
189
|
+
:raises ValidationError: If the value contains non-digit characters.
|
|
190
|
+
:raises ValidationError: If the value is negative.
|
|
191
|
+
:raises ValidationError: If the value is a year in the past.
|
|
192
|
+
:returns: Nothing.
|
|
193
|
+
:rtype: None
|
|
194
|
+
|
|
195
|
+
"""
|
|
196
|
+
if not value.isdigit():
|
|
197
|
+
raise ValidationError(
|
|
198
|
+
_("Expiration year can only contain digits, got '%(value)s'."),
|
|
199
|
+
code="invalid",
|
|
200
|
+
params={"value": value},
|
|
201
|
+
)
|
|
202
|
+
if not int(value) > 0:
|
|
203
|
+
raise ValidationError(
|
|
204
|
+
_(
|
|
205
|
+
"Expiration year can only be a positive value, got '%(value)s'."
|
|
206
|
+
),
|
|
207
|
+
code="invalid",
|
|
208
|
+
params={"value": value},
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
input_year = datetime.datetime.strptime(value, "%y").year
|
|
212
|
+
this_year = datetime.datetime.now().year
|
|
213
|
+
|
|
214
|
+
if not input_year >= this_year:
|
|
215
|
+
raise ValidationError(
|
|
216
|
+
_("Expiration year cannot be in the past, got '%(value)s'."),
|
|
217
|
+
code="invalid",
|
|
218
|
+
params={"value": value},
|
|
219
|
+
)
|
|
@@ -19,7 +19,7 @@ class WialonAccount(WialonObject):
|
|
|
19
19
|
:param billing_plan: A Wialon account billing plan.
|
|
20
20
|
:type billing_plan: str
|
|
21
21
|
:raises ValueError: If ``resource_id`` wasn't a digit.
|
|
22
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
22
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
23
23
|
:returns: A Wialon object dictionary.
|
|
24
24
|
:rtype: dict[str, str]
|
|
25
25
|
|
|
@@ -45,7 +45,7 @@ class WialonAccount(WialonObject):
|
|
|
45
45
|
:param reasons: An optional collection of reason strings. Default is :py:obj:`None`.
|
|
46
46
|
:type reasons: ~collections.abc.Collection[str] | None
|
|
47
47
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
48
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
48
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
49
49
|
:returns: An empty dictionary.
|
|
50
50
|
:rtype: dict[str, str]
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ class WialonAccount(WialonObject):
|
|
|
62
62
|
Enables the account in Wialon.
|
|
63
63
|
|
|
64
64
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
65
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
65
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
66
66
|
:returns: An empty dictionary.
|
|
67
67
|
:rtype: dict[str, str]
|
|
68
68
|
|
|
@@ -77,7 +77,7 @@ class WialonAccount(WialonObject):
|
|
|
77
77
|
Disables the account in Wialon.
|
|
78
78
|
|
|
79
79
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
80
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
80
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
81
81
|
:returns: An empty dictionary.
|
|
82
82
|
:rtype: dict[str, str]
|
|
83
83
|
|
|
@@ -103,7 +103,7 @@ class WialonAccount(WialonObject):
|
|
|
103
103
|
:param description: A description for the payment.
|
|
104
104
|
:type description: str
|
|
105
105
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
106
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
106
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
107
107
|
:returns: An empty dictionary.
|
|
108
108
|
:rtype: dict[str, str]
|
|
109
109
|
|
|
@@ -125,7 +125,7 @@ class WialonAccount(WialonObject):
|
|
|
125
125
|
:param enabled: Whether to set the account as a dealer or not.
|
|
126
126
|
:type enabled: bool
|
|
127
127
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
128
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
128
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
129
129
|
:returns: An empty dictionary.
|
|
130
130
|
:rtype: dict[str, str]
|
|
131
131
|
|
|
@@ -151,7 +151,7 @@ class WialonAccount(WialonObject):
|
|
|
151
151
|
:param deny_balance: Balance required for service denial. Default is ``0.00``.
|
|
152
152
|
:type deny_balance: ~decimal.Decimal
|
|
153
153
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
154
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
154
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
155
155
|
:returns: An empty dictionary.
|
|
156
156
|
:rtype: dict[str, str]
|
|
157
157
|
|
|
@@ -173,7 +173,7 @@ class WialonAccount(WialonObject):
|
|
|
173
173
|
:param name: A Wialon billing plan name.
|
|
174
174
|
:type name: str
|
|
175
175
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
176
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
176
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
177
177
|
:returns: An empty dictionary.
|
|
178
178
|
:rtype: dict[str, str]
|
|
179
179
|
|
|
@@ -190,7 +190,7 @@ class WialonAccount(WialonObject):
|
|
|
190
190
|
:param days: Minimum number of days as an integer.
|
|
191
191
|
:type days: int
|
|
192
192
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
193
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
193
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
194
194
|
:returns: An empty dictionary.
|
|
195
195
|
:rtype: dict[str, str]
|
|
196
196
|
|
|
@@ -207,7 +207,7 @@ class WialonAccount(WialonObject):
|
|
|
207
207
|
:param response_type: A response flag integer. Default is ``1``.
|
|
208
208
|
:type response_type: int
|
|
209
209
|
:raises AssertionError: If the Wialon account id wasn't set.
|
|
210
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
210
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
211
211
|
:returns: A dictionary containing the account's data from Wialon.
|
|
212
212
|
:rtype: dict[str, str]
|
|
213
213
|
|
terminusgps/wialon/items/base.py
CHANGED
|
@@ -111,7 +111,7 @@ class WialonObject(ABC):
|
|
|
111
111
|
Returns a list of admin field dictionaries from Wialon.
|
|
112
112
|
|
|
113
113
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
114
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
114
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
115
115
|
:returns: A list of admin field dictionaries.
|
|
116
116
|
:rtype: list[dict[str, str]]
|
|
117
117
|
|
|
@@ -142,7 +142,7 @@ class WialonObject(ABC):
|
|
|
142
142
|
:type id: int | str | None
|
|
143
143
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
144
144
|
:raises ValueError: If ``id`` wasn't a digit.
|
|
145
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
145
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
146
146
|
:returns: An admin field dictionary.
|
|
147
147
|
:rtype: dict[str, str]
|
|
148
148
|
|
|
@@ -168,7 +168,7 @@ class WialonObject(ABC):
|
|
|
168
168
|
:type id: int | str
|
|
169
169
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
170
170
|
:raises ValueError: If ``id`` wasn't a digit.
|
|
171
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
171
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
172
172
|
:returns: An empty dictionary.
|
|
173
173
|
:rtype: dict[str, str]
|
|
174
174
|
|
|
@@ -185,7 +185,7 @@ class WialonObject(ABC):
|
|
|
185
185
|
Returns a list of custom field dictionaries from Wialon.
|
|
186
186
|
|
|
187
187
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
188
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
188
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
189
189
|
:returns: A list of admin field dictionaries.
|
|
190
190
|
:rtype: list[dict[str, str]]
|
|
191
191
|
|
|
@@ -214,7 +214,7 @@ class WialonObject(ABC):
|
|
|
214
214
|
:type id: int | str | None
|
|
215
215
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
216
216
|
:raises ValueError: If ``id`` wasn't a digit.
|
|
217
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
217
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
218
218
|
:returns: A custom field dictionary.
|
|
219
219
|
:rtype: dict[str, str]
|
|
220
220
|
|
|
@@ -240,7 +240,7 @@ class WialonObject(ABC):
|
|
|
240
240
|
:type id: int | str
|
|
241
241
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
242
242
|
:raises ValueError: If ``id`` wasn't a digit.
|
|
243
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
243
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
244
244
|
:returns: An empty dictionary.
|
|
245
245
|
:rtype: dict[str, str]
|
|
246
246
|
|
|
@@ -261,7 +261,7 @@ class WialonObject(ABC):
|
|
|
261
261
|
:param value: Profile field value.
|
|
262
262
|
:type value: str
|
|
263
263
|
:raises AssertionError: If the Wialon object id wasn't set.
|
|
264
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
264
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
265
265
|
:returns: A profile field dictionary.
|
|
266
266
|
:rtype: dict[str, str]
|
|
267
267
|
|
|
@@ -24,7 +24,7 @@ class WialonResource(WialonObject):
|
|
|
24
24
|
:param skip_creator_check: Whether to ignore creator check during the API call. Default is :py:obj:`False`.
|
|
25
25
|
:type skip_creator_check: bool
|
|
26
26
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
27
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
27
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
28
28
|
:returns: A Wialon object dictionary.
|
|
29
29
|
:rtype: dict[str, str]
|
|
30
30
|
|
|
@@ -56,7 +56,7 @@ class WialonResource(WialonObject):
|
|
|
56
56
|
:param notification_ids: An optional collection of notification ids. Default is :py:obj:`None`.
|
|
57
57
|
:type notification_ids: ~collections.abc.Collection[int] | None
|
|
58
58
|
:raises AssertionError: If the Wialon resource id wasn't set.
|
|
59
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
59
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
60
60
|
:returns: A dictionary of notification data.
|
|
61
61
|
:rtype: dict[str, str]
|
|
62
62
|
|
|
@@ -89,7 +89,7 @@ class WialonResource(WialonObject):
|
|
|
89
89
|
:raises AssertionError: If the Wialon resource id wasn't set.
|
|
90
90
|
:raises ValueError: If ``unit_id`` wasn't a digit.
|
|
91
91
|
:raises ValueError: If ``driver_id`` wasn't a digit.
|
|
92
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
92
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
93
93
|
:returns: A dictionary of Wialon drivers.
|
|
94
94
|
:rtype: dict[str, str]
|
|
95
95
|
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
|
|
3
1
|
from terminusgps.wialon import flags
|
|
4
2
|
from terminusgps.wialon.items.base import WialonObject
|
|
5
3
|
|
|
6
|
-
WialonRetranslatorConfiguration = typing.TypedDict(
|
|
7
|
-
"WialonRetranslatorConfiguration",
|
|
8
|
-
{
|
|
9
|
-
"protocol": str,
|
|
10
|
-
"server": str,
|
|
11
|
-
"port": int,
|
|
12
|
-
"auth": str,
|
|
13
|
-
"ssl": int,
|
|
14
|
-
"debug": int,
|
|
15
|
-
"v6type": int,
|
|
16
|
-
},
|
|
17
|
-
)
|
|
18
|
-
|
|
19
4
|
|
|
20
5
|
class WialonRetranslator(WialonObject):
|
|
21
6
|
"""A Wialon `retranslator <https://wialon.com/en/gps-hardware/soft>`_."""
|
|
22
7
|
|
|
23
8
|
def create(
|
|
24
|
-
self,
|
|
25
|
-
creator_id: int | str,
|
|
26
|
-
name: str,
|
|
27
|
-
config: WialonRetranslatorConfiguration,
|
|
9
|
+
self, creator_id: int | str, name: str, config: str
|
|
28
10
|
) -> dict[str, str]:
|
|
29
11
|
"""
|
|
30
12
|
Creates the retranslator in Wialon and sets its id.
|
|
@@ -34,9 +16,9 @@ class WialonRetranslator(WialonObject):
|
|
|
34
16
|
:param name: Wialon retranslator name.
|
|
35
17
|
:type name: str
|
|
36
18
|
:param config: Wialon retranslator configuration.
|
|
37
|
-
:type config:
|
|
19
|
+
:type config: str
|
|
38
20
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
39
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
21
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
40
22
|
:returns: A Wialon object dictionary.
|
|
41
23
|
:rtype: dict[str, str]
|
|
42
24
|
|
|
@@ -14,7 +14,7 @@ class WialonRoute(WialonObject):
|
|
|
14
14
|
:param name: Wialon route name.
|
|
15
15
|
:type name: str
|
|
16
16
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
17
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
17
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
18
18
|
:returns: A Wialon object dictionary.
|
|
19
19
|
:rtype: dict[str, str]
|
|
20
20
|
|
terminusgps/wialon/items/unit.py
CHANGED
|
@@ -21,7 +21,7 @@ class WialonUnit(WialonObject):
|
|
|
21
21
|
:type hw_type_id: int | str
|
|
22
22
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
23
23
|
:raises ValueError: If ``hw_type_id`` wasn't a digit.
|
|
24
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
24
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
25
25
|
:returns: A Wialon object dictionary.
|
|
26
26
|
:rtype: dict[str, str]
|
|
27
27
|
|
|
@@ -51,7 +51,7 @@ class WialonUnit(WialonObject):
|
|
|
51
51
|
Activates the unit in Wialon.
|
|
52
52
|
|
|
53
53
|
:raises AssertionError: If the Wialon unit id wasn't set.
|
|
54
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
54
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
55
55
|
:returns: A dictionary with the unit's current status.
|
|
56
56
|
:rtype: dict[str, str]
|
|
57
57
|
|
|
@@ -66,7 +66,7 @@ class WialonUnit(WialonObject):
|
|
|
66
66
|
Deactivates the unit in Wialon.
|
|
67
67
|
|
|
68
68
|
:raises AssertionError: If the Wialon unit id wasn't set.
|
|
69
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
69
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
70
70
|
:returns: A dictionary with the unit's current status.
|
|
71
71
|
:rtype: dict[str, str]
|
|
72
72
|
|
|
@@ -98,7 +98,7 @@ class WialonUnit(WialonObject):
|
|
|
98
98
|
:param flags: Command execution flags. Default is ``0``.
|
|
99
99
|
:type flags: int
|
|
100
100
|
:raises AssertionError: If the Wialon unit id wasn't set.
|
|
101
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
101
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
102
102
|
:returns: An empty dictionary.
|
|
103
103
|
:rtype: dict[str, str]
|
|
104
104
|
|
|
@@ -126,7 +126,7 @@ class WialonUnit(WialonObject):
|
|
|
126
126
|
:param command_ids: An optional collection of command ids. Default is :py:obj:`None`.
|
|
127
127
|
:type command_ids: ~collections.abc.Collection[int] | None
|
|
128
128
|
:raises AssertionError: If the Wialon unit id wasn't set.
|
|
129
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
129
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
130
130
|
:returns: A dictionary of command definition data.
|
|
131
131
|
:rtype: dict[str, str]
|
|
132
132
|
|
|
@@ -16,7 +16,7 @@ class WialonUnitGroup(WialonObject):
|
|
|
16
16
|
:param name: Name for the unit group.
|
|
17
17
|
:type name: str
|
|
18
18
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
19
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
19
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
20
20
|
:returns: A Wialon object dictionary.
|
|
21
21
|
:rtype: dict[str, str]
|
|
22
22
|
|
|
@@ -45,7 +45,7 @@ class WialonUnitGroup(WialonObject):
|
|
|
45
45
|
:param unit_ids: A collection of Wialon unit ids.
|
|
46
46
|
:type unit_ids: ~collections.abc.Collection[int]
|
|
47
47
|
:raises AssertionError: If the Wialon unit group id wasn't set.
|
|
48
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
48
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
49
49
|
:returns: A dictionary containing the unit group's new unit list.
|
|
50
50
|
:rtype: dict[str, str]
|
|
51
51
|
|
terminusgps/wialon/items/user.py
CHANGED
|
@@ -18,7 +18,7 @@ class WialonUser(WialonObject):
|
|
|
18
18
|
:param password: Wialon user password.
|
|
19
19
|
:type password: str
|
|
20
20
|
:raises ValueError: If ``creator_id`` wasn't a digit.
|
|
21
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
21
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
22
22
|
:returns: A Wialon object dictionary.
|
|
23
23
|
:rtype: dict[str, str]
|
|
24
24
|
|
|
@@ -52,7 +52,7 @@ class WialonUser(WialonObject):
|
|
|
52
52
|
:param flags: Response flags. Default is ``0x1``.
|
|
53
53
|
:type flags: int
|
|
54
54
|
:raises AssertionError: If the Wialon user id wasn't set.
|
|
55
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
55
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
56
56
|
:returns: A dictionary of Wialon objects.
|
|
57
57
|
:rtype: dict[str, str]
|
|
58
58
|
|
|
@@ -79,7 +79,7 @@ class WialonUser(WialonObject):
|
|
|
79
79
|
:type access_mask: int
|
|
80
80
|
:raises AssertionError: If the Wialon user id wasn't set.
|
|
81
81
|
:raises ValueError: If the other Wialon object's id wasn't set.
|
|
82
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
82
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
83
83
|
:returns: An empty dictionary.
|
|
84
84
|
:rtype: dict[str, str]
|
|
85
85
|
|
|
@@ -100,7 +100,7 @@ class WialonUser(WialonObject):
|
|
|
100
100
|
:param flags_mask: An integer mask which determines which bits will be changed.
|
|
101
101
|
:type flags_mask: int
|
|
102
102
|
:raises AssertionError: If the Wialon user id wasn't set.
|
|
103
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
103
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
104
104
|
:returns: A dictionary containing the user's new settings flags.
|
|
105
105
|
:rtype: dict[str, str]
|
|
106
106
|
|
|
@@ -121,7 +121,7 @@ class WialonUser(WialonObject):
|
|
|
121
121
|
:param new_password: The user's new Wialon password.
|
|
122
122
|
:type new_password: str
|
|
123
123
|
:raises AssertionError: If the Wialon user id wasn't set.
|
|
124
|
-
:raises WialonAPIError: If something went wrong calling the Wialon API.
|
|
124
|
+
:raises ~terminusgps.wialon.session.WialonAPIError: If something went wrong calling the Wialon API.
|
|
125
125
|
:returns: An empty dictionary.
|
|
126
126
|
:rtype: dict[str, str]
|
|
127
127
|
|
terminusgps/wialon/session.py
CHANGED
|
@@ -5,6 +5,8 @@ import wialon.api
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class WialonAPIError(Exception):
|
|
8
|
+
"""Raised when a Wialon API call fails."""
|
|
9
|
+
|
|
8
10
|
def __init__(self, message, *args, **kwargs) -> None:
|
|
9
11
|
self.message = message
|
|
10
12
|
self._code = int(message._code)
|
|
@@ -12,6 +14,7 @@ class WialonAPIError(Exception):
|
|
|
12
14
|
|
|
13
15
|
@property
|
|
14
16
|
def code(self) -> int:
|
|
17
|
+
"""Wialon API error code."""
|
|
15
18
|
return self._code
|
|
16
19
|
|
|
17
20
|
|
|
@@ -35,18 +38,18 @@ class WialonSession:
|
|
|
35
38
|
"""
|
|
36
39
|
Starts or continues a Wialon API session.
|
|
37
40
|
|
|
38
|
-
:param token:
|
|
39
|
-
:type token:
|
|
41
|
+
:param token: A Wialon API token. If not provided, the environment variable ``"WIALON_TOKEN"`` is used.
|
|
42
|
+
:type token: str | None
|
|
40
43
|
:param sid: An optional Wialon API session id. If provided, the session is continued.
|
|
41
|
-
:type sid:
|
|
44
|
+
:type sid: str | None
|
|
42
45
|
:param scheme: HTTP request scheme to use. Default is ``"https"``.
|
|
43
|
-
:type scheme:
|
|
46
|
+
:type scheme: str
|
|
44
47
|
:param host: Wialon API host url. Default is ``"hst-api.wialon.com"``.
|
|
45
|
-
:type host:
|
|
48
|
+
:type host: str
|
|
46
49
|
:param port: Wialon API port. Default is ``443``.
|
|
47
|
-
:type port:
|
|
50
|
+
:type port: int
|
|
48
51
|
:returns: Nothing.
|
|
49
|
-
:rtype:
|
|
52
|
+
:rtype: None
|
|
50
53
|
|
|
51
54
|
"""
|
|
52
55
|
|
|
@@ -69,7 +72,7 @@ class WialonSession:
|
|
|
69
72
|
|
|
70
73
|
:raises AssertionError: If the session's Wialon API :py:attr:`token` wasn't set.
|
|
71
74
|
:returns: A valid Wialon API session.
|
|
72
|
-
:rtype:
|
|
75
|
+
:rtype: ~terminusgps.wialon.session.WialonSession
|
|
73
76
|
|
|
74
77
|
"""
|
|
75
78
|
assert self.token, "Wialon API token wasn't set."
|
|
@@ -81,7 +84,7 @@ class WialonSession:
|
|
|
81
84
|
Logs out of the session by calling :py:meth:`logout`.
|
|
82
85
|
|
|
83
86
|
:returns: Nothing.
|
|
84
|
-
:rtype:
|
|
87
|
+
:rtype: None
|
|
85
88
|
|
|
86
89
|
"""
|
|
87
90
|
self.logout()
|
|
@@ -95,8 +98,8 @@ class WialonSession:
|
|
|
95
98
|
"""
|
|
96
99
|
User id of the session's authenticated Wialon user.
|
|
97
100
|
|
|
98
|
-
:type:
|
|
99
|
-
:value:
|
|
101
|
+
:type: str | None
|
|
102
|
+
:value: None
|
|
100
103
|
"""
|
|
101
104
|
return self._uid
|
|
102
105
|
|
|
@@ -105,8 +108,8 @@ class WialonSession:
|
|
|
105
108
|
"""
|
|
106
109
|
Username of the session's authenticated Wialon user.
|
|
107
110
|
|
|
108
|
-
:type:
|
|
109
|
-
:value:
|
|
111
|
+
:type: str | None
|
|
112
|
+
:value: None
|
|
110
113
|
|
|
111
114
|
"""
|
|
112
115
|
return self._username
|
|
@@ -120,8 +123,8 @@ class WialonSession:
|
|
|
120
123
|
|
|
121
124
|
Returns :py:obj:`None` if the session wasn't logged in.
|
|
122
125
|
|
|
123
|
-
:type:
|
|
124
|
-
:value:
|
|
126
|
+
:type: str | None
|
|
127
|
+
:value: None
|
|
125
128
|
|
|
126
129
|
"""
|
|
127
130
|
return self.wialon_api.sid
|
|
@@ -131,7 +134,7 @@ class WialonSession:
|
|
|
131
134
|
"""
|
|
132
135
|
Wialon API token set during :py:meth:`WialonSession.__init__`.
|
|
133
136
|
|
|
134
|
-
:type:
|
|
137
|
+
:type: str
|
|
135
138
|
|
|
136
139
|
"""
|
|
137
140
|
return str(self._token)
|
|
@@ -141,13 +144,13 @@ class WialonSession:
|
|
|
141
144
|
Logs into the Wialon API, starts a new session then returns its id.
|
|
142
145
|
|
|
143
146
|
:param token: An active Wialon API token.
|
|
144
|
-
:type token:
|
|
147
|
+
:type token: str
|
|
145
148
|
:param flags: A login response flag integer.
|
|
146
|
-
:type flags:
|
|
149
|
+
:type flags: int
|
|
147
150
|
:raises WialonError: If the login fails.
|
|
148
151
|
:raises AssertionError: If the login token was not set.
|
|
149
152
|
:returns: The new session id.
|
|
150
|
-
:rtype:
|
|
153
|
+
:rtype: str
|
|
151
154
|
|
|
152
155
|
"""
|
|
153
156
|
try:
|
|
@@ -165,7 +168,7 @@ class WialonSession:
|
|
|
165
168
|
Logs out of the Wialon API session.
|
|
166
169
|
|
|
167
170
|
:returns: Nothing.
|
|
168
|
-
:rtype:
|
|
171
|
+
:rtype: None
|
|
169
172
|
|
|
170
173
|
"""
|
|
171
174
|
sid = self.wialon_api.sid
|
|
@@ -182,10 +185,10 @@ class WialonSession:
|
|
|
182
185
|
Sets the Wialon API session's attributes based on a login response.
|
|
183
186
|
|
|
184
187
|
:param login_response: A dictionary returned from :py:meth:`login`.
|
|
185
|
-
:type login_response:
|
|
188
|
+
:type login_response: dict
|
|
186
189
|
:raises ValueError: If ``login_response`` wasn't provided.
|
|
187
190
|
:returns: Nothing.
|
|
188
|
-
:rtype:
|
|
191
|
+
:rtype: None
|
|
189
192
|
|
|
190
193
|
"""
|
|
191
194
|
if login_response is None:
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
terminusgps/authorizenet/auth.py,sha256=CKT_pfDEL-53GceOEaFtIU6IBXVuVd8MVHikpPAX0xY,1184
|
|
4
|
-
terminusgps/authorizenet/constants.py,sha256=xU2oGpxsAlgJftI_S4WL8Ii5TJ3OD5FXnCUNceLzXbM,1015
|
|
5
|
-
terminusgps/authorizenet/controllers.py,sha256=oEomwVPu6uT2z5BGKKm-zLWXhODvBajUQ4GxDOHTecQ,2011
|
|
6
|
-
terminusgps/authorizenet/validators.py,sha256=Wq4rqEuqG3JzOO7O1wM6oQ0FciNxxOK0HnJqTuLa8CY,3916
|
|
7
|
-
terminusgps/authorizenet/api/__init__.py,sha256=VXR4Yco1yz5R-R7vgaH2zTP9VFqzfvvGy_XJVjyb3i0,154
|
|
8
|
-
terminusgps/authorizenet/api/address_profiles.py,sha256=_BmhMbhrWnUyk7WfY6I0cDxDtS9r2H8l69OnZV6wxRU,4779
|
|
9
|
-
terminusgps/authorizenet/api/customer_profiles.py,sha256=cmXFH4a_Ng26o4u6RMVPBqLWxYSearlhNgM8n7ArZKs,4502
|
|
10
|
-
terminusgps/authorizenet/api/payment_profiles.py,sha256=etyfvivAtXeo-GdUXxyNVkDfrjPg3fLXSnp-aRsnqxY,6516
|
|
11
|
-
terminusgps/authorizenet/api/subscriptions.py,sha256=wdiD3UaKSkPQhTZLrDWq8ZFNPW5JIIjOWyPvAEgb1xg,4541
|
|
12
|
-
terminusgps/authorizenet/api/transactions.py,sha256=y1Bq0niTWsWEi_tMJzXUTYj3_GoJnL5K4fPuGER77kw,2731
|
|
13
|
-
terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
|
|
15
|
-
terminusgps/django/settings.py,sha256=JcHo9uonGLXoIbapkTYJ4GSIfiS74CtChzw1Cuq4XOk,644
|
|
16
|
-
terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
|
|
17
|
-
terminusgps/django/validators.py,sha256=chuJ4I1DBQ_H5dwb6CXPEIyv_CUuEzJzRUSijfss1vc,3510
|
|
18
|
-
terminusgps/django/forms/__init__.py,sha256=hh8Z9AC_u2m2bu3h6sdmPyndfQneCEVovENPHmoTDC0,21
|
|
19
|
-
terminusgps/django/forms/fields.py,sha256=BfuPzOZyGvWsEzONW2h4i01fhoL0IS0-gDdBKW4jHgI,2225
|
|
20
|
-
terminusgps/django/forms/forms.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
terminusgps/django/forms/renderer.py,sha256=QSLQ94Ff7ZaV1jD6wAL-ltvdKIblED8Wsv5EXvSbUJ4,394
|
|
22
|
-
terminusgps/django/forms/widgets.py,sha256=No4hPQ-BK5rrotaQ5iJEjWo8quYIPNf_1C2y4OAIxro,2037
|
|
23
|
-
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
terminusgps/wialon/constants.py,sha256=p2BhopeE6lXzjzdzb4ZKOz0rhJQIMUbXLrBy1Yzf57s,13730
|
|
25
|
-
terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
|
|
26
|
-
terminusgps/wialon/session.py,sha256=-WSjbWT5GpueD3xEM9EHBx0iPTOMB1BUr1swzyPZPZg,5797
|
|
27
|
-
terminusgps/wialon/utils.py,sha256=E7J9s4p7P-OePtttxcBogxu3WiXqf4xxr_Tksbisl60,9957
|
|
28
|
-
terminusgps/wialon/validators.py,sha256=o5__H9HHnGYth8QAKErJG5rEub7FnT8ue0S3IQ8b67o,4232
|
|
29
|
-
terminusgps/wialon/items/__init__.py,sha256=RTiY9ziXqKCB8VWGoExOIErDlUMBBfzzsA7nlOlCZ2w,41
|
|
30
|
-
terminusgps/wialon/items/account.py,sha256=FL_PZXimLarP3tZX1E9dLA977mSUOx98YJxVyc4WOxg,7588
|
|
31
|
-
terminusgps/wialon/items/base.py,sha256=YSK00q2qUR9SluXojfy2HjfVbMQfnHp4djTcpNSCer4,9164
|
|
32
|
-
terminusgps/wialon/items/factory.py,sha256=7Xjog8qJPUqKj6RVO92ZaN_fD6WWb9x9ARHkZ3VPeBo,4074
|
|
33
|
-
terminusgps/wialon/items/resource.py,sha256=L8myvk9I8snUKFPWBdhMmP1KCb5aC8OtOe4P7Lb2KoY,4792
|
|
34
|
-
terminusgps/wialon/items/retranslator.py,sha256=lWywPciEkazL0GbEV0r1TjBSNEpQcCQ5tDBOua0pGtE,1827
|
|
35
|
-
terminusgps/wialon/items/route.py,sha256=nXFQNzIU2c-_rG-8r_cvZPq_hB7vQgMO5zIe7Sz5KmU,1278
|
|
36
|
-
terminusgps/wialon/items/unit.py,sha256=Ze3t5aK3UX-z95BiDSaDCttCvAs-g6ZyA_NWx3uYp6Y,5382
|
|
37
|
-
terminusgps/wialon/items/unit_group.py,sha256=zP6nBETRQ3tI6V7BYq5yoyG78DGyZM-rU14TMRrpAZA,2075
|
|
38
|
-
terminusgps/wialon/items/user.py,sha256=HY3EWKD7RwcySjPL91Ulmll_gZZXoRaIr6v6I8tW2VM,5011
|
|
39
|
-
python_terminusgps-43.2.0.dist-info/METADATA,sha256=TFEZSdm0iQwTrZfMqRfI6kwSxUOxoKC7KV9SLSuADq0,938
|
|
40
|
-
python_terminusgps-43.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
41
|
-
python_terminusgps-43.2.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
42
|
-
python_terminusgps-43.2.0.dist-info/RECORD,,
|
terminusgps/django/__init__.py
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .forms import *
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
from collections.abc import Sequence
|
|
2
|
-
|
|
3
|
-
from authorizenet import apicontractsv1
|
|
4
|
-
from django import forms
|
|
5
|
-
|
|
6
|
-
from .widgets import AddressWidget, CreditCardWidget
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class CreditCardField(forms.MultiValueField):
|
|
10
|
-
require_all_fields = True
|
|
11
|
-
|
|
12
|
-
def __init__(self, fields=(), widget=CreditCardWidget(), *args, **kwargs) -> None:
|
|
13
|
-
if not fields:
|
|
14
|
-
fields = (
|
|
15
|
-
forms.CharField(label="Card #"),
|
|
16
|
-
forms.IntegerField(label="Expiry Month", min_value=1, max_value=12),
|
|
17
|
-
forms.IntegerField(label="Expiry Year"),
|
|
18
|
-
forms.CharField(label="CCV #"),
|
|
19
|
-
)
|
|
20
|
-
super().__init__(fields=fields, widget=widget, *args, **kwargs)
|
|
21
|
-
|
|
22
|
-
def compress(self, data_list: Sequence[str]) -> apicontractsv1.creditCardType:
|
|
23
|
-
"""Compresses ``data_list`` into a :py:obj:`~authorizenet.apicontractsv1.creditCardType`."""
|
|
24
|
-
return apicontractsv1.creditCardType(
|
|
25
|
-
**{
|
|
26
|
-
"cardNumber": data_list[0],
|
|
27
|
-
"expirationDate": f"{data_list[1]}-{data_list[2]}",
|
|
28
|
-
"cardCode": data_list[3],
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class AddressField(forms.MultiValueField):
|
|
34
|
-
require_all_fields = True
|
|
35
|
-
|
|
36
|
-
def __init__(self, fields=(), widget=AddressWidget(), *args, **kwargs) -> None:
|
|
37
|
-
if not fields:
|
|
38
|
-
fields = (
|
|
39
|
-
forms.CharField(label="Street", max_length=128),
|
|
40
|
-
forms.CharField(label="City", max_length=128),
|
|
41
|
-
forms.CharField(label="State", max_length=64),
|
|
42
|
-
forms.CharField(label="Zip #", min_length=5, max_length=10),
|
|
43
|
-
forms.CharField(label="Country", max_length=2),
|
|
44
|
-
)
|
|
45
|
-
super().__init__(fields=fields, widget=widget, *args, **kwargs)
|
|
46
|
-
|
|
47
|
-
def compress(self, data_list: Sequence[str]) -> apicontractsv1.customerAddressType:
|
|
48
|
-
"""Compresses ``data_list`` into a :py:obj:`~authorizenet.apicontractsv1.customerAddressType`."""
|
|
49
|
-
return apicontractsv1.customerAddressType(
|
|
50
|
-
**{
|
|
51
|
-
"address": data_list[0],
|
|
52
|
-
"city": data_list[1],
|
|
53
|
-
"state": data_list[2],
|
|
54
|
-
"zip": data_list[3],
|
|
55
|
-
"country": data_list[4],
|
|
56
|
-
}
|
|
57
|
-
)
|
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from django.conf import settings
|
|
2
|
-
from django.core.exceptions import ImproperlyConfigured
|
|
3
|
-
from django.forms.renderers import TemplatesSetting
|
|
4
|
-
|
|
5
|
-
if settings.configured and not hasattr(settings, "DEFAULT_FIELD_CLASS"):
|
|
6
|
-
raise ImproperlyConfigured("'DEFAULT_FIELD_CLASS' setting is required.")
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TerminusgpsFormRenderer(TemplatesSetting):
|
|
10
|
-
field_template_name = "terminusgps/field.html"
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from authorizenet import apicontractsv1
|
|
2
|
-
from django import forms
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class CaptchaWidget(forms.widgets.CheckboxInput):
|
|
6
|
-
def get_context(self, name, value, attrs):
|
|
7
|
-
context = super().get_context(name, value, attrs)
|
|
8
|
-
print(f"{context = }")
|
|
9
|
-
return context
|
|
10
|
-
|
|
11
|
-
def check_test(self, value):
|
|
12
|
-
return bool(value)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CreditCardWidget(forms.widgets.MultiWidget):
|
|
16
|
-
def __init__(self, widgets=(), attrs: dict | None = None) -> None:
|
|
17
|
-
if not widgets:
|
|
18
|
-
widgets = [
|
|
19
|
-
forms.TextInput(attrs=attrs),
|
|
20
|
-
forms.TextInput(attrs=attrs),
|
|
21
|
-
forms.TextInput(attrs=attrs),
|
|
22
|
-
forms.TextInput(attrs=attrs),
|
|
23
|
-
]
|
|
24
|
-
super().__init__(widgets=widgets, attrs=attrs)
|
|
25
|
-
|
|
26
|
-
def decompress(
|
|
27
|
-
self, value: apicontractsv1.creditCardType | None
|
|
28
|
-
) -> list[str | None]:
|
|
29
|
-
"""Decompresses a :py:attr:`~authorizenet.apicontractsv1.creditCardType` into a list of strings."""
|
|
30
|
-
if value is None:
|
|
31
|
-
return [None, None, None, None]
|
|
32
|
-
|
|
33
|
-
expiry_parts = value.expirationDate.split("-")
|
|
34
|
-
return [value.cardNumber, expiry_parts[0], expiry_parts[1], value.cardCode]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class AddressWidget(forms.widgets.MultiWidget):
|
|
38
|
-
def __init__(self, widgets=(), attrs: dict | None = None) -> None:
|
|
39
|
-
if not widgets:
|
|
40
|
-
widgets = [
|
|
41
|
-
forms.TextInput(attrs=attrs),
|
|
42
|
-
forms.TextInput(attrs=attrs),
|
|
43
|
-
forms.TextInput(attrs=attrs),
|
|
44
|
-
forms.TextInput(attrs=attrs),
|
|
45
|
-
forms.TextInput(attrs=attrs),
|
|
46
|
-
]
|
|
47
|
-
super().__init__(widgets=widgets, attrs=attrs)
|
|
48
|
-
|
|
49
|
-
def decompress(
|
|
50
|
-
self, value: apicontractsv1.customerAddressType | None
|
|
51
|
-
) -> list[str | None]:
|
|
52
|
-
"""Decompresses a :py:attr:`~authorizenet.apicontractsv1.customerAddressType` into a list of strings."""
|
|
53
|
-
if value is None:
|
|
54
|
-
return [None, None, None, None, None]
|
|
55
|
-
|
|
56
|
-
return [value.address, value.city, value.state, value.country, value.zip]
|
terminusgps/django/utils.py
DELETED
terminusgps/django/validators.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
from django.core.exceptions import ValidationError
|
|
2
|
-
from django.utils.translation import gettext_lazy as _
|
|
3
|
-
|
|
4
|
-
VALID_COUNTRY_CODES = ("+1", "+52")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def validate_e164_phone_number(value: str) -> None:
|
|
8
|
-
"""Raises :py:exc:`~django.core.exceptions.ValidationError` if the value is not a valid `E.164 <https://en.wikipedia.org/wiki/E.164>`_ formatted phone number."""
|
|
9
|
-
if not value:
|
|
10
|
-
raise ValidationError(
|
|
11
|
-
_("This field is required, got '%(value)s'"),
|
|
12
|
-
code="invalid",
|
|
13
|
-
params={"value": value},
|
|
14
|
-
)
|
|
15
|
-
if not value.startswith("+"):
|
|
16
|
-
raise ValidationError(
|
|
17
|
-
_("E.164 phone number must begin with a '+', got '%(char)s'."),
|
|
18
|
-
code="invalid",
|
|
19
|
-
params={"char": value[0]},
|
|
20
|
-
)
|
|
21
|
-
if " " in value:
|
|
22
|
-
raise ValidationError(
|
|
23
|
-
_("E.164 phone number cannot contain spaces, got '%(value)s'."),
|
|
24
|
-
code="invalid",
|
|
25
|
-
params={"value": value},
|
|
26
|
-
)
|
|
27
|
-
if "-" in value:
|
|
28
|
-
raise ValidationError(
|
|
29
|
-
_("E.164 phone number cannot contain hyphens, got '%(value)s'."),
|
|
30
|
-
code="invalid",
|
|
31
|
-
params={"value": value},
|
|
32
|
-
)
|
|
33
|
-
if len(value) < 12:
|
|
34
|
-
raise ValidationError(
|
|
35
|
-
_(
|
|
36
|
-
"E.164 phone number cannot be less than 12 characters in length, got %(len)s."
|
|
37
|
-
),
|
|
38
|
-
code="invalid",
|
|
39
|
-
params={"len": len(value)},
|
|
40
|
-
)
|
|
41
|
-
if len(value) > 15:
|
|
42
|
-
raise ValidationError(
|
|
43
|
-
_(
|
|
44
|
-
"E.164 phone number cannot be greater than 15 characters in length, got %(len)s."
|
|
45
|
-
),
|
|
46
|
-
code="invalid",
|
|
47
|
-
params={"len": len(value)},
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
country_code = value[:-10]
|
|
51
|
-
area_code = value[-10:-7]
|
|
52
|
-
subscriber_number = value[-7:]
|
|
53
|
-
|
|
54
|
-
if len(country_code) < 2 or len(country_code) > 5:
|
|
55
|
-
raise ValidationError(
|
|
56
|
-
_(
|
|
57
|
-
"E.164 phone number country code must be between 2 and 5 characters in length, got %(len)s."
|
|
58
|
-
),
|
|
59
|
-
code="invalid",
|
|
60
|
-
params={"len": len(country_code)},
|
|
61
|
-
)
|
|
62
|
-
if country_code not in VALID_COUNTRY_CODES:
|
|
63
|
-
raise ValidationError(
|
|
64
|
-
_(
|
|
65
|
-
"E.164 phone number cannot contain an invalid country code, got '%(country_code)s'."
|
|
66
|
-
),
|
|
67
|
-
code="invalid",
|
|
68
|
-
params={"country_code": country_code},
|
|
69
|
-
)
|
|
70
|
-
if not len(area_code) == 3:
|
|
71
|
-
raise ValidationError(
|
|
72
|
-
_(
|
|
73
|
-
"E.164 phone number must contain a 3-digit area code, got '%(area_code)s'."
|
|
74
|
-
),
|
|
75
|
-
code="invalid",
|
|
76
|
-
params={"area_code": area_code},
|
|
77
|
-
)
|
|
78
|
-
if not area_code.isdigit():
|
|
79
|
-
raise ValidationError(
|
|
80
|
-
_("E.164 phone number must have a valid area code, got '%(area_code)s'."),
|
|
81
|
-
code="invalid",
|
|
82
|
-
params={"area_code": area_code},
|
|
83
|
-
)
|
|
84
|
-
if not len(subscriber_number) == 7:
|
|
85
|
-
raise ValidationError(
|
|
86
|
-
_(
|
|
87
|
-
"E.164 phone number must contain a 7-digit subscriber number, got '%(subscriber_number)s'."
|
|
88
|
-
),
|
|
89
|
-
code="invalid",
|
|
90
|
-
params={"subscriber_number": subscriber_number},
|
|
91
|
-
)
|
|
92
|
-
if not subscriber_number.isdigit():
|
|
93
|
-
raise ValidationError(
|
|
94
|
-
_(
|
|
95
|
-
"E.164 phone number must have a valid subscriber number, got '%(subscriber_number)s'."
|
|
96
|
-
),
|
|
97
|
-
code="invalid",
|
|
98
|
-
params={"subscriber_number": subscriber_number},
|
|
99
|
-
)
|
|
File without changes
|
{python_terminusgps-43.2.0.dist-info → python_terminusgps-44.0.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|
|
File without changes
|