python-terminusgps 31.8.1__py3-none-any.whl → 32.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of python-terminusgps might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 31.8.1
3
+ Version: 32.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://docs.terminusgps.com
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -2,11 +2,11 @@ terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  terminusgps/authorizenet/auth.py,sha256=umNpOXObDrIt2K40padWBedQl7tVAmEg2alBWhGk-qQ,1238
4
4
  terminusgps/authorizenet/errors.py,sha256=HG5NwVxQCtOYidVl30y49PC0Ovw5VYdsy9wTgUFMw9M,949
5
- terminusgps/authorizenet/utils.py,sha256=253SeY0CSYlcxsXUmjNJ4X-FgtFTdO3N1XAytAtb_R0,3970
5
+ terminusgps/authorizenet/utils.py,sha256=T0ufuNiBgn54VS07qJRJHf7pmapA3sFLSiSGe_nfUog,2802
6
6
  terminusgps/authorizenet/profiles/__init__.py,sha256=IG4XCEEYtHKqXOatlZlob6J3ukAgF7cFR-RXxOSMS1c,161
7
7
  terminusgps/authorizenet/profiles/addresses.py,sha256=7yrOrb9kIsiiazgWbeH8v_YUBiWG3Y61g46R3S5DD-k,6592
8
8
  terminusgps/authorizenet/profiles/base.py,sha256=TOUHr22QRQBLErdysOkfcpJBusTjrUTqOmWEyNvMacA,2240
9
- terminusgps/authorizenet/profiles/customers.py,sha256=RlvSDuBNmtotu1WD24fQEktiBKyqKiTkGaBgoS2_V84,8851
9
+ terminusgps/authorizenet/profiles/customers.py,sha256=EkgYUmTt42nhDbIykvDdO5yDLbZra2hm1wimF9YMsKg,9832
10
10
  terminusgps/authorizenet/profiles/payments.py,sha256=ohhZrs9MB7GkCi7jQvPVvELNKnR9BwzMd607jJmT4n4,11316
11
11
  terminusgps/authorizenet/profiles/subscriptions.py,sha256=N4_0kbBBJ0FtKdIydN8FLnAG2kSI9DHQWAwemMt7Qu8,11020
12
12
  terminusgps/authorizenet/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,7 +45,7 @@ terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
45
45
  terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
47
47
  terminusgps/wialon/tests/test_utils.py,sha256=SK4PxJQGECFnzx_EQeRAQfsQ5_3FLaVcis2W9u_ibuI,1730
48
- python_terminusgps-31.8.1.dist-info/METADATA,sha256=SAIylvokXcWj7ZD4knARCl2FwzCI1-VVxKDzcj5SIRw,1581
49
- python_terminusgps-31.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
- python_terminusgps-31.8.1.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
- python_terminusgps-31.8.1.dist-info/RECORD,,
48
+ python_terminusgps-32.0.0.dist-info/METADATA,sha256=v9Izrqd4pgBliL_jgwpnjN2iAg9Mj70Vxra2zeHXhtI,1581
49
+ python_terminusgps-32.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
50
+ python_terminusgps-32.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
+ python_terminusgps-32.0.0.dist-info/RECORD,,
@@ -8,10 +8,24 @@ from .base import AuthorizenetProfileBase
8
8
  class CustomerProfile(AuthorizenetProfileBase):
9
9
  """An Authorizenet customer profile."""
10
10
 
11
- def __init__(self, *args, **kwargs) -> None:
12
- super().__init__(*args, **kwargs)
11
+ def __init__(
12
+ self, merchant_id: int | str, id: int | str | None = None, *args, **kwargs
13
+ ) -> None:
13
14
  self._email = None
14
15
  self._desc = None
16
+ try:
17
+ response = self._authorizenet_get_customer_profile(
18
+ merchant_id=int(merchant_id), issuer_info=False
19
+ )
20
+ id = (
21
+ int(response.profile.customerProfileId)
22
+ if response is not None
23
+ else None
24
+ )
25
+ except ControllerExecutionError:
26
+ id = None
27
+ finally:
28
+ super().__init__(merchant_id, id, *args, **kwargs)
15
29
 
16
30
  def create(self, email: str, desc: str = "") -> int:
