python-terminusgps 1.9.3__tar.gz → 1.9.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/PKG-INFO +1 -1
  2. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/pyproject.toml +1 -1
  3. python_terminusgps-1.9.8/terminusgps/authorizenet/auth.py +27 -0
  4. python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/__init__.py +3 -0
  5. python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/addresses.py +91 -0
  6. python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/base.py +84 -0
  7. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/customers.py +34 -37
  8. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/payments.py +62 -56
  9. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/settings.py +0 -2
  10. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/uv.lock +1 -1
  11. python_terminusgps-1.9.3/terminusgps/authorizenet/auth.py +0 -35
  12. python_terminusgps-1.9.3/terminusgps/authorizenet/profiles/addresses.py +0 -83
  13. python_terminusgps-1.9.3/terminusgps/authorizenet/profiles/base.py +0 -62
  14. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/.gitignore +0 -0
  15. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/COPYING +0 -0
  16. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/README.md +0 -0
  17. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/requirements.txt +0 -0
  18. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/__init__.py +0 -0
  19. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/authorizenet/__init__.py +0 -0
  20. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/aws/__init__.py +0 -0
  21. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/aws/secrets.py +0 -0
  22. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/__init__.py +0 -0
  23. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/constants.py +0 -0
  24. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/errors.py +0 -0
  25. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/flags.py +0 -0
  26. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/__init__.py +0 -0
  27. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/base.py +0 -0
  28. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/resource.py +0 -0
  29. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/retranslator.py +0 -0
  30. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/route.py +0 -0
  31. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/unit.py +0 -0
  32. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/unit_group.py +0 -0
  33. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/items/user.py +0 -0
  34. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/session.py +0 -0
  35. {python_terminusgps-1.9.3 → python_terminusgps-1.9.8}/terminusgps/wialon/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 1.9.3
3
+ Version: 1.9.8
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-terminusgps"
3
- version = "1.9.3"
3
+ version = "1.9.8"
4
4
  description = "Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more."
5
5
  readme = "README.md"
6
6
  authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
