python-terminusgps 37.5.2__py3-none-any.whl → 37.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_terminusgps-37.5.2.dist-info → python_terminusgps-37.6.1.dist-info}/METADATA +1 -1
- {python_terminusgps-37.5.2.dist-info → python_terminusgps-37.6.1.dist-info}/RECORD +7 -16
- terminusgps/authorizenet/auth.py +2 -3
- terminusgps/authorizenet/profiles/customers.py +1 -1
- terminusgps/django/settings.py +4 -0
- terminusgps/authorizenet/items/__init__.py +0 -0
- terminusgps/authorizenet/items/address_profiles.py +0 -126
- terminusgps/authorizenet/items/base.py +0 -68
- terminusgps/authorizenet/items/customer_profiles.py +0 -227
- terminusgps/authorizenet/items/payment_profiles.py +0 -253
- terminusgps/wialon/tests/__init__.py +0 -0
- terminusgps/wialon/tests/test_items.py +0 -0
- terminusgps/wialon/tests/test_session.py +0 -42
- terminusgps/wialon/tests/test_utils.py +0 -41
- {python_terminusgps-37.5.2.dist-info → python_terminusgps-37.6.1.dist-info}/WHEEL +0 -0
- {python_terminusgps-37.5.2.dist-info → python_terminusgps-37.6.1.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 37.
|
|
3
|
+
Version: 37.6.1
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://docs.terminusgps.com
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
terminusgps/authorizenet/auth.py,sha256=
|
|
3
|
+
terminusgps/authorizenet/auth.py,sha256=CKT_pfDEL-53GceOEaFtIU6IBXVuVd8MVHikpPAX0xY,1184
|
|
4
4
|
terminusgps/authorizenet/constants.py,sha256=uXkYVmQPrnYBDfGahVEmzwTny21A8jGcrH7qfSdLhvc,512
|
|
5
5
|
terminusgps/authorizenet/controllers.py,sha256=rMuBwSoKJjte7wVuB1ewaqnzfuDXxwus-d5mkqbfnGE,2193
|
|
6
6
|
terminusgps/authorizenet/utils.py,sha256=lkXjKfegFFN8TgtjlyI03416X6oqFIciFnWgSEuIgSM,6800
|
|
7
|
-
terminusgps/authorizenet/items/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
terminusgps/authorizenet/items/address_profiles.py,sha256=oiFw2T3TmyhLn8Vw-GWFrAeBbyOEG_dV8LLGr3oH7aI,5669
|
|
9
|
-
terminusgps/authorizenet/items/base.py,sha256=fcO0RRrOXytlSbBDLLFajfdkxYtqmniJ5FWV4z0UkOk,2004
|
|
10
|
-
terminusgps/authorizenet/items/customer_profiles.py,sha256=53cqXooXszTqMv2PuifDsDknuDxGtA73jZkquWZl0zs,9262
|
|
11
|
-
terminusgps/authorizenet/items/payment_profiles.py,sha256=kYvuq1xCmeIUmmXgbOapbA01roQ4k0zOLafcBtG-eM0,10830
|
|
12
7
|
terminusgps/authorizenet/profiles/__init__.py,sha256=IG4XCEEYtHKqXOatlZlob6J3ukAgF7cFR-RXxOSMS1c,161
|
|
13
8
|
terminusgps/authorizenet/profiles/addresses.py,sha256=MwJQzq3IrjYCLJzOglLfJIcMvH5osDu1MzN6_XGO0Tc,6376
|
|
14
9
|
terminusgps/authorizenet/profiles/base.py,sha256=Pu1NGrvC5Ox2W1oZuVcPqUw3aUoSK191Evexw1U6_3k,3940
|
|
15
|
-
terminusgps/authorizenet/profiles/customers.py,sha256=
|
|
10
|
+
terminusgps/authorizenet/profiles/customers.py,sha256=cFGFoVODso0ylW58bduvy2IEkl2vNtCJRdhzU4KqMjA,12182
|
|
16
11
|
terminusgps/authorizenet/profiles/payments.py,sha256=57qtiPKGS6loPMccLXQJoHV3fGyNNQ0AXcR9ukDNrXE,11313
|
|
17
12
|
terminusgps/authorizenet/profiles/subscriptions.py,sha256=TKTGeYCNSiDMAQGwMnFOL7E_SKt3GsiwgtIfGJE3yHc,10256
|
|
18
13
|
terminusgps/authorizenet/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -27,7 +22,7 @@ terminusgps/aws/tests/test_notifications.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
|
|
|
27
22
|
terminusgps/aws/tests/test_secrets.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
23
|
terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
24
|
terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
|
|
30
|
-
terminusgps/django/settings.py,sha256=
|
|
25
|
+
terminusgps/django/settings.py,sha256=OxfagnSI6Ra8bte0viGYk9kr5KHGs8dvP2iN1ykjC7U,896
|
|
31
26
|
terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
|
|
32
27
|
terminusgps/django/validators.py,sha256=Gx-bpWkfI0fM4WXVRUpoC2ihPqs7agjdHAFO6gralCs,3341
|
|
33
28
|
terminusgps/django/forms/__init__.py,sha256=hh8Z9AC_u2m2bu3h6sdmPyndfQneCEVovENPHmoTDC0,21
|
|
@@ -55,11 +50,7 @@ terminusgps/wialon/items/route.py,sha256=2dEUK9o8nwutPE03W-5GUcZrjGvbwLoExVnFV9L
|
|
|
55
50
|
terminusgps/wialon/items/unit.py,sha256=P828NaWkTQncNre3n4h7AedeSxUXPKSxQFpBiliZCBk,12133
|
|
56
51
|
terminusgps/wialon/items/unit_group.py,sha256=HhYMZ9b7UATXeEgHkXN9r5-M_w82fabjDYADCUwBtxQ,4442
|
|
57
52
|
terminusgps/wialon/items/user.py,sha256=pR6OTrm6f7Zo0J8eLvKtWVsdhGi430OxMsMMthGh8YE,5382
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
python_terminusgps-37.5.2.dist-info/METADATA,sha256=rs7iVZ9GR7e21fCHspgV86OVQ2cKErylAeGzzsFMk9c,1329
|
|
63
|
-
python_terminusgps-37.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
64
|
-
python_terminusgps-37.5.2.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
65
|
-
python_terminusgps-37.5.2.dist-info/RECORD,,
|
|
53
|
+
python_terminusgps-37.6.1.dist-info/METADATA,sha256=F6KjSzH5g86T7nsdcj0o0chogKv3L7pkzxbKtB62iFE,1329
|
|
54
|
+
python_terminusgps-37.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
55
|
+
python_terminusgps-37.6.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
56
|
+
python_terminusgps-37.6.1.dist-info/RECORD,,
|
terminusgps/authorizenet/auth.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
|
-
from authorizenet.constants import constants
|
|
3
2
|
from django.conf import settings
|
|
4
3
|
|
|
5
4
|
from terminusgps.django import settings as default_settings
|
|
@@ -30,7 +29,7 @@ def get_environment() -> str:
|
|
|
30
29
|
:rtype: :py:obj:`str`
|
|
31
30
|
|
|
32
31
|
"""
|
|
33
|
-
return
|
|
32
|
+
return settings.MERCHANT_AUTH_ENVIRONMENT
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
def get_validation_mode() -> str:
|
|
@@ -41,4 +40,4 @@ def get_validation_mode() -> str:
|
|
|
41
40
|
:rtype: :py:obj:`str`
|
|
42
41
|
|
|
43
42
|
"""
|
|
44
|
-
return
|
|
43
|
+
return settings.MERCHANT_AUTH_VALIDATION_MODE
|
|
@@ -190,7 +190,7 @@ class CustomerProfile(AuthorizenetProfileBase):
|
|
|
190
190
|
address_profiles = (
|
|
191
191
|
self._authorizenet_get_customer_profile()
|
|
192
192
|
.find(f"{ANET_XMLNS}profile")
|
|
193
|
-
.
|
|
193
|
+
.find(f"{ANET_XMLNS}shipToList")
|
|
194
194
|
)
|
|
195
195
|
return (
|
|
196
196
|
[
|
terminusgps/django/settings.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import pathlib
|
|
3
3
|
|
|
4
|
+
from authorizenet.constants import constants
|
|
5
|
+
|
|
4
6
|
BASE_DIR = pathlib.Path(__file__).resolve().parent
|
|
5
7
|
DEBUG = True
|
|
6
8
|
SECRET_KEY = "xem*6no%8d9%^qzt2f3x3ar-uq4_+7h9myc$t0!+4%bj5us6f)"
|
|
@@ -10,6 +12,8 @@ USE_TZ = False
|
|
|
10
12
|
CONNECT_SECRET = os.getenv("CONNECT_SECRET")
|
|
11
13
|
MERCHANT_AUTH_LOGIN_ID = os.getenv("MERCHANT_AUTH_LOGIN_ID")
|
|
12
14
|
MERCHANT_AUTH_TRANSACTION_KEY = os.getenv("MERCHANT_AUTH_TRANSACTION_KEY")
|
|
15
|
+
MERCHANT_AUTH_ENVIRONMENT = constants.SANDBOX
|
|
16
|
+
MERCHANT_AUTH_VALIDATION_MODE = "testMode"
|
|
13
17
|
TWILIO_FROM_NUMBER = os.getenv("TWILIO_FROM_NUMBER")
|
|
14
18
|
TWILIO_MESSAGING_SID = os.getenv("TWILIO_MESSAGING_SID")
|
|
15
19
|
TWILIO_SID = os.getenv("TWILIO_SID")
|
|
File without changes
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
|
|
3
|
-
from authorizenet import apicontractsv1, apicontrollers
|
|
4
|
-
|
|
5
|
-
from .base import AuthorizenetBase
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AuthorizenetAddressProfile(AuthorizenetBase):
|
|
9
|
-
"""An Authorizenet address profile."""
|
|
10
|
-
|
|
11
|
-
def __init__(self, customerProfileId: int | str, *args, **kwargs) -> None:
|
|
12
|
-
super().__init__(*args, **kwargs)
|
|
13
|
-
if isinstance(customerProfileId, str) and not customerProfileId.isdigit():
|
|
14
|
-
raise ValueError(
|
|
15
|
-
f"'customerProfileId' can only contain digits, got '{customerProfileId}'."
|
|
16
|
-
)
|
|
17
|
-
self.customerProfileId = customerProfileId
|
|
18
|
-
|
|
19
|
-
def _authorizenet_create_customer_shipping_address(
|
|
20
|
-
self, address: apicontractsv1.customerAddressType, default: bool = False
|
|
21
|
-
) -> dict[str, typing.Any] | None:
|
|
22
|
-
"""
|
|
23
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerShippingAddressRequest` using the Authorizenet API.
|
|
24
|
-
|
|
25
|
-
`createCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-shipping-address>`_
|
|
26
|
-
|
|
27
|
-
:param address: A customer address object.
|
|
28
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
29
|
-
:param default: Whether or not to set the address profile as default.
|
|
30
|
-
:type default: :py:obj:`bool`
|
|
31
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
32
|
-
:returns: An Authorizenet API response, if any.
|
|
33
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
34
|
-
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
request = apicontractsv1.createCustomerShippingAddressRequest()
|
|
38
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
39
|
-
request.customerProfileId = self.customerProfileId
|
|
40
|
-
request.address = address
|
|
41
|
-
request.defaultShippingAddress = str(default).lower()
|
|
42
|
-
|
|
43
|
-
return self.execute_controller(
|
|
44
|
-
apicontrollers.createCustomerShippingAddressController(request)
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
def _authorizenet_get_customer_shipping_address(
|
|
48
|
-
self,
|
|
49
|
-
) -> dict[str, typing.Any] | None:
|
|
50
|
-
"""
|
|
51
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerShippingAddressRequest` using the Authorizenet API.
|
|
52
|
-
|
|
53
|
-
`getCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-shipping-address>`_
|
|
54
|
-
|
|
55
|
-
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
56
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
57
|
-
:returns: An Authorizenet API response, if any.
|
|
58
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
59
|
-
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
assert self.id, "Address profile id wasn't set."
|
|
63
|
-
|
|
64
|
-
request = apicontractsv1.getCustomerShippingAddressRequest()
|
|
65
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
66
|
-
request.customerProfileId = self.customerProfileId
|
|
67
|
-
request.customerAddressId = self.id
|
|
68
|
-
|
|
69
|
-
return self.execute_controller(
|
|
70
|
-
apicontrollers.getCustomerShippingAddressController(request)
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
def _authorizenet_update_customer_shipping_address(
|
|
74
|
-
self, address: apicontractsv1.customerAddressType, default: bool = False
|
|
75
|
-
) -> dict[str, typing.Any] | None:
|
|
76
|
-
"""
|
|
77
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.updateCustomerShippingAddress` using the Authorizenet API.
|
|
78
|
-
|
|
79
|
-
`updateCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-shipping-address>`_
|
|
80
|
-
|
|
81
|
-
:param address: A customer address object.
|
|
82
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
83
|
-
:param default: Whether or not to set the address profile as default.
|
|
84
|
-
:type default: :py:obj:`bool`
|
|
85
|
-
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
86
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
87
|
-
:returns: An Authorizenet API response, if any.
|
|
88
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
89
|
-
|
|
90
|
-
"""
|
|
91
|
-
request = apicontractsv1.updateCustomerShippingAddressRequest()
|
|
92
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
93
|
-
request.customerProfileId = self.customerProfileId
|
|
94
|
-
request.address = address
|
|
95
|
-
request.address.customerAddressId = self.id
|
|
96
|
-
request.defaultShippingAddress = str(default).lower()
|
|
97
|
-
|
|
98
|
-
return self.execute_controller(
|
|
99
|
-
apicontrollers.updateCustomerShippingAddressController(request)
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
def _authorizenet_delete_customer_shipping_address(
|
|
103
|
-
self,
|
|
104
|
-
) -> dict[str, typing.Any] | None:
|
|
105
|
-
"""
|
|
106
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerShippingAddress` using the Authorizenet API.
|
|
107
|
-
|
|
108
|
-
`deleteCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-shipping-address>`_
|
|
109
|
-
|
|
110
|
-
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
111
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
112
|
-
:returns: An Authorizenet API response, if any.
|
|
113
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
114
|
-
|
|
115
|
-
"""
|
|
116
|
-
|
|
117
|
-
assert self.id, "Address profile id wasn't set."
|
|
118
|
-
|
|
119
|
-
request = apicontractsv1.deleteCustomerShippingAddressRequest()
|
|
120
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
121
|
-
request.customerProfileId = self.customerProfileId
|
|
122
|
-
request.customerAddressId = self.id
|
|
123
|
-
|
|
124
|
-
return self.execute_controller(
|
|
125
|
-
apicontrollers.deleteCustomerShippingAddressController(request)
|
|
126
|
-
)
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
from authorizenet import apicontractsv1
|
|
2
|
-
|
|
3
|
-
from terminusgps.authorizenet.auth import get_merchant_auth, get_validation_mode
|
|
4
|
-
from terminusgps.authorizenet.controllers import AuthorizenetControllerExecutor
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class AuthorizenetBase(AuthorizenetControllerExecutor):
|
|
8
|
-
"""Base class for Authorizenet objects."""
|
|
9
|
-
|
|
10
|
-
def __init__(self, id: int | str | None = None, *args, **kwargs) -> None:
|
|
11
|
-
"""
|
|
12
|
-
Sets :py:attr:`id` if provided.
|
|
13
|
-
|
|
14
|
-
:returns: Nothing.
|
|
15
|
-
:rtype: :py:obj:`None`
|
|
16
|
-
|
|
17
|
-
"""
|
|
18
|
-
self.id = id
|
|
19
|
-
|
|
20
|
-
def __str__(self) -> str:
|
|
21
|
-
"""Returns the object in format: '#<ID>' if :py:attr:`id` is set."""
|
|
22
|
-
return f"#{self.id}" if self.id else ""
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def id(self) -> str | None:
|
|
26
|
-
"""
|
|
27
|
-
An Authorizenet generated id.
|
|
28
|
-
|
|
29
|
-
:type: :py:obj:`str` | :py:obj:`None`
|
|
30
|
-
|
|
31
|
-
"""
|
|
32
|
-
return self._id
|
|
33
|
-
|
|
34
|
-
@id.setter
|
|
35
|
-
def id(self, other: int | str | None) -> None:
|
|
36
|
-
"""
|
|
37
|
-
Sets :py:attr:`id` to ``other``.
|
|
38
|
-
|
|
39
|
-
:raises ValueError: If ``other`` was provided as a string containing non-digit characters.
|
|
40
|
-
:returns: Nothing.
|
|
41
|
-
:rtype: :py:obj:`None`
|
|
42
|
-
|
|
43
|
-
"""
|
|
44
|
-
if isinstance(other, str) and not other.isdigit():
|
|
45
|
-
raise ValueError(f"'id' can only contain digit characters, got '{other}'.")
|
|
46
|
-
self._id = str(other) if other is not None else None
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def merchantAuthentication(self) -> apicontractsv1.merchantAuthenticationType:
|
|
50
|
-
"""
|
|
51
|
-
Current merchant authentication object to authenticate Authorizenet API calls.
|
|
52
|
-
|
|
53
|
-
:returns: A merchant authentication object.
|
|
54
|
-
:rtype: :py:obj:`~authorizenet.apicontractsv1.merchantAuthenticationType`
|
|
55
|
-
|
|
56
|
-
"""
|
|
57
|
-
return get_merchant_auth()
|
|
58
|
-
|
|
59
|
-
@property
|
|
60
|
-
def validationMode(self) -> str:
|
|
61
|
-
"""
|
|
62
|
-
Current Authorizenet API validation mode.
|
|
63
|
-
|
|
64
|
-
:returns: An Authorizenet API validation mode string.
|
|
65
|
-
:rtype: :py:obj:`str`
|
|
66
|
-
|
|
67
|
-
"""
|
|
68
|
-
return get_validation_mode()
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
|
|
3
|
-
from authorizenet import apicontractsv1, apicontrollers
|
|
4
|
-
|
|
5
|
-
from .base import AuthorizenetBase
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AuthorizenetCustomerProfile(AuthorizenetBase):
|
|
9
|
-
"""An Authorizenet customer profile."""
|
|
10
|
-
|
|
11
|
-
def __init__(self, email: str, merchant_id: str, *args, **kwargs) -> None:
|
|
12
|
-
"""
|
|
13
|
-
Sets :py:attr:`_email` and :py:attr:`_merchant_id`.
|
|
14
|
-
|
|
15
|
-
:param email: An email address.
|
|
16
|
-
:type email: :py:obj:`str`
|
|
17
|
-
:param merchant_id: A merchant designated id string.
|
|
18
|
-
:type merchant_id: :py:obj:`str`
|
|
19
|
-
:returns: Nothing.
|
|
20
|
-
:rtype: :py:obj:`None`
|
|
21
|
-
|
|
22
|
-
"""
|
|
23
|
-
super().__init__(*args, **kwargs)
|
|
24
|
-
self._email = email
|
|
25
|
-
self._merchant_id = merchant_id
|
|
26
|
-
|
|
27
|
-
@property
|
|
28
|
-
def email(self) -> str:
|
|
29
|
-
"""An email address assigned to the customer profile."""
|
|
30
|
-
return str(self._email)
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def merchant_id(self) -> str:
|
|
34
|
-
"""A merchant designated id assigned to the customer profile."""
|
|
35
|
-
return str(self._merchant_id)
|
|
36
|
-
|
|
37
|
-
@email.setter
|
|
38
|
-
def email(self, other: str) -> None:
|
|
39
|
-
"""Sets :py:attr:`email` to ``other``."""
|
|
40
|
-
self._email = str(other)
|
|
41
|
-
|
|
42
|
-
@merchant_id.setter
|
|
43
|
-
def merchant_id(self, other: str) -> None:
|
|
44
|
-
"""Sets :py:attr:`merchant_id` to ``other``."""
|
|
45
|
-
self._merchant_id = str(other)
|
|
46
|
-
|
|
47
|
-
def create(self, desc: str | None = None, validate: bool = False) -> int:
|
|
48
|
-
"""
|
|
49
|
-
Creates an Authorizenet customer profile and returns its id as an integer.
|
|
50
|
-
|
|
51
|
-
If successfully created, sets :py:attr:`id` to the new customer profile id.
|
|
52
|
-
|
|
53
|
-
:param desc: An optional customer profile description. Default is :py:obj:`None`
|
|
54
|
-
:type desc: :py:obj:`str` | :py:obj:`None`
|
|
55
|
-
:param validate: Whether or not to validate a payment on the new customer profile. Default is :py:obj:`False`.
|
|
56
|
-
:type validate: :py:obj:`bool`
|
|
57
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
58
|
-
:returns: A customer profile id integer.
|
|
59
|
-
:rtype: :py:obj:`int`
|
|
60
|
-
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
profile = apicontractsv1.customerProfileType()
|
|
64
|
-
profile.merchantCustomerId = self.merchant_id
|
|
65
|
-
if desc:
|
|
66
|
-
profile.description = desc
|
|
67
|
-
|
|
68
|
-
response = self._authorizenet_create_customer_profile(profile, validate)
|
|
69
|
-
profile_id = int(response.customerProfileId)
|
|
70
|
-
self.id = profile_id
|
|
71
|
-
|
|
72
|
-
return profile_id
|
|
73
|
-
|
|
74
|
-
def delete(self) -> None:
|
|
75
|
-
"""
|
|
76
|
-
Deletes the Authorizenet customer profile.
|
|
77
|
-
|
|
78
|
-
If successfully deleted, sets :py:attr:`id` to :py:obj:`None`.
|
|
79
|
-
|
|
80
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
81
|
-
:returns: Nothing.
|
|
82
|
-
:rtype: :py:obj:`None`
|
|
83
|
-
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
if self.id:
|
|
87
|
-
self._authorizenet_delete_customer_profile()
|
|
88
|
-
self._id = None
|
|
89
|
-
|
|
90
|
-
def update(self, desc: str | None = None, validate: bool = False) -> None:
|
|
91
|
-
"""
|
|
92
|
-
Updates the Authorizenet customer profile if :py:attr:`id` is set.
|
|
93
|
-
|
|
94
|
-
:param desc: An optional customer profile description. Default is :py:obj:`None`
|
|
95
|
-
:type desc: :py:obj:`str` | :py:obj:`None`
|
|
96
|
-
:param validate: Whether or not to validate a payment on the customer profile. Default is :py:obj:`False`.
|
|
97
|
-
:type validate: :py:obj:`bool`
|
|
98
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
99
|
-
:returns: Nothing.
|
|
100
|
-
:rtype: :py:obj:`None`
|
|
101
|
-
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
if self.id:
|
|
105
|
-
profile = apicontractsv1.customerProfileExType()
|
|
106
|
-
profile.customerProfileId = self.id
|
|
107
|
-
profile.merchantCustomerId = self.merchant_id
|
|
108
|
-
profile.email = self.email
|
|
109
|
-
if desc is not None:
|
|
110
|
-
profile.description = desc
|
|
111
|
-
|
|
112
|
-
self._authorizenet_update_customer_profile(profile, validate)
|
|
113
|
-
|
|
114
|
-
def _authorizenet_get_customer_profile(
|
|
115
|
-
self, issuer_info: bool = False
|
|
116
|
-
) -> dict[str, typing.Any] | None:
|
|
117
|
-
"""
|
|
118
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileRequest` using the Authorizenet API.
|
|
119
|
-
|
|
120
|
-
`getCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile>`_
|
|
121
|
-
|
|
122
|
-
:param issuer_info: Whether or not to include issuer information in the response. Default is :py:obj:`False`.
|
|
123
|
-
:type issuer_info: :py:obj:`bool`
|
|
124
|
-
:raises AssertionError: If none of :py:attr:`id`, :py:attr:`email` or :py:attr:`merchant_id` were set.
|
|
125
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
126
|
-
:returns: An Authorizenet API response, if any.
|
|
127
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
128
|
-
|
|
129
|
-
"""
|
|
130
|
-
|
|
131
|
-
assert any([self.id, self.email, self.merchant_id]), (
|
|
132
|
-
"At least one of 'id', 'email' or 'merchant_id' must be set."
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
request = apicontractsv1.getCustomerProfileRequest()
|
|
136
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
137
|
-
request.includeIssuerInfo = str(issuer_info).lower()
|
|
138
|
-
|
|
139
|
-
if self.id:
|
|
140
|
-
request.customerProfileId = self.id
|
|
141
|
-
if self.email:
|
|
142
|
-
request.email = self.email
|
|
143
|
-
if self.merchant_id:
|
|
144
|
-
request.customerMerchantId = self.merchant_id
|
|
145
|
-
|
|
146
|
-
return self.execute_controller(
|
|
147
|
-
apicontrollers.getCustomerProfileController(request)
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
def _authorizenet_create_customer_profile(
|
|
151
|
-
self, profile: apicontractsv1.customerProfileType, validate: bool = False
|
|
152
|
-
) -> dict[str, typing.Any] | None:
|
|
153
|
-
"""
|
|
154
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerProfileRequest` using the Authorizenet API.
|
|
155
|
-
|
|
156
|
-
`createCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile>`_
|
|
157
|
-
|
|
158
|
-
:param profile: A customer profile object.
|
|
159
|
-
:type profile: :py:obj:`~authorizenet.apicontractsv1.customerProfileType`
|
|
160
|
-
:param validate: Whether or not to validate a payment profile for the customer profile. Default is :py:obj:`False`.
|
|
161
|
-
:type validate: :py:obj:`bool`
|
|
162
|
-
:raises AuthorizenetControllerExecutionError: If ``validate`` was :py:obj:`True` but validation was forbidden.
|
|
163
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
164
|
-
:returns: An Authorizenet API response, if any.
|
|
165
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
166
|
-
|
|
167
|
-
"""
|
|
168
|
-
request = apicontractsv1.createCustomerProfileRequest()
|
|
169
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
170
|
-
request.profile = profile
|
|
171
|
-
if validate:
|
|
172
|
-
request.validationMode = self.validationMode
|
|
173
|
-
|
|
174
|
-
return self.execute_controller(
|
|
175
|
-
apicontrollers.createCustomerProfileController(request)
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
def _authorizenet_update_customer_profile(
|
|
179
|
-
self, profile: apicontractsv1.customerProfileExType, validate: bool = False
|
|
180
|
-
) -> dict[str, typing.Any] | None:
|
|
181
|
-
"""
|
|
182
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.updateCustomerProfileRequest` using the Authorizenet API.
|
|
183
|
-
|
|
184
|
-
`updateCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-profile>`_
|
|
185
|
-
|
|
186
|
-
:param profile: A customer profile ex object.
|
|
187
|
-
:type profile: :py:obj:`~authorizenet.apicontractsv1.customerProfileExType`
|
|
188
|
-
:param validate: Whether or not to validate a payment profile for the customer profile. Default is :py:obj:`False`.
|
|
189
|
-
:type validate: :py:obj:`bool`
|
|
190
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
191
|
-
:returns: An Authorizenet API response, if any.
|
|
192
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
193
|
-
|
|
194
|
-
"""
|
|
195
|
-
|
|
196
|
-
request = apicontractsv1.updateCustomerProfileRequest()
|
|
197
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
198
|
-
request.profile = profile
|
|
199
|
-
if validate:
|
|
200
|
-
request.validationMode = self.validationMode
|
|
201
|
-
|
|
202
|
-
return self.execute_controller(
|
|
203
|
-
apicontrollers.updateCustomerProfileController(request)
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
def _authorizenet_delete_customer_profile(self) -> dict[str, typing.Any] | None:
|
|
207
|
-
"""
|
|
208
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerProfileRequest` using the Authorizenet API.
|
|
209
|
-
|
|
210
|
-
`deleteCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-profile>`_
|
|
211
|
-
|
|
212
|
-
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
213
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
214
|
-
:returns: An Authorizenet API response, if any.
|
|
215
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
216
|
-
|
|
217
|
-
"""
|
|
218
|
-
|
|
219
|
-
assert self.id, "Customer profile id wasn't set."
|
|
220
|
-
|
|
221
|
-
request = apicontractsv1.deleteCustomerProfileRequest()
|
|
222
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
223
|
-
request.customerProfileId = self.id
|
|
224
|
-
|
|
225
|
-
return self.execute_controller(
|
|
226
|
-
apicontrollers.deleteCustomerProfileController(request)
|
|
227
|
-
)
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
|
|
3
|
-
from authorizenet import apicontractsv1, apicontrollers
|
|
4
|
-
|
|
5
|
-
from .base import AuthorizenetBase
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AuthorizenetPaymentProfile(AuthorizenetBase):
|
|
9
|
-
"""An Authorizenet payment profile."""
|
|
10
|
-
|
|
11
|
-
def __init__(self, customerProfileId: int | str, *args, **kwargs) -> None:
|
|
12
|
-
super().__init__(*args, **kwargs)
|
|
13
|
-
if isinstance(customerProfileId, str) and not customerProfileId.isdigit():
|
|
14
|
-
raise ValueError(
|
|
15
|
-
f"'customerProfileId' can only contain digits, got '{customerProfileId}'."
|
|
16
|
-
)
|
|
17
|
-
self.customerProfileId = customerProfileId
|
|
18
|
-
|
|
19
|
-
def create(
|
|
20
|
-
self,
|
|
21
|
-
payment: apicontractsv1.paymentType,
|
|
22
|
-
address: apicontractsv1.customerAddressType,
|
|
23
|
-
default: bool = False,
|
|
24
|
-
validate: bool = False,
|
|
25
|
-
) -> int:
|
|
26
|
-
"""
|
|
27
|
-
Creates an Authorizenet payment profile and returns its id as an integer.
|
|
28
|
-
|
|
29
|
-
If successfully created, sets :py:attr:`id` to the new payment profile id.
|
|
30
|
-
|
|
31
|
-
:param payment: A payment object.
|
|
32
|
-
:type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
33
|
-
:param address: A customer address object.
|
|
34
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
35
|
-
:param default: Whether or not to set the payment profile as default.
|
|
36
|
-
:type default: :py:obj:`bool`
|
|
37
|
-
:param validate: Whether or not to validate the payment profile.
|
|
38
|
-
:type validate: :py:obj:`bool`
|
|
39
|
-
:raises AuthorizenetControllerExecutionError: If something went wrong during an Authorizenet API call.
|
|
40
|
-
:returns: The new payment profile id.
|
|
41
|
-
:rtype: :py:obj:`int`
|
|
42
|
-
|
|
43
|
-
"""
|
|
44
|
-
response = self._authorizenet_create_customer_payment_profile(
|
|
45
|
-
payment=payment, address=address, default=default, validate=validate
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
payment_id = int(response.customerPaymentProfileId)
|
|
49
|
-
self.id = payment_id
|
|
50
|
-
|
|
51
|
-
return payment_id
|
|
52
|
-
|
|
53
|
-
def update(
|
|
54
|
-
self,
|
|
55
|
-
payment: apicontractsv1.paymentType,
|
|
56
|
-
address: apicontractsv1.customerAddressType,
|
|
57
|
-
default: bool = False,
|
|
58
|
-
validate: bool = False,
|
|
59
|
-
) -> None:
|
|
60
|
-
"""
|
|
61
|
-
Updates the Authorizenet payment profile if :py:attr:`id` is set.
|
|
62
|
-
|
|
63
|
-
:param payment: A payment object.
|
|
64
|
-
:type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
65
|
-
:param address: A customer address object.
|
|
66
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
67
|
-
:param default: Whether or not to set the payment profile as default.
|
|
68
|
-
:type default: :py:obj:`bool`
|
|
69
|
-
:param validate: Whether or not to validate the payment profile.
|
|
70
|
-
:type validate: :py:obj:`bool`
|
|
71
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
72
|
-
:returns: Nothing.
|
|
73
|
-
:rtype: :py:obj:`None`
|
|
74
|
-
|
|
75
|
-
"""
|
|
76
|
-
if self.id:
|
|
77
|
-
self._authorizenet_update_customer_payment_profile(
|
|
78
|
-
payment=payment, address=address, default=default, validate=validate
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
def delete(self) -> None:
|
|
82
|
-
"""
|
|
83
|
-
Deletes the Authorizenet payment profile.
|
|
84
|
-
|
|
85
|
-
If successfully deleted, sets :py:attr:`id` to :py:obj:`None`.
|
|
86
|
-
|
|
87
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
88
|
-
:returns: Nothing.
|
|
89
|
-
:rtype: :py:obj:`None`
|
|
90
|
-
|
|
91
|
-
"""
|
|
92
|
-
|
|
93
|
-
if self.id:
|
|
94
|
-
self._authorizenet_delete_customer_payment_profile()
|
|
95
|
-
self.id = None
|
|
96
|
-
|
|
97
|
-
def _authorizenet_create_customer_payment_profile(
|
|
98
|
-
self,
|
|
99
|
-
payment: apicontractsv1.paymentType,
|
|
100
|
-
address: apicontractsv1.customerAddressType,
|
|
101
|
-
default: bool = False,
|
|
102
|
-
validate: bool = False,
|
|
103
|
-
) -> dict[str, typing.Any] | None:
|
|
104
|
-
"""
|
|
105
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerPaymentProfileRequest` using the Authorizenet API.
|
|
106
|
-
|
|
107
|
-
`createCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-payment-profile>`_
|
|
108
|
-
|
|
109
|
-
:param payment: A payment object.
|
|
110
|
-
:type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
111
|
-
:param address: A customer address object.
|
|
112
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
113
|
-
:param default: Whether or not to set the payment profile as default.
|
|
114
|
-
:type default: :py:obj:`bool`
|
|
115
|
-
:param validate: Whether or not to validate the payment profile in Authorizenet.
|
|
116
|
-
:type validate: :py:obj:`bool`
|
|
117
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
118
|
-
:returns: An Authorizenet API response, if any.
|
|
119
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
120
|
-
|
|
121
|
-
"""
|
|
122
|
-
|
|
123
|
-
request = apicontractsv1.createCustomerPaymentProfileRequest()
|
|
124
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
125
|
-
request.paymentProfile = apicontractsv1.customerPaymentProfileType()
|
|
126
|
-
request.paymentProfile.payment = payment
|
|
127
|
-
request.paymentProfile.address = address
|
|
128
|
-
request.paymentProfile.defaultPaymentProfile = str(default).lower()
|
|
129
|
-
|
|
130
|
-
if validate:
|
|
131
|
-
request.validationMode = self.validationMode
|
|
132
|
-
|
|
133
|
-
return self.execute_controller(
|
|
134
|
-
apicontrollers.createCustomerPaymentProfileController(request)
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
def _authorizenet_get_customer_payment_profile(
|
|
138
|
-
self, issuer_info: bool = False
|
|
139
|
-
) -> dict[str, typing.Any] | None:
|
|
140
|
-
"""
|
|
141
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerPaymentProfileRequest` using the Authorizenet API.
|
|
142
|
-
|
|
143
|
-
`getCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile>`_
|
|
144
|
-
|
|
145
|
-
:param issuer_info: Whether or not to include issuer information in the response.
|
|
146
|
-
:type issuer_info: :py:obj:`bool`
|
|
147
|
-
:raises AssertionError: If :py:attr:`id` wasn't set.
|
|
148
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
149
|
-
:returns: An Authorizenet API response, if any.
|
|
150
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
151
|
-
|
|
152
|
-
"""
|
|
153
|
-
|
|
154
|
-
assert self.id, "Customer payment profile id wasn't set."
|
|
155
|
-
|
|
156
|
-
request = apicontractsv1.getCustomerPaymentProfileRequest()
|
|
157
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
158
|
-
request.customerProfileId = self.customerProfileId
|
|
159
|
-
request.customerPaymentProfileId = self.id
|
|
160
|
-
request.includeIssuerInfo = str(issuer_info).lower()
|
|
161
|
-
|
|
162
|
-
return self.execute_controller(
|
|
163
|
-
apicontrollers.getCustomerPaymentProfileController(request)
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
def _authorizenet_validate_customer_payment_profile(
|
|
167
|
-
self,
|
|
168
|
-
) -> dict[str, typing.Any] | None:
|
|
169
|
-
"""
|
|
170
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.validateCustomerPaymentProfileRequest` using the Authorizenet API.
|
|
171
|
-
|
|
172
|
-
`validateCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-validate-customer-payment-profile>`_
|
|
173
|
-
|
|
174
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
175
|
-
:returns: An Authorizenet API response, if any.
|
|
176
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
177
|
-
|
|
178
|
-
"""
|
|
179
|
-
|
|
180
|
-
request = apicontractsv1.validateCustomerPaymentProfileRequest()
|
|
181
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
182
|
-
request.customerProfileId = self.customerProfileId
|
|
183
|
-
request.customerPaymentProfileId = self.id
|
|
184
|
-
request.validationMode = self.validationMode
|
|
185
|
-
|
|
186
|
-
return self.execute_controller(
|
|
187
|
-
apicontrollers.validateCustomerPaymentProfileController(request)
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
def _authorizenet_update_customer_payment_profile(
|
|
191
|
-
self,
|
|
192
|
-
payment: apicontractsv1.paymentType,
|
|
193
|
-
address: apicontractsv1.customerAddressType,
|
|
194
|
-
default: bool = False,
|
|
195
|
-
validate: bool = False,
|
|
196
|
-
) -> dict[str, typing.Any] | None:
|
|
197
|
-
"""
|
|
198
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.updateCustomerPaymentProfileRequest` using the Authorizenet API.
|
|
199
|
-
|
|
200
|
-
`updateCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-payment-profile>`_
|
|
201
|
-
|
|
202
|
-
:param payment: A payment object.
|
|
203
|
-
:type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
204
|
-
:param address: A customer address object.
|
|
205
|
-
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
206
|
-
:param default: Whether or not to set the payment profile as default.
|
|
207
|
-
:type default: :py:obj:`bool`
|
|
208
|
-
:param validate: Whether or not to validate the payment profile in Authorizenet.
|
|
209
|
-
:type validate: :py:obj:`bool`
|
|
210
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
211
|
-
:returns: An Authorizenet API response, if any.
|
|
212
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
213
|
-
|
|
214
|
-
"""
|
|
215
|
-
|
|
216
|
-
request = apicontractsv1.updateCustomerPaymentProfileRequest()
|
|
217
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
218
|
-
request.customerProfileId = self.customerProfileId
|
|
219
|
-
|
|
220
|
-
request.paymentProfile = apicontractsv1.customerPaymentProfileType()
|
|
221
|
-
request.paymentProfile.payment = payment
|
|
222
|
-
request.paymentProfile.address = address
|
|
223
|
-
request.paymentProfile.defaultPaymentProfile = str(default).lower()
|
|
224
|
-
request.paymentProfile.customerPaymentProfileId = self.id
|
|
225
|
-
|
|
226
|
-
if validate:
|
|
227
|
-
request.validationMode = self.validationMode
|
|
228
|
-
|
|
229
|
-
return self.execute_controller(
|
|
230
|
-
apicontrollers.updateCustomerPaymentProfileController(request)
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
def _authorizenet_delete_customer_payment_profile(
|
|
234
|
-
self,
|
|
235
|
-
) -> dict[str, typing.Any] | None:
|
|
236
|
-
"""
|
|
237
|
-
Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerPaymentProfileRequest` using the Authorizenet API.
|
|
238
|
-
|
|
239
|
-
`deleteCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-payment-profile>`_
|
|
240
|
-
|
|
241
|
-
:raises AuthorizenetControllerExecutionError: If something goes wrong during an Authorizenet API call.
|
|
242
|
-
:returns: An Authorizenet API response, if any.
|
|
243
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
244
|
-
|
|
245
|
-
"""
|
|
246
|
-
request = apicontractsv1.deleteCustomerPaymentProfileRequest()
|
|
247
|
-
request.merchantAuthentication = self.merchantAuthentication
|
|
248
|
-
request.customerProfileId = self.customerProfileId
|
|
249
|
-
request.customerPaymentProfileId = self.id
|
|
250
|
-
|
|
251
|
-
return self.execute_controller(
|
|
252
|
-
apicontrollers.deleteCustomerPaymentProfileController(request)
|
|
253
|
-
)
|
|
File without changes
|
|
File without changes
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import unittest
|
|
3
|
-
|
|
4
|
-
from django.conf import settings
|
|
5
|
-
|
|
6
|
-
from terminusgps.wialon.session import WialonSession
|
|
7
|
-
|
|
8
|
-
TEST_WIALON_TOKEN = os.getenv("WIALON_TOKEN") or settings.WIALON_TOKEN
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class WialonSessionTestCase(unittest.TestCase):
|
|
12
|
-
def setUp(self) -> None:
|
|
13
|
-
self.token = TEST_WIALON_TOKEN
|
|
14
|
-
self.session = WialonSession()
|
|
15
|
-
|
|
16
|
-
def tearDown(self) -> None:
|
|
17
|
-
if self.session.active:
|
|
18
|
-
self.session.logout()
|
|
19
|
-
|
|
20
|
-
def test_session_init(self) -> None:
|
|
21
|
-
self.assertIsNone(self.session.id)
|
|
22
|
-
self.assertIsNone(self.session.username)
|
|
23
|
-
self.assertIsNone(self.session.uid)
|
|
24
|
-
|
|
25
|
-
def test_session_login(self) -> None:
|
|
26
|
-
sid: str = self.session.login(self.token)
|
|
27
|
-
self.assertEqual(self.session.id, sid)
|
|
28
|
-
|
|
29
|
-
def test_session_logout(self) -> None:
|
|
30
|
-
self.session.login(self.token)
|
|
31
|
-
self.session.logout()
|
|
32
|
-
self.assertIsNone(self.session.id, None)
|
|
33
|
-
|
|
34
|
-
def test_session_bad_call(self) -> None:
|
|
35
|
-
self.session.login(self.token)
|
|
36
|
-
response = self.session.wialon_api.core_bad_call({})
|
|
37
|
-
self.assertIsNone(response)
|
|
38
|
-
|
|
39
|
-
def test_session_valid_call_count(self) -> None:
|
|
40
|
-
self.session.login(self.token) # Login/logout does not count
|
|
41
|
-
self.session.wialon_api.avl_evts()
|
|
42
|
-
self.assertEqual(self.session.wialon_api.total_calls, 1)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import string
|
|
2
|
-
import unittest
|
|
3
|
-
|
|
4
|
-
from terminusgps.wialon import utils
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class WialonUtilsTestCase(unittest.TestCase):
|
|
8
|
-
def test_generate_wialon_password_min_length(self) -> None:
|
|
9
|
-
with self.assertRaises(ValueError) as context:
|
|
10
|
-
utils.generate_wialon_password(length=7)
|
|
11
|
-
self.assertTrue(
|
|
12
|
-
"Password cannot be less than 8 characters in length, got 7."
|
|
13
|
-
in str(context.exception)
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
def test_generate_wialon_password_max_length(self) -> None:
|
|
17
|
-
with self.assertRaises(ValueError) as context:
|
|
18
|
-
utils.generate_wialon_password(length=65)
|
|
19
|
-
self.assertTrue(
|
|
20
|
-
"Password cannot be greater than 64 characters in length, got 65."
|
|
21
|
-
in str(context.exception)
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
def test_generate_wialon_password_valid(self) -> None:
|
|
25
|
-
password = utils.generate_wialon_password()
|
|
26
|
-
s0 = list(string.ascii_uppercase)
|
|
27
|
-
s1 = list(string.ascii_lowercase)
|
|
28
|
-
s2 = list(string.digits)
|
|
29
|
-
s3 = list("!@#$%^*()[]-_+")
|
|
30
|
-
|
|
31
|
-
if len(password) < 8 or len(password) > 64:
|
|
32
|
-
self.fail(f"Generated password was {len(password)} chars in length.")
|
|
33
|
-
if not any([c for c in password if c in s0]):
|
|
34
|
-
self.fail("Generated password did not contain an uppercase letter.")
|
|
35
|
-
if not any([c for c in password if c in s1]):
|
|
36
|
-
self.fail("Generated password did not contain a lowercase letter.")
|
|
37
|
-
# TODO: Make this check for 3 digits
|
|
38
|
-
if not any([c for c in password if c in s2]):
|
|
39
|
-
self.fail("Generated password did not contain a digit.")
|
|
40
|
-
if not any([c for c in password if c in s3]):
|
|
41
|
-
self.fail("Generated password did not contain a special symbol.")
|
|
File without changes
|
{python_terminusgps-37.5.2.dist-info → python_terminusgps-37.6.1.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|