python-terminusgps 22.0.2__py3-none-any.whl → 24.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.
- {python_terminusgps-22.0.2.dist-info → python_terminusgps-24.0.0.dist-info}/METADATA +1 -4
- {python_terminusgps-22.0.2.dist-info → python_terminusgps-24.0.0.dist-info}/RECORD +18 -17
- terminusgps/authorizenet/__init__.py +9 -0
- terminusgps/authorizenet/auth.py +21 -1
- terminusgps/authorizenet/errors.py +31 -0
- terminusgps/authorizenet/profiles/addresses.py +90 -40
- terminusgps/authorizenet/profiles/base.py +17 -73
- terminusgps/authorizenet/profiles/customers.py +141 -45
- terminusgps/authorizenet/profiles/payments.py +174 -56
- terminusgps/authorizenet/subscriptions/subscriptions.py +39 -0
- terminusgps/authorizenet/utils.py +54 -0
- terminusgps/aws/secrets.py +2 -1
- terminusgps/settings.py +2 -0
- terminusgps/wialon/session.py +2 -23
- terminusgps/wialon/utils.py +35 -26
- terminusgps/authorizenet/subscriptions.py +0 -61
- terminusgps/opencv/barcodes.py +0 -31
- {python_terminusgps-22.0.2.dist-info → python_terminusgps-24.0.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-22.0.2.dist-info → python_terminusgps-24.0.0.dist-info}/licenses/COPYING +0 -0
- /terminusgps/{opencv → authorizenet/subscriptions}/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version:
|
|
3
|
+
Version: 24.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://app.terminusgps.com/docs/apps/python-terminusgps/index.html
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -17,8 +17,5 @@ Requires-Dist: authorizenet>=1.1.5
|
|
|
17
17
|
Requires-Dist: boto3>=1.34.144
|
|
18
18
|
Requires-Dist: django>=5.1.5
|
|
19
19
|
Requires-Dist: matplotlib>=3.10.1
|
|
20
|
-
Requires-Dist: opencv-python>=4.11.0.86
|
|
21
|
-
Requires-Dist: pyqt6>=6.8.1
|
|
22
20
|
Requires-Dist: python-wialon>=1.2.4
|
|
23
|
-
Requires-Dist: pyzbar>=0.1.9
|
|
24
21
|
Requires-Dist: twilio>=9.4.5
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
terminusgps/settings.py,sha256=
|
|
3
|
-
terminusgps/authorizenet/__init__.py,sha256=
|
|
4
|
-
terminusgps/authorizenet/auth.py,sha256=
|
|
5
|
-
terminusgps/authorizenet/
|
|
2
|
+
terminusgps/settings.py,sha256=UBj2tvuBzQDEz05PeFqHG4_ise3Bl6Iu7pxcrtjNaYE,568
|
|
3
|
+
terminusgps/authorizenet/__init__.py,sha256=LiGLlWNNiqS7RSOP4Apabx-b9EBYyNbxRY_a0mvJoaE,466
|
|
4
|
+
terminusgps/authorizenet/auth.py,sha256=ICxPPzoUc64VbsIIemEWKrn8xjHGwbNdo2VbtaFCFss,1107
|
|
5
|
+
terminusgps/authorizenet/errors.py,sha256=HG5NwVxQCtOYidVl30y49PC0Ovw5VYdsy9wTgUFMw9M,949
|
|
6
|
+
terminusgps/authorizenet/utils.py,sha256=5aczO2EcMX2bi-kRg8_fnzLzE7qMA9K1qBxAo2AJz1c,2021
|
|
6
7
|
terminusgps/authorizenet/profiles/__init__.py,sha256=QKjMKcXpCSCEhv6LBCz0yGP8t0VxAyKyYRS4_HLYnxQ,114
|
|
7
|
-
terminusgps/authorizenet/profiles/addresses.py,sha256=
|
|
8
|
-
terminusgps/authorizenet/profiles/base.py,sha256=
|
|
9
|
-
terminusgps/authorizenet/profiles/customers.py,sha256=
|
|
10
|
-
terminusgps/authorizenet/profiles/payments.py,sha256=
|
|
8
|
+
terminusgps/authorizenet/profiles/addresses.py,sha256=uowUkrr4fa4g7pjgNDrjW0es5t_gH9B8VHI74PbTWFc,6303
|
|
9
|
+
terminusgps/authorizenet/profiles/base.py,sha256=TOUHr22QRQBLErdysOkfcpJBusTjrUTqOmWEyNvMacA,2240
|
|
10
|
+
terminusgps/authorizenet/profiles/customers.py,sha256=xe7LNsqSB_oRCY-teojDTt0O6a5yVf0dyuu86ftc4hA,8377
|
|
11
|
+
terminusgps/authorizenet/profiles/payments.py,sha256=O_oZGUwO8XTApzr0itu-1XQYnWFR4gDpNCusWNzBh7A,11152
|
|
12
|
+
terminusgps/authorizenet/subscriptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
terminusgps/authorizenet/subscriptions/subscriptions.py,sha256=JQHo2FxQyRPJp1jlbD2mIt9RKEJZbADZcfozNTKWbz0,1514
|
|
11
14
|
terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
terminusgps/aws/secrets.py,sha256=
|
|
15
|
+
terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
|
|
13
16
|
terminusgps/aws/ses.py,sha256=sDca2GjMaZvUt3kUPtGCpcqHiOkij9lMV1ogZofgYUU,2372
|
|
14
|
-
terminusgps/opencv/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
terminusgps/opencv/barcodes.py,sha256=NmdpUnixlGJI-6shbKGcb6-M_IZvgSZJRDVSsI7pcFg,669
|
|
16
17
|
terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
|
|
17
18
|
terminusgps/twilio/caller.py,sha256=nHCIwUulo-C_v2orsp6OY0nuJA6YetSkxpMTwrRQ-uA,1831
|
|
18
19
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
20
|
terminusgps/wialon/constants.py,sha256=n1ux68oWYWnzeZdN811Iw_Lk78KBM0YMJMoonn67uZY,1723
|
|
20
21
|
terminusgps/wialon/flags.py,sha256=_NIL3mrEGhvI5YISVjimjYtUatdgOqhZPJX368MtKSU,13959
|
|
21
22
|
terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
|
|
22
|
-
terminusgps/wialon/session.py,sha256=
|
|
23
|
-
terminusgps/wialon/utils.py,sha256=
|
|
23
|
+
terminusgps/wialon/session.py,sha256=t3d7trBQRxnXFnex73alSSD5n2LDTZQ9VAtzUKIERto,9670
|
|
24
|
+
terminusgps/wialon/utils.py,sha256=Y7fo9a81w84b3N39h1AmVLS-AnC3aRT5R137hIsqCHU,6723
|
|
24
25
|
terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
|
|
25
26
|
terminusgps/wialon/items/base.py,sha256=EAtzlnCvB7WTu3iX1bV1-S9TvwXc-Eez7e0X4TMiK9U,6943
|
|
26
27
|
terminusgps/wialon/items/resource.py,sha256=qmQKEakJa9LH5YkI9-iBDA0hsotc5ctcwdb7kZuXdfQ,14549
|
|
@@ -29,7 +30,7 @@ terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFne
|
|
|
29
30
|
terminusgps/wialon/items/unit.py,sha256=-jQL5Alvz77FZWteYNM9VNX15jtCufI-DWRRj3hRsgA,8539
|
|
30
31
|
terminusgps/wialon/items/unit_group.py,sha256=vGVJMBY1BrKK0tP-C1DCIz4Bh6P-HKRnKY1g8g95UIs,5031
|
|
31
32
|
terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
|
|
32
|
-
python_terminusgps-
|
|
33
|
-
python_terminusgps-
|
|
34
|
-
python_terminusgps-
|
|
35
|
-
python_terminusgps-
|
|
33
|
+
python_terminusgps-24.0.0.dist-info/METADATA,sha256=QU-Do0pVNWwhy5D08Y5-n2nKz_mknj6sQMRHgHWpf5s,946
|
|
34
|
+
python_terminusgps-24.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
35
|
+
python_terminusgps-24.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
36
|
+
python_terminusgps-24.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from django.conf import settings
|
|
2
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
3
|
+
|
|
4
|
+
if not hasattr(settings, "DEBUG"):
|
|
5
|
+
raise ImproperlyConfigured("'DEBUG' setting is required.")
|
|
6
|
+
if not hasattr(settings, "MERCHANT_AUTH_LOGIN_ID"):
|
|
7
|
+
raise ImproperlyConfigured("'MERCHANT_AUTH_LOGIN_ID' setting is required.")
|
|
8
|
+
if not hasattr(settings, "MERCHANT_AUTH_TRANSACTION_KEY"):
|
|
9
|
+
raise ImproperlyConfigured("'MERCHANT_AUTH_TRANSACTION_KEY' setting is required.")
|
terminusgps/authorizenet/auth.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
2
|
from authorizenet.constants import constants
|
|
3
|
-
|
|
4
3
|
from django.conf import settings
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
def get_merchant_auth() -> merchantAuthenticationType:
|
|
7
|
+
"""
|
|
8
|
+
Returns the merchant authentication information for Authorizenet API requests.
|
|
9
|
+
|
|
10
|
+
:returns: A merchant authentication object.
|
|
11
|
+
:rtype: :py:obj:`~authorizenet.apicontractsv1.merchantAuthenticationType`
|
|
12
|
+
|
|
13
|
+
"""
|
|
8
14
|
return merchantAuthenticationType(
|
|
9
15
|
name=str(settings.MERCHANT_AUTH_LOGIN_ID),
|
|
10
16
|
transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
|
|
@@ -12,8 +18,22 @@ def get_merchant_auth() -> merchantAuthenticationType:
|
|
|
12
18
|
|
|
13
19
|
|
|
14
20
|
def get_environment() -> str:
|
|
21
|
+
"""
|
|
22
|
+
Returns the environment for Authorizenet API requests.
|
|
23
|
+
|
|
24
|
+
:returns: An Authorizenet API environment string.
|
|
25
|
+
:rtype: :py:obj:`str`
|
|
26
|
+
|
|
27
|
+
"""
|
|
15
28
|
return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
|
|
16
29
|
|
|
17
30
|
|
|
18
31
|
def get_validation_mode() -> str:
|
|
32
|
+
"""
|
|
33
|
+
Returns the validation mode for Authorizenet API requests.
|
|
34
|
+
|
|
35
|
+
:returns: An Authorizenet API validation string.
|
|
36
|
+
:rtype: :py:obj:`str`
|
|
37
|
+
|
|
38
|
+
"""
|
|
19
39
|
return "testMode" if settings.DEBUG else "liveMode"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class ControllerExecutionError(Exception):
|
|
2
|
+
"""Raised when an Authorizenet API controller fails to execute."""
|
|
3
|
+
|
|
4
|
+
def __init__(self, message: str, code: str, *args, **kwargs) -> None:
|
|
5
|
+
"""
|
|
6
|
+
Sets :py:attr:`message` and :py:attr`code` for the exception.
|
|
7
|
+
|
|
8
|
+
:param message: An Authorizenet API error message.
|
|
9
|
+
:type message: :py:obj:`str`
|
|
10
|
+
:param code: An Authorizenet API error code.
|
|
11
|
+
:type code: :py:obj:`str`
|
|
12
|
+
:returns: Nothing.
|
|
13
|
+
:rtype: :py:obj:`None`
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
super().__init__(message, *args, **kwargs)
|
|
17
|
+
self._message = message
|
|
18
|
+
self._code = code
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
return f"{self.code}: {self.message}"
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def message(self) -> str:
|
|
25
|
+
"""An Authorizenet API error message."""
|
|
26
|
+
return self._message
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def code(self) -> str:
|
|
30
|
+
"""An Authorizenet API error code."""
|
|
31
|
+
return self._code
|
|
@@ -1,47 +1,64 @@
|
|
|
1
1
|
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
-
from authorizenet.apicontractsv1 import customerAddressType
|
|
3
2
|
|
|
4
|
-
from
|
|
3
|
+
from .base import AuthorizenetSubProfileBase
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
class AddressProfile(AuthorizenetSubProfileBase):
|
|
8
|
-
|
|
7
|
+
"""An Authorizenet customer address profile."""
|
|
8
|
+
|
|
9
|
+
def create(self, address: apicontractsv1.customerAddressType) -> int:
|
|
9
10
|
"""
|
|
10
|
-
Creates an
|
|
11
|
+
Creates an Authorizenet address profile.
|
|
11
12
|
|
|
12
|
-
:param
|
|
13
|
-
:type
|
|
14
|
-
:raises
|
|
15
|
-
:raises
|
|
16
|
-
:returns:
|
|
13
|
+
:param address: A customer address.
|
|
14
|
+
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
15
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
16
|
+
:raises ValueError: If the Authorizenet API response was not retrieved.
|
|
17
|
+
:returns: A new address profile id.
|
|
17
18
|
:rtype: :py:obj:`int`
|
|
18
19
|
|
|
19
20
|
"""
|
|
20
|
-
|
|
21
|
+
response = self._authorizenet_create_shipping_address(address)
|
|
22
|
+
if response is None:
|
|
23
|
+
raise ValueError("Failed to retrieve Authorizenet API response.")
|
|
24
|
+
return int(response.customerAddressId)
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
def update(self, address: apicontractsv1.customerAddressType) -> dict | None:
|
|
27
|
+
"""
|
|
28
|
+
Updates the Authorizenet address profile.
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
:param address: A customer shipping address.
|
|
31
|
+
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
32
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
33
|
+
:returns: An Authorizenet API response, if any.
|
|
34
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
return
|
|
36
|
+
"""
|
|
37
|
+
return self._authorizenet_update_shipping_address(address)
|
|
38
|
+
|
|
39
|
+
def delete(self) -> dict | None:
|
|
40
|
+
"""
|
|
41
|
+
Deletes the Authorizenet address profile.
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
44
|
+
:returns: An Authorizenet API response, if any.
|
|
45
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
"""Deletes the Authorize.NET payment profile."""
|
|
47
|
+
"""
|
|
39
48
|
return self._authorizenet_delete_shipping_address()
|
|
40
49
|
|
|
41
|
-
def
|
|
42
|
-
|
|
50
|
+
def _authorizenet_get_shipping_address(self) -> dict | None:
|
|
51
|
+
"""
|
|
52
|
+
Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerShippingAddressRequest` using the Authorizenet API.
|
|
53
|
+
|
|
54
|
+
`getCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-shipping-address>`_
|
|
55
|
+
|
|
56
|
+
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
57
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
58
|
+
:returns: An Authorizenet API response, if any.
|
|
59
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
43
60
|
|
|
44
|
-
|
|
61
|
+
"""
|
|
45
62
|
assert self.id, "'id' was not set."
|
|
46
63
|
|
|
47
64
|
request = apicontractsv1.getCustomerShippingAddressRequest(
|
|
@@ -50,35 +67,69 @@ class AddressProfile(AuthorizenetSubProfileBase):
|
|
|
50
67
|
customerAddressId=self.id,
|
|
51
68
|
)
|
|
52
69
|
controller = apicontrollers.getCustomerShippingAddressController(request)
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
return self.execute_controller(controller)
|
|
71
|
+
|
|
72
|
+
def _authorizenet_create_shipping_address(
|
|
73
|
+
self, address: apicontractsv1.customerAddressType
|
|
74
|
+
) -> dict | None:
|
|
75
|
+
"""
|
|
76
|
+
Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerShippingAddressRequest` using the Authorizenet API.
|
|
55
77
|
|
|
56
|
-
|
|
78
|
+
`createCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-shipping-address>`_
|
|
79
|
+
|
|
80
|
+
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
81
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
82
|
+
:returns: An Authorizenet API response, if any.
|
|
83
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
84
|
+
|
|
85
|
+
"""
|
|
57
86
|
request = apicontractsv1.createCustomerShippingAddressRequest(
|
|
58
87
|
merchantAuthentication=self.merchantAuthentication,
|
|
59
88
|
customerProfileId=self.customerProfileId,
|
|
60
|
-
address=
|
|
89
|
+
address=address,
|
|
61
90
|
defaultShippingAddress=self.default,
|
|
62
91
|
)
|
|
63
92
|
controller = apicontrollers.createCustomerShippingAddressController(request)
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
return self.execute_controller(controller)
|
|
94
|
+
|
|
95
|
+
def _authorizenet_update_shipping_address(
|
|
96
|
+
self, address: apicontractsv1.customerAddressType
|
|
97
|
+
) -> dict | None:
|
|
98
|
+
"""
|
|
99
|
+
Executes a :py:obj:`~authorizenet.apicontractsv1.updateCustomerShippingAddressRequest` using the Authorizenet API.
|
|
100
|
+
|
|
101
|
+
`updateCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-shipping-address>`_
|
|
102
|
+
|
|
103
|
+
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
104
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
105
|
+
:returns: An Authorizenet API response, if any.
|
|
106
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
66
107
|
|
|
67
|
-
|
|
108
|
+
"""
|
|
68
109
|
assert self.id, "'id' was not set."
|
|
69
|
-
addr.customerAddressId = self.id
|
|
70
110
|
|
|
111
|
+
address.customerAddressId = self.id
|
|
71
112
|
request = apicontractsv1.updateCustomerShippingAddressRequest(
|
|
72
113
|
merchantAuthentication=self.merchantAuthentication,
|
|
73
114
|
customerProfileId=self.customerProfileId,
|
|
74
|
-
address=
|
|
115
|
+
address=address,
|
|
75
116
|
default=self.default,
|
|
76
117
|
)
|
|
77
118
|
controller = apicontrollers.updateCustomerShippingAddressController(request)
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
return self.execute_controller(controller)
|
|
120
|
+
|
|
121
|
+
def _authorizenet_delete_shipping_address(self) -> dict | None:
|
|
122
|
+
"""
|
|
123
|
+
Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerShippingAddressRequest` using the Authorizenet API.
|
|
80
124
|
|
|
81
|
-
|
|
125
|
+
`deleteCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-shipping-address>`_
|
|
126
|
+
|
|
127
|
+
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
128
|
+
:raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
129
|
+
:returns: An Authorizenet API response, if any.
|
|
130
|
+
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
131
|
+
|
|
132
|
+
"""
|
|
82
133
|
assert self.id, "'id' was not set."
|
|
83
134
|
|
|
84
135
|
request = apicontractsv1.deleteCustomerShippingAddressRequest(
|
|
@@ -87,5 +138,4 @@ class AddressProfile(AuthorizenetSubProfileBase):
|
|
|
87
138
|
customerAddressId=self.id,
|
|
88
139
|
)
|
|
89
140
|
controller = apicontrollers.deleteCustomerShippingAddressController(request)
|
|
90
|
-
|
|
91
|
-
return response
|
|
141
|
+
return self.execute_controller(controller)
|
|
@@ -1,81 +1,40 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
|
+
from typing import override
|
|
2
3
|
|
|
3
|
-
from authorizenet
|
|
4
|
-
from authorizenet.apicontrollersbase import APIOperationBase
|
|
4
|
+
from authorizenet import apicontractsv1
|
|
5
5
|
|
|
6
|
-
from ..auth import get_merchant_auth,
|
|
6
|
+
from ..auth import get_merchant_auth, get_validation_mode
|
|
7
|
+
from ..utils import ControllerExecutionMixin
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
class AuthorizenetProfileBase:
|
|
10
|
+
class AuthorizenetProfileBase(ControllerExecutionMixin):
|
|
10
11
|
def __init__(
|
|
11
|
-
self, merchant_id: int | str, id: int | str | None = None, **kwargs
|
|
12
|
+
self, merchant_id: int | str, id: int | str | None = None, *args, **kwargs
|
|
12
13
|
) -> None:
|
|
13
14
|
self._merchantCustomerId = merchant_id
|
|
14
|
-
self._id =
|
|
15
|
+
self._id = int(id) if id else self.create(*args, **kwargs)
|
|
15
16
|
|
|
17
|
+
@override
|
|
16
18
|
def __str__(self) -> str:
|
|
17
19
|
return f"#{self.id}"
|
|
18
20
|
|
|
19
|
-
def execute_controller(self, controller: APIOperationBase) -> dict:
|
|
20
|
-
"""
|
|
21
|
-
Executes an Authorize.NET controller and returns its response.
|
|
22
|
-
|
|
23
|
-
:param controller: An Authorize.NET API controller.
|
|
24
|
-
:raises ValueError: If the API call fails.
|
|
25
|
-
:returns: The Authorize.NET API response.
|
|
26
|
-
:rtype: :py:obj:`dict`
|
|
27
|
-
|
|
28
|
-
"""
|
|
29
|
-
controller.setenvironment(self.environment)
|
|
30
|
-
controller.execute()
|
|
31
|
-
response = controller.getresponse()
|
|
32
|
-
|
|
33
|
-
if response.messages.resultCode != "Ok":
|
|
34
|
-
raise ValueError(response.messages.message[0]["text"].text)
|
|
35
|
-
return response
|
|
36
|
-
|
|
37
21
|
@property
|
|
38
22
|
def merchantCustomerId(self) -> str:
|
|
39
|
-
"""
|
|
40
|
-
An internally designated customer id.
|
|
41
|
-
|
|
42
|
-
:type: :py:obj:`str`
|
|
43
|
-
|
|
44
|
-
"""
|
|
23
|
+
"""An internally designated customer id."""
|
|
45
24
|
return str(self._merchantCustomerId)
|
|
46
25
|
|
|
47
26
|
@property
|
|
48
27
|
def id(self) -> str:
|
|
49
|
-
"""
|
|
50
|
-
An Authorizenet generated id.
|
|
51
|
-
|
|
52
|
-
:type: :py:obj:`str`
|
|
53
|
-
|
|
54
|
-
"""
|
|
28
|
+
"""An Authorizenet generated id."""
|
|
55
29
|
return str(self._id)
|
|
56
30
|
|
|
57
31
|
@property
|
|
58
|
-
def merchantAuthentication(self) -> merchantAuthenticationType:
|
|
59
|
-
"""
|
|
60
|
-
Merchant authentication for Authorizenet API calls.
|
|
61
|
-
|
|
62
|
-
:type: :py:obj:`~authorizenet.apicontractsv1.merchantAuthenticationType`
|
|
63
|
-
|
|
64
|
-
"""
|
|
32
|
+
def merchantAuthentication(self) -> apicontractsv1.merchantAuthenticationType:
|
|
33
|
+
"""Merchant authentication for Authorizenet API calls."""
|
|
65
34
|
return get_merchant_auth()
|
|
66
35
|
|
|
67
|
-
@property
|
|
68
|
-
def environment(self) -> str:
|
|
69
|
-
"""
|
|
70
|
-
Environment for Authorizenet API calls to execute within.
|
|
71
|
-
|
|
72
|
-
:type: :py:obj:`str`
|
|
73
|
-
|
|
74
|
-
"""
|
|
75
|
-
return get_environment()
|
|
76
|
-
|
|
77
36
|
@abstractmethod
|
|
78
|
-
def create(self, **kwargs) -> int:
|
|
37
|
+
def create(self, *args, **kwargs) -> int:
|
|
79
38
|
raise NotImplementedError("Subclasses must implement this method.")
|
|
80
39
|
|
|
81
40
|
@abstractmethod
|
|
@@ -93,34 +52,19 @@ class AuthorizenetSubProfileBase(AuthorizenetProfileBase):
|
|
|
93
52
|
) -> None:
|
|
94
53
|
self._customerProfileId = customer_profile_id
|
|
95
54
|
self._default = default
|
|
96
|
-
|
|
55
|
+
super().__init__(*args, **kwargs)
|
|
97
56
|
|
|
98
57
|
@property
|
|
99
58
|
def validationMode(self) -> str:
|
|
100
|
-
"""
|
|
101
|
-
The validation mode for Authorizenet API calls.
|
|
102
|
-
|
|
103
|
-
:type: :py:obj:`str`
|
|
104
|
-
|
|
105
|
-
"""
|
|
59
|
+
"""The validation mode for Authorizenet API calls."""
|
|
106
60
|
return get_validation_mode()
|
|
107
61
|
|
|
108
62
|
@property
|
|
109
63
|
def default(self) -> str:
|
|
110
|
-
"""
|
|
111
|
-
Whether or not the sub profile is set as default in Authorizenet.
|
|
112
|
-
|
|
113
|
-
:type: :py:obj:`str`
|
|
114
|
-
|
|
115
|
-
"""
|
|
64
|
+
"""Whether or not the sub profile is set as default in Authorizenet."""
|
|
116
65
|
return str(self._default).lower()
|
|
117
66
|
|
|
118
67
|
@property
|
|
119
68
|
def customerProfileId(self) -> str:
|
|
120
|
-
"""
|
|
121
|
-
An Authorizenet generated customer profile id.
|
|
122
|
-
|
|
123
|
-
:py:obj:`str`
|
|
124
|
-
|
|
125
|
-
"""
|
|
69
|
+
"""An Authorizenet generated customer profile id."""
|
|
126
70
|
return str(self._customerProfileId)
|