@@ -0,0 +1,27 @@
1
+ from authorizenet.apicontractsv1 import merchantAuthenticationType
2
+ from authorizenet.constants import constants
3
+
4
+ from django.conf import settings
5
+ from django.core.exceptions import ImproperlyConfigured
6
+
7
+ if not hasattr(settings, "DEBUG"):
8
+ raise ImproperlyConfigured("'DEBUG' setting is required.")
9
+ if not hasattr(settings, "MERCHANT_AUTH_LOGIN_ID"):
10
+ raise ImproperlyConfigured("'MERCHANT_AUTH_LOGIN_ID' setting is required.")
11
+ if not hasattr(settings, "MERCHANT_AUTH_TRANSACTION_KEY"):
12
+ raise ImproperlyConfigured("'MERCHANT_AUTH_TRANSACTION_KEY' setting is required.")
13
+
14
+
15
+ def get_merchant_auth() -> merchantAuthenticationType:
16
+ return merchantAuthenticationType(
17
+ name=str(settings.MERCHANT_AUTH_LOGIN_ID),
18
+ transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
19
+ )
20
+
21
+
22
+ def get_environment() -> str:
23
+ return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
24
+
25
+
26
+ def get_validation_mode() -> str:
27
+ return "testMode" if settings.DEBUG else "liveMode"
@@ -0,0 +1,3 @@
1
+ from .addresses import AddressProfile
2
+ from .customers import CustomerProfile
3
+ from .payments import PaymentProfile
@@ -0,0 +1,91 @@
1
+ from authorizenet import apicontractsv1, apicontrollers
2
+ from authorizenet.apicontractsv1 import customerAddressType
3
+
4
+ from terminusgps.authorizenet.profiles.base import AuthorizenetSubProfileBase
5
+
6
+
7
+ class AddressProfile(AuthorizenetSubProfileBase):
8
+ def create(self, **kwargs) -> int:
9
+ """
10
+ Creates an Authorize.NET address profile.
11
+
12
+ :param shipping_addr: An Authorize.NET customer address.
13
+ :type shipping_addr: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
14
+ :raises ValueError: If no customer address was provided.
15
+ :raises TypeError: If the customer address is not a :py:obj:`~authorizenet.apicontractsv1.customerAddressType` object.
16
+ :returns: The new address profile's id.
17
+ :rtype: :py:obj:`int`
18
+
19
+ """
20
+ shipping_addr = kwargs.get("shipping_addr")
21
+
22
+ if not shipping_addr:
23
+ raise ValueError("'shipping_addr' is required on creation.")
24
+
25
+ if not isinstance(shipping_addr, customerAddressType):
26
+ raise TypeError(
27
+ f"'shipping_addr' must be customerAddressType, got '{type(shipping_addr)}'."
28
+ )
29
+
30
+ response = self._authorizenet_create_shipping_address(shipping_addr)
31
+ return int(response.customerAddressId)
32
+
33
+ def update(self, shipping_addr: customerAddressType) -> dict:
34
+ """Updates the Authorize.NET payment profile."""
35
+ return self._authorizenet_update_shipping_address(shipping_addr)
36
+
37
+ def delete(self) -> dict:
38
+ """Deletes the Authorize.NET payment profile."""
39
+ return self._authorizenet_delete_shipping_address()
40
+
41
+ def get_details(self) -> dict:
42
+ return self._authorizenet_get_shipping_address()
43
+
44
+ def _authorizenet_get_shipping_address(self) -> dict:
45
+ assert self.id, "'id' was not set."
46
+
47
+ request = apicontractsv1.getCustomerShippingAddressRequest(
48
+ merchantAuthentication=self.merchantAuthentication,
49
+ customerProfileId=self.customerProfileId,
50
+ customerAddressId=self.id,
51
+ )
52
+ controller = apicontrollers.getCustomerShippingAddressController(request)
53
+ response = self.execute_controller(controller)
54
+ return response
55
+
56
+ def _authorizenet_create_shipping_address(self, addr: customerAddressType) -> dict:
57
+ request = apicontractsv1.createCustomerShippingAddressRequest(
58
+ merchantAuthentication=self.merchantAuthentication,
59
+ customerProfileId=self.customerProfileId,
60
+ address=addr,
61
+ defaultShippingAddress=self.default,
62
+ )
63
+ controller = apicontrollers.createCustomerShippingAddressController(request)
64
+ response = self.execute_controller(controller)
65
+ return response
66
+
67
+ def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> dict:
68
+ assert self.id, "'id' was not set."
69
+ addr.customerAddressId = self.id
70
+
71
+ request = apicontractsv1.updateCustomerShippingAddressRequest(
72
+ merchantAuthentication=self.merchantAuthentication,
73
+ customerProfileId=self.customerProfileId,
74
+ address=addr,
75
+ default=self.default,
76
+ )
77
+ controller = apicontrollers.updateCustomerShippingAddressController(request)
78
+ response = self.execute_controller(controller)
79
+ return response
80
+
81
+ def _authorizenet_delete_shipping_address(self) -> dict:
82
+ assert self.id, "'id' was not set."
83
+
84
+ request = apicontractsv1.deleteCustomerShippingAddressRequest(
85
+ merchantAuthentication=self.merchantAuthentication,
86
+ customerProfileId=self.customerProfileId,
87
+ customerAddressId=self.id,
88
+ )
89
+ controller = apicontrollers.deleteCustomerShippingAddressController(request)
90
+ response = self.execute_controller(controller)
91
+ return response
@@ -0,0 +1,84 @@
1
+ from abc import abstractmethod
2
+
3
+ from authorizenet.apicontractsv1 import merchantAuthenticationType
4
+ from authorizenet.apicontrollersbase import APIOperationBase
5
+
6
+ from ..auth import get_merchant_auth, get_environment, get_validation_mode
7
+
8
+
9
+ class AuthorizenetProfileBase:
10
+ def __init__(
11
+ self, merchant_id: int | str, id: int | str | None = None, **kwargs
12
+ ) -> None:
13
+ self._merchantCustomerId = merchant_id
14
+ self._id = str(id) if id else self.create(**kwargs)
15
+
16
+ def __str__(self) -> str:
17
+ return f"#{self.id}"
18
+
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
+ @property
38
+ def merchantCustomerId(self) -> str:
39
+ return str(self._merchantCustomerId)
40
+
41
+ @property
42
+ def id(self) -> str:
43
+ return str(self._id)
44
+
45
+ @property
46
+ def merchantAuthentication(self) -> merchantAuthenticationType:
47
+ return get_merchant_auth()
48
+
49
+ @property
50
+ def environment(self) -> str:
51
+ return get_environment()
52
+
53
+ @abstractmethod
54
+ def create(self, **kwargs) -> int:
55
+ raise NotImplementedError("Subclasses must implement this method.")
56
+
57
+ @abstractmethod
58
+ def update(self, *args, **kwargs) -> dict:
59
+ raise NotImplementedError("Subclasses must implement this method.")
60
+
61
+ @abstractmethod
62
+ def delete(self, *args, **kwargs) -> dict:
63
+ raise NotImplementedError("Subclasses must implement this method.")
64
+
65
+
66
+ class AuthorizenetSubProfileBase(AuthorizenetProfileBase):
67
+ def __init__(
68
+ self, customer_profile_id: int | str, default: bool, *args, **kwargs
69
+ ) -> None:
70
+ self._customerProfileId = customer_profile_id
71
+ self._default = default
72
+ return super().__init__(*args, **kwargs)
73
+
74
+ @property
75
+ def validationMode(self) -> str:
76
+ return get_validation_mode()
77
+
78
+ @property
79
+ def default(self) -> str:
80
+ return str(self._default).lower()
81
+
82
+ @property
83
+ def customerProfileId(self) -> str:
84
+ return str(self._customerProfileId)
@@ -1,16 +1,5 @@
1
- from authorizenet.apicontrollers import (
2
- createCustomerProfileController,
3
- deleteCustomerProfileController,
4
- getCustomerProfileController,
5
- updateCustomerProfileController,
6
- )
7
- from authorizenet.apicontractsv1 import (
8
- customerProfileType,
9
- createCustomerProfileRequest,
10
- deleteCustomerProfileRequest,
11
- getCustomerProfileRequest,
12
- updateCustomerProfileRequest,
13
- )
1
+ from authorizenet import apicontractsv1, apicontrollers
2
+ from authorizenet.apicontractsv1 import customerProfileType
14
3
 