17
31
  """
@@ -73,7 +87,7 @@ class CustomerProfile(AuthorizenetProfileBase):
73
87
  int(profile.customerPaymentProfileId)
74
88
  for profile in response.profile.paymentProfiles
75
89
  ]
76
- except (ControllerExecutionError, AttributeError):
90
+ except ControllerExecutionError:
77
91
  return []
78
92
 
79
93
  @property
@@ -85,7 +99,7 @@ class CustomerProfile(AuthorizenetProfileBase):
85
99
  int(profile.customerAddressId)
86
100
  for profile in response.profile.shipToList
87
101
  ]
88
- except (ControllerExecutionError, AttributeError):
102
+ except ControllerExecutionError:
89
103
  return []
90
104
 
91
105
  @property
@@ -95,6 +109,12 @@ class CustomerProfile(AuthorizenetProfileBase):
95
109
  self._email = response.profile.email if response else None
96
110
  return self._email
97
111
 
112
+ @property
113
+ def exists(self) -> bool:
114
+ return bool(
115
+ self._authorizenet_get_customer_profile(merchant_id=self.merchantCustomerId)
116
+ )
117
+
98
118
  def _authorizenet_get_customer_profile_ids(self) -> dict | None:
99
119
  """
100
120
  Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileIdsRequest` using the Authorizenet API.
@@ -141,28 +161,34 @@ class CustomerProfile(AuthorizenetProfileBase):
141
161
  return self.execute_controller(controller)
142
162
 
143
163
  def _authorizenet_get_customer_profile(
144
- self, issuer_info: bool = True
164
+ self, merchant_id: int | None = None, issuer_info: bool = True
145
165
  ) -> dict | None:
146
166
  """
147
167
  Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileRequest` using the Authorizenet API.
148
168
 
149
169
  `getCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile>`_
150
170
 
171
+ :param merchant_id: An optional customer merchant id.
172
+ :type merchant_id: :py:obj:`int` | :py:obj:`None`
151
173
  :param issuer_info: Whether or not to include issuer info in the response.
152
174
  :type issuer_info: :py:obj:`bool`
153
- :raises AssertionError: If :py:attr:`id` was not set.
154
175
  :raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
155
176
  :returns: An Authorizenet API response, if any.
156
177
  :rtype: :py:obj:`dict` | :py:obj:`None`
157
178
 
158
179
  """
159
- assert self.id, "'id' was not set."
160
-
161
- request = apicontractsv1.getCustomerProfileRequest(
162
- merchantAuthentication=self.merchantAuthentication,
163
- customerProfileId=self.id,
164
- includeIssuerInfo=str(issuer_info).lower(),
165
- )
180
+ if merchant_id is not None:
181
+ request = apicontractsv1.getCustomerProfileRequest(
182
+ merchantAuthentication=self.merchantAuthentication,
183
+ merchantCustomerId=str(merchant_id),
184
+ includeIssuerInfo=str(issuer_info).lower(),
185
+ )
186
+ else:
187
+ request = apicontractsv1.getCustomerProfileRequest(
188
+ merchantAuthentication=self.merchantAuthentication,
189
+ customerProfileId=self.id,
190
+ includeIssuerInfo=str(issuer_info).lower(),
191
+ )
166
192
  controller = apicontrollers.getCustomerProfileController(request)
167
193
  return self.execute_controller(controller)
168
194
 
@@ -56,37 +56,6 @@ def get_customer_profile_ids() -> list[int]:
56
56
  return [int(id) for id in response.ids.getchildren()]
57
57
 
58
58
 
59
- def get_customer_profile_id(email: str) -> int | None:
60
- """
61
- Retrieves an Authorizenet customer profile id by email address.
62
-
63
- :param email: A customer email address.
64
- :type email: :py:obj:`str`
65
- :raises ControllerExecutionError: If something goes wrong with the Authorizenet API.
66
- :returns: A customer profile id, if found.
67
- :rtype: :py:obj:`int` | :py:obj:`None`
68
-
69
- """
70
- request = apicontractsv1.getCustomerProfileRequest(
71
- merchantAuthentication=get_merchant_auth(), email=email, includeIssuerInfo=False
72
- )
73
- controller = apicontrollers.getCustomerProfileController(request)
74
- controller.setenvironment(get_environment())
75
- controller.execute()
76
- response = controller.getresponse()
77
-
78
- if response is not None and response.messages.resultCode != "Ok":
79
- if response.messages.message[0]["code"].text == "E00040":
80
- return # Record not found
81
-
82
- raise ControllerExecutionError(
83
- message=response.messages.message[0]["text"].text,
84
- code=response.messages.message[0]["code"].text,
85
- )
86
- elif response is not None:
87
- return int(response.profile.customerProfileId)
88
-
89
-
90
59
  def generate_customer_address(form: forms.Form) -> apicontractsv1.customerAddressType:
91
60
  """Takes a form and returns a :py:obj:`~authorizenet.apicontractsv1.customerAddressType`."""
92
61
  address: apicontractsv1.customerAddressType = form.cleaned_data["address"]