15
4
  from terminusgps.authorizenet.profiles.base import AuthorizenetProfileBase
16
5
 
@@ -31,15 +20,16 @@ class CustomerProfile(AuthorizenetProfileBase):
31
20
  if not kwargs.get("email"):
32
21
  raise ValueError("'email' is required for creation.")
33
22
 
34
- return self._authorizenet_create_customer_profile(
35
- kwargs["email"], kwargs.get("desc", "")
23
+ response = self._authorizenet_create_customer_profile(
24
+ email=kwargs["email"], desc=kwargs.get("desc", "")
36
25
  )
26
+ return int(response.customerProfileId)
37
27
 
38
- def update(self, email: str, desc: str = "") -> None:
28
+ def update(self, email: str, desc: str = "") -> dict:
39
29
  """Updates the customer profile."""
40
30
  return self._authorizenet_update_customer_profile(email, desc)
41
31
 
42
- def delete(self) -> None:
32
+ def delete(self) -> dict:
43
33
  """Deletes the customer profile."""
44
34
  return self._authorizenet_delete_customer_profile()
45
35
 
@@ -57,9 +47,11 @@ class CustomerProfile(AuthorizenetProfileBase):
57
47
  )
58
48
  return addresses if addresses else None
59
49
 
60
- def _authorizenet_create_customer_profile(self, email: str, desc: str = "") -> int:
50
+ def _authorizenet_create_customer_profile(
51
+ self, email: str, desc: str = ""
52
+ ) -> dict[str, str]:
61
53
  """Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerProfileRequest` using the Authorize.NET API."""
62
- request = createCustomerProfileRequest(
54
+ request = apicontractsv1.createCustomerProfileRequest(
63
55
  merchantAuthentication=self.merchantAuthentication,
64
56
  profile=customerProfileType(
65
57
  merchantCustomerId=self.merchantCustomerId,
@@ -67,36 +59,28 @@ class CustomerProfile(AuthorizenetProfileBase):
67
59
  description=desc,
68
60
  ),
69
61
  )
70
- controller = createCustomerProfileController(request)
62
+ controller = apicontrollers.createCustomerProfileController(request)
71
63
  response = self.execute_controller(controller)
72
- return int(response.customerProfileId)
73
-
74
- def _authorizenet_delete_customer_profile(self) -> None:
75
- """Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerProfileRequest` using the Authorize.NET API."""
76
- assert self.id, "'id' was not set."
77
- request = deleteCustomerProfileRequest(
78
- merchantAuthentication=self.merchantAuthentication,
79
- customerProfileId=str(self.id),
80
- )
81
- controller = deleteCustomerProfileController(request)
82
- self.execute_controller(controller)
64
+ return response
83
65
 
84
66
  def _authorizenet_get_customer_profile(self, issuer_info: bool = True) -> dict:
85
67
  """Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileRequest` using the Authorize.NET API."""
86
68
  assert self.id, "'id' was not set."
87
- request = getCustomerProfileRequest(
69
+
70
+ request = apicontractsv1.getCustomerProfileRequest(
88
71
  merchantAuthentication=self.merchantAuthentication,
89
72
  customerProfileId=self.id,
90
73
  includeIssuerInfo=str(issuer_info).lower(),
91
74
  )
92
- controller = getCustomerProfileController(request)
75
+ controller = apicontrollers.getCustomerProfileController(request)
93
76
  response = self.execute_controller(controller)
94
77
  return response
95
78
 
96
- def _authorizenet_update_customer_profile(self, email: str, desc: str = "") -> None:
79
+ def _authorizenet_update_customer_profile(self, email: str, desc: str = "") -> dict:
97
80
  """Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerProfileRequest` using the Authorize.NET API."""
98
81
  assert self.id, "'id' was not set."
99
- request = updateCustomerProfileRequest(
82
+
83
+ request = apicontractsv1.updateCustomerProfileRequest(
100
84
  merchantAuthentication=self.merchantAuthentication,
101
85
  profile=customerProfileType(
102
86
  merchantCustomerId=self.merchantCustomerId,
@@ -105,5 +89,18 @@ class CustomerProfile(AuthorizenetProfileBase):
105
89
  customerProfileId=self.id,
106
90
  ),
107
91
  )
108
- controller = updateCustomerProfileController(request)
109
- self.execute_controller(controller)
92
+ controller = apicontrollers.updateCustomerProfileController(request)
93
+ response = self.execute_controller(controller)
94
+ return response
95
+
96
+ def _authorizenet_delete_customer_profile(self) -> dict:
97
+ """Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerProfileRequest` using the Authorize.NET API."""
98
+ assert self.id, "'id' was not set."
99
+
100
+ request = apicontractsv1.deleteCustomerProfileRequest(
101
+ merchantAuthentication=self.merchantAuthentication,
102
+ customerProfileId=self.id,
103
+ )
104
+ controller = apicontrollers.deleteCustomerProfileController(request)
105
+ response = self.execute_controller(controller)
106
+ return response
@@ -1,25 +1,26 @@
1
+ from authorizenet import apicontractsv1, apicontrollers
1
2
  from authorizenet.apicontractsv1 import (
2
- createCustomerPaymentProfileRequest,
3
3
  customerAddressType,
4
- deleteCustomerPaymentProfileRequest,
5
- getCustomerPaymentProfileRequest,
6
- paymentProfile,
4
+ customerPaymentProfileType,
7
5
  paymentType,
8
- validateCustomerPaymentProfileRequest,
9
- updateCustomerPaymentProfileRequest,
10
6
  )
11
- from authorizenet.apicontrollers import (
12
- createCustomerPaymentProfileController,
13
- deleteCustomerPaymentProfileController,
14
- getCustomerPaymentProfileController,
15
- updateCustomerPaymentProfileController,
16
- validateCustomerPaymentProfileController,
17
- )
18
- from terminusgps.authorizenet.profiles.base import AuthorizenetCustomerProfileBase
7
+
8
+ from terminusgps.authorizenet.profiles.base import AuthorizenetSubProfileBase
19
9
 
20
10
 
21
- class PaymentProfile(AuthorizenetCustomerProfileBase):
11
+ class PaymentProfile(AuthorizenetSubProfileBase):
22
12
  def create(self, **kwargs) -> int:
13
+ """
14
+ Creates an Authorize.NET payment profile.
15
+
16
+ :param billing_addr: An Authorize.NET customer address.
17
+ :type billing_addr: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
18
+ :param payment: An Authorize.NET API payment.
19
+ :type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
20
+ :returns: The new payment profile's id.
21
+ :rtype: :py:obj:`int`
22
+
23
+ """
23
24
  billing_addr = kwargs.get("billing_addr")
24
25
  payment = kwargs.get("payment")
25
26
  if not billing_addr:
@@ -36,43 +37,57 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
36
37
  f"'payment' must be customerAddressType, got '{type(payment)}'"
37
38
  )
38
39
 
39
- return self._authorizenet_create_payment_profile(billing_addr, payment)
40
+ response = self._authorizenet_create_payment_profile(billing_addr, payment)
41
+ return int(response.customerPaymentProfileId)
40
42
 
41
- def update(self, billing_addr: customerAddressType, payment: paymentType) -> None:
42
- self._authorizenet_update_payment_profile(billing_addr, payment)
43
+ def update(self, billing_addr: customerAddressType, payment: paymentType) -> dict:
44
+ """Updates the Authorize.NET payment profile."""
45
+ return self._authorizenet_update_payment_profile(billing_addr, payment)
43
46
 
44
- def delete(self) -> None:
45
- self._authorizenet_delete_payment_profile()
47
+ def delete(self) -> dict:
48
+ """Deletes the Authorize.NET payment profile."""
49
+ return self._authorizenet_delete_payment_profile()
46
50
 
47
51
  def get_details(self, issuer_info: bool = False) -> dict:
48
52
  return self._authorizenet_get_payment_profile(issuer_info)
49
53
 
50
54
  def _authorizenet_create_payment_profile(
51
55
  self, billing_addr: customerAddressType, payment: paymentType
52
- ) -> int:
53
- """Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerPaymentProfileRequest` using the Authorize.NET API."""
54
- request = createCustomerPaymentProfileRequest(
55
- merchantAuthentication=self.merchantAuthentication,
56
+ ) -> dict:
57
+ request = apicontractsv1.createCustomerPaymentProfileRequest(
56
58
  customerProfileId=self.customerProfileId,
57
- paymentProfile=paymentProfile(
58
- billTo=billing_addr, payment=payment, default=self.default
59
+ merchantAuthentication=self.merchantAuthentication,
60
+ paymentProfile=customerPaymentProfileType(
61
+ billTo=billing_addr, payment=payment, defaultPaymentProfile=self.default
59
62
  ),
60
63
  validationMode=self.validationMode,
61
- defaultPaymentProfile=self.default,
62
64
  )
63
- controller = createCustomerPaymentProfileController(request)
65
+ controller = apicontrollers.createCustomerPaymentProfileController(request)
64
66
  response = self.execute_controller(controller)
65
- return int(response.customerPaymentProfileId)
67
+ return response
68
+
69
+ def _authorizenet_get_payment_profile(self, issuer_info: bool = False) -> dict:
70
+ assert self.id, "'id' was not set."
71
+
72
+ request = apicontractsv1.getCustomerPaymentProfileRequest(
73
+ merchantAuthentication=self.merchantAuthentication,
74
+ customerProfileId=self.customerProfileId,
75
+ customerPaymentProfileId=self.id,
76
+ includeIssuerInfo=str(issuer_info).lower(),
77
+ )
78
+ controller = apicontrollers.getCustomerPaymentProfileController(request)
79
+ response = self.execute_controller(controller)
80
+ return response
66
81
 
67
82
  def _authorizenet_update_payment_profile(
68
83
  self, billing_addr: customerAddressType, payment: paymentType
69
- ) -> None:
70
- """Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerPaymentProfileRequest` using the Authorize.NET API."""
84
+ ) -> dict:
71
85
  assert self.id, "'id' was not set."
72
- request = updateCustomerPaymentProfileRequest(
86
+
87
+ request = apicontractsv1.updateCustomerPaymentProfileRequest(
73
88
  merchantAuthentication=self.merchantAuthentication,
74
89
  customerProfileId=self.customerProfileId,
75
- paymentProfile=paymentProfile(
90
+ paymentProfile=customerPaymentProfileType(
76
91
  billTo=billing_addr,
77
92
  payment=payment,
78
93
  defaultPaymentProfile=self.default,
@@ -80,40 +95,31 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
80
95
  ),
81
96
  validationMode=self.validationMode,
82
97
  )
83
- controller = updateCustomerPaymentProfileController(request)
84
- self.execute_controller(controller)
98
+ controller = apicontrollers.updateCustomerPaymentProfileController(request)
99
+ response = self.execute_controller(controller)
100
+ return response
85
101
 
86
- def _authorizenet_get_payment_profile(self, issuer_info: bool = False) -> dict:
87
- """Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerPaymentProfileRequest` using the Authorize.NET API."""
102
+ def _authorizenet_validate_payment_profile(self) -> dict:
88
103
  assert self.id, "'id' was not set."
89
- request = getCustomerPaymentProfileRequest(
90
- merchantAuthentication=self.merchantAuthentication,
91
- customerProfileId=self.customerProfileId,
92
- customerPaymentProfileId=self.id,
93
- includeIssuerInfo=str(issuer_info).lower(),
94
- )
95
- controller = getCustomerPaymentProfileController(request)
96
- return self.execute_controller(controller)
97
104
 
98
- def _authorizenet_validate_payment_profile(self) -> None:
99
- """Executes a :py:obj:`~authorizenet.apicontractsv1.validateCustomerPaymentProfileRequest` using the Authorize.NET API."""
100
- assert self.id, "'id' was not set."
101
- request = validateCustomerPaymentProfileRequest(
105
+ request = apicontractsv1.validateCustomerPaymentProfileRequest(
102
106
  merchantAuthentication=self.merchantAuthentication,
103
107
  customerProfileId=self.customerProfileId,
104
108
  customerPaymentProfileId=self.id,
105
109
  validationMode=self.validationMode,
106
110
  )
107
- controller = validateCustomerPaymentProfileController(request)
108
- self.execute_controller(controller)
111
+ controller = apicontrollers.validateCustomerPaymentProfileController(request)
112
+ response = self.execute_controller(controller)
113
+ return response
109
114
 
110
- def _authorizenet_delete_payment_profile(self) -> None:
111
- """Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerPaymentProfileRequest` using the Authorize.NET API."""
115
+ def _authorizenet_delete_payment_profile(self) -> dict:
112
116
  assert self.id, "'id' was not set."
113
- request = deleteCustomerPaymentProfileRequest(
117
+
118
+ request = apicontractsv1.deleteCustomerPaymentProfileRequest(
114
119
  merchantAuthentication=self.merchantAuthentication,
115
120
  customerProfileId=self.customerProfileId,
116
121
  customerPaymentProfileId=self.id,
117
122
  )
118
- controller = deleteCustomerPaymentProfileController(request)
119
- self.execute_controller(controller)
123
+ controller = apicontrollers.deleteCustomerPaymentProfileController(request)
124
+ response = self.execute_controller(controller)
125
+ return response
@@ -6,5 +6,3 @@ WIALON_ADMIN_ID = getenv("WIALON_ADMIN_ID")
6
6
  WIALON_TOKEN = getenv("WIALON_TOKEN")
7
7
  MERCHANT_AUTH_LOGIN_ID = getenv("MERCHANT_AUTH_LOGIN_ID")
8
8
  MERCHANT_AUTH_TRANSACTION_KEY = getenv("MERCHANT_AUTH_TRANSACTION_KEY")
9
- QB_CLIENT_ID = getenv("QB_CLIENT_ID")
10
- QB_CLIENT_SECRET = getenv("QB_CLIENT_ID")
@@ -285,7 +285,7 @@ wheels = [
285
285
 
286
286
  [[package]]
287
287
  name = "python-terminusgps"
288
- version = "1.9.2"
288
+ version = "1.9.8"
289
289
  source = { editable = "." }
290
290
  dependencies = [
291
291
  { name = "argparse" },
@@ -1,35 +0,0 @@
1
- from authorizenet.apicontractsv1 import merchantAuthenticationType
2
- from authorizenet.constants import constants
3
-
4
- from django.conf import ImproperlyConfigured, settings
5
-
6
-
7
- def settings_required(settings_list: list[str]):
8
- def decorator(func):
9
- def wrapped(*args, **kwargs):
10
- for setting_name in settings_list:
11
- if not hasattr(settings, setting_name):
12
- raise ImproperlyConfigured(f"'{setting_name}' setting is required.")
13
- return func(*args, **kwargs)
14
-
15
- return wrapped
16
-
17
- return decorator
18
-
19
-
20
- @settings_required(["MERCHANT_AUTH_LOGIN_ID", "MERCHANT_AUTH_TRANSACTION_KEY"])
21
- def get_merchant_auth() -> merchantAuthenticationType:
22
- return merchantAuthenticationType(
23
- name=str(settings.MERCHANT_AUTH_LOGIN_ID),
24
- transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
25
- )
26
-
27
-
28
- @settings_required(["DEBUG"])
29
- def get_environment() -> str:
30
- return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
31
-
32
-
33
- @settings_required(["DEBUG"])
34
- def get_validation_mode() -> str:
35
- return "testMode" if settings.DEBUG else "liveMode"
@@ -1,83 +0,0 @@
1
- from authorizenet.apicontractsv1 import (
2
- createCustomerShippingAddressRequest,
3
- customerAddressType,
4
- deleteCustomerShippingAddressRequest,
5
- updateCustomerShippingAddressRequest,
6
- getCustomerShippingAddressRequest,
7
- getCustomerShippingAddressResponse,
8
- )
9
- from authorizenet.apicontrollers import (
10
- createCustomerShippingAddressController,
11
- deleteCustomerShippingAddressController,
12
- getCustomerShippingAddressController,
13
- updateCustomerShippingAddressController,
14
- )
15
- from terminusgps.authorizenet.profiles.base import AuthorizenetCustomerProfileBase
16
-
17
-
18
- class AddressProfile(AuthorizenetCustomerProfileBase):
19
- def create(self, **kwargs) -> int:
20
- shipping_addr = kwargs.get("shipping_addr")
21
-
22
- if not shipping_addr:
23
- raise ValueError("'shipping_addr' is required on creation.")
24
-
25
- if not isinstance(shipping_addr, customerAddressType):
26
- raise TypeError(
27
- f"'shipping_addr' must be customerAddressType, got '{type(shipping_addr)}'."
28
- )
29
-
30
- return self._authorizenet_create_shipping_address(shipping_addr)
31
-
32
- def delete(self) -> None:
33
- self._authorizenet_delete_shipping_address()
34
-
35
- def update(self, shipping_addr: customerAddressType) -> None:
36
- self._authorizenet_update_shipping_address(shipping_addr)
37
-
38
- def get_details(self) -> dict:
39
- return self._authorizenet_get_shipping_address()
40
-
41
- def _authorizenet_create_shipping_address(self, addr: customerAddressType) -> int:
42
- request = createCustomerShippingAddressRequest(
43
- merchantAuthentication=self.merchantAuthentication,
44
- customerProfileId=self.customerProfileId,
45
- address=addr,
46
- defaultShippingAddress=self.default,
47
- )
48
- controller = createCustomerShippingAddressController(request)
49
- response = self.execute_controller(controller)
50
- return int(response.customerAddressId)
51
-
52
- def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> None:
53
- assert self.id, "'id' was not set."
54
- addr.customerAddressId = self.id
55
- request = updateCustomerShippingAddressRequest(
56
- merchantAuthentication=self.merchantAuthentication,
57
- customerProfileId=self.customerProfileId,
58
- address=addr,
59
- default=self.default,
60
- )
61
- controller = updateCustomerShippingAddressController(request)
62
- self.execute_controller(controller)
63
-
64
- def _authorizenet_get_shipping_address(self) -> dict:
65
- assert self.id, "'id' was not set."
66
- request = getCustomerShippingAddressRequest(
67
- merchantAuthentication=self.merchantAuthentication,
68
- customerProfileId=self.customerProfileId,
69
- customerAddressId=self.id,
70
- )
71
- controller = getCustomerShippingAddressController(request)
72
- response = self.execute_controller(controller)
73
- return response
74
-
75
- def _authorizenet_delete_shipping_address(self) -> None:
76
- assert self.id, "'id' was not set."
77
- request = deleteCustomerShippingAddressRequest(
78
- merchantAuthentication=self.merchantAuthentication,
79
- customerProfileId=self.customerProfileId,
80
- customerAddressId=self.id,
81
- )
82
- controller = deleteCustomerShippingAddressController(request)
83
- self.execute_controller(controller)
@@ -1,62 +0,0 @@
1
- from authorizenet.apicontractsv1 import merchantAuthenticationType
2
- from ..auth import get_environment, get_merchant_auth, get_validation_mode
3
-
4
-
5
- class AuthorizenetProfileBase:
6
- def __init__(
7
- self, merchant_id: int | str, id: int | str | None = None, **kwargs
8
- ) -> None:
9
- self.merchant_id = merchant_id
10
- self.id = str(id) if id else str(self.create(**kwargs))
11
-
12
- def __str__(self) -> str:
13
- return f"#{self.id}"
14
-
15
- @property
16
- def environment(self) -> str:
17
- return get_environment()
18
-
19
- @property
20
- def merchantAuthentication(self) -> merchantAuthenticationType:
21
- return get_merchant_auth()
22
-
23
- @property
24
- def validationMode(self) -> str:
25
- return get_validation_mode()
26
-
27
- @property
28
- def merchantCustomerId(self) -> str:
29
- return str(self.merchant_id)
30
-
31
- def create(self, **kwargs) -> int:
32
- raise NotImplementedError("Subclasses must implement this method.")
33
-
34
- def execute_controller(self, controller):
35
- controller.setenvironment(self.environment)
36
- controller.execute()
37
- response = controller.getresponse()
38
- if response.messages.resultCode != "Ok":
39
- raise ValueError(response.messages.message[0]["text"].text)
40
- return response
41
-
42
-
43
- class AuthorizenetCustomerProfileBase(AuthorizenetProfileBase):
44
- def __init__(
45
- self, customer_profile_id: int | str, default: bool = False, **kwargs
46
- ) -> None:
47
- if isinstance(customer_profile_id, str) and not customer_profile_id.isdigit():
48
- raise ValueError(
49
- f"'customer_profile_id' must be a digit, got '{customer_profile_id}'."
50
- )
51
-
52
- self._default = default
53
- self.customer_profile_id = customer_profile_id
54
- return super().__init__(**kwargs)
55
-
56
- @property
57
- def customerProfileId(self) -> str:
58
- return str(self.customer_profile_id)
59
-
60
- @property
61
- def default(self) -> str:
62
- return str(self._default).lower()