python-terminusgps 28.0.0__py3-none-any.whl → 28.1.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: 28.0.0
3
+ Version: 28.1.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
@@ -4,13 +4,12 @@ terminusgps/authorizenet/__init__.py,sha256=LiGLlWNNiqS7RSOP4Apabx-b9EBYyNbxRY_a
4
4
  terminusgps/authorizenet/auth.py,sha256=ICxPPzoUc64VbsIIemEWKrn8xjHGwbNdo2VbtaFCFss,1107
5
5
  terminusgps/authorizenet/errors.py,sha256=HG5NwVxQCtOYidVl30y49PC0Ovw5VYdsy9wTgUFMw9M,949
6
6
  terminusgps/authorizenet/utils.py,sha256=RQ_R9YEoNGYQNV7vePmNxbYyhf_DImumATyROckX66I,2770
7
- terminusgps/authorizenet/profiles/__init__.py,sha256=QKjMKcXpCSCEhv6LBCz0yGP8t0VxAyKyYRS4_HLYnxQ,114
7
+ terminusgps/authorizenet/profiles/__init__.py,sha256=IG4XCEEYtHKqXOatlZlob6J3ukAgF7cFR-RXxOSMS1c,161
8
8
  terminusgps/authorizenet/profiles/addresses.py,sha256=7yrOrb9kIsiiazgWbeH8v_YUBiWG3Y61g46R3S5DD-k,6592
9
9
  terminusgps/authorizenet/profiles/base.py,sha256=TOUHr22QRQBLErdysOkfcpJBusTjrUTqOmWEyNvMacA,2240
10
10
  terminusgps/authorizenet/profiles/customers.py,sha256=-F8IsQEn2CyHpfxyVZjKayHSuVe4ENNUj_ck7SE8LO0,8568
11
11
  terminusgps/authorizenet/profiles/payments.py,sha256=ohhZrs9MB7GkCi7jQvPVvELNKnR9BwzMd607jJmT4n4,11316
12
- terminusgps/authorizenet/subscriptions/__init__.py,sha256=OqRean82wOsuvnV3iadVxJhWt0nvspEvWPOg9sUJ4AA,40
13
- terminusgps/authorizenet/subscriptions/subscriptions.py,sha256=rZQXbs4wCj9EIuAfywKpE-jYQhfkXxNEvfcaH13YITY,8673
12
+ terminusgps/authorizenet/profiles/subscriptions.py,sha256=10Jlt19k-4c2GkG7lfKcRnYk0KUKZsSCgxpdDQQ5RHw,12426
14
13
  terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
14
  terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
16
15
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
@@ -30,7 +29,7 @@ terminusgps/wialon/items/route.py,sha256=8SzlqNmpYVdt-ZAY--B_KHoDIHgN0Zb7KBsBWAz
30
29
  terminusgps/wialon/items/unit.py,sha256=i7sQiRu3N0XxyTHVN2RnmjYy9X48KdnZLSB18ic37w8,9363
31
30
  terminusgps/wialon/items/unit_group.py,sha256=YsYh34l2DjSKcv5SIZkEVi5FSjveGB1gxU2fwdLyvl4,4101
32
31
  terminusgps/wialon/items/user.py,sha256=PFYBie04F16YE2B5364PLxkmlTmQr4sZXpItvRBxsDc,7143
33
- python_terminusgps-28.0.0.dist-info/METADATA,sha256=s4YUD2ZeFpd0NvqQFwnOdgfXmdi3ZffXlg3d5D82xhk,946
34
- python_terminusgps-28.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- python_terminusgps-28.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
36
- python_terminusgps-28.0.0.dist-info/RECORD,,
32
+ python_terminusgps-28.1.0.dist-info/METADATA,sha256=kEqWCNoPiDseRB3diJNYEnRlLq1cLagusBQTkPtezHc,946
33
+ python_terminusgps-28.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
+ python_terminusgps-28.1.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
35
+ python_terminusgps-28.1.0.dist-info/RECORD,,
@@ -1,3 +1,4 @@
1
1
  from .addresses import AddressProfile
2
2
  from .customers import CustomerProfile
3
3
  from .payments import PaymentProfile
4
+ from .subscriptions import SubscriptionProfile
@@ -6,7 +6,9 @@ from ..auth import get_merchant_auth
6
6
  from ..utils import ControllerExecutionMixin
7
7
 
8
8
 
9
- class Subscription(ControllerExecutionMixin):
9
+ class SubscriptionProfile(ControllerExecutionMixin):
10
+ """An Authorizenet subscription profile."""
11
+
10
12
  def __init__(self, id: str | int | None = None, *args, **kwargs) -> None:
11
13
  if id and isinstance(id, str) and not id.isdigit():
12
14
  raise ValueError(f"'id' must be a digit, got '{id}'.")
@@ -57,9 +59,8 @@ class Subscription(ControllerExecutionMixin):
57
59
  if isinstance(address_id, str) and not address_id.isdigit():
58
60
  raise ValueError(f"'address_id' must be a digit, got '{address_id}'.")
59
61
 
60
- request = apicontractsv1.ARBCreateSubscriptionRequest(
61
- merchantAuthentication=self.merchantAuthentication,
62
- subscription=apicontractsv1.ARBSubscriptionType(
62
+ subscription: apicontractsv1.ARBSubscriptionType = (
63
+ apicontractsv1.ARBSubscriptionType(
63
64
  name=name,
64
65
  paymentSchedule=schedule,
65
66
  amount=amount,
@@ -69,10 +70,9 @@ class Subscription(ControllerExecutionMixin):
69
70
  customerPaymentProfileId=str(payment_id),
70
71
  customerAddressId=str(address_id),
71
72
  ),
72
- ),
73
+ )
73
74
  )
74
- controller = apicontrollers.ARBCreateSubscriptionController(request)
75
- response = self.execute_controller(controller)
75
+ response = self._authorizenet_create_subscription(subscription)
76
76
  if response is None:
77
77
  raise ValueError("Failed to retrieve Authorizenet API response.")
78
78
  return int(response.subscriptionId)
@@ -89,6 +89,66 @@ class Subscription(ControllerExecutionMixin):
89
89
  """
90
90
  self._authorizenet_cancel_subscription()
91
91
 
92
+ def update(
93
+ self,
94
+ name: str,
95
+ amount: decimal.Decimal,
96
+ schedule: apicontractsv1.paymentScheduleType,
97
+ profile_id: int | str,
98
+ payment_id: int | str,
99
+ address_id: int | str,
100
+ trial_amount: decimal.Decimal = decimal.Decimal(
101
+ 0.00, context=decimal.Context(prec=2, rounding=decimal.ROUND_HALF_UP)
102
+ ),
103
+ ) -> None:
104
+ """
105
+ Updates a subscription in Authorizenet.
106
+
107
+ :param name: A name for the subscription.
108
+ :type name: :py:obj:`str`
109
+ :param amount: An amount of money paid per occurrence of the subscription.
110
+ :type amount: :py:obj:`~decimal.Decimal`
111
+ :param schedule: A payment schedule for the subscription.
112
+ :type amount: :py:obj:`~authorizenet.apicontractsv1.paymentScheduleType`
113
+ :param profile_id: An Authoriznet customer profile id.
114
+ :type profile_id: :py:obj:`int` | :py:obj:`str`
115
+ :param payment_id: An Authoriznet customer payment profile id.
116
+ :type payment_id: :py:obj:`int` | :py:obj:`str`
117
+ :param address_id: An Authoriznet customer address profile id.
118
+ :type address_id: :py:obj:`int` | :py:obj:`str`
119
+ :param trial_amount: Trial amount for the subscription. Default is ``0.00``.
120
+ :type trial_amount: :py:obj:`~decimal.Decimal`
121
+ :raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
122
+ :raises ValueError: If ``profile_id`` wasn't a digit.
123
+ :raises ValueError: If ``payment_id`` wasn't a digit.
124
+ :raises ValueError: If ``address_id`` wasn't a digit.
125
+ :raises ValueError: If the Authorizenet API response was not retrieved.
126
+ :returns: An Authorizenet subscription id.
127
+ :rtype: :py:obj:`int`
128
+
129
+ """
130
+ if isinstance(profile_id, str) and not profile_id.isdigit():
131
+ raise ValueError(f"'profile_id' must be a digit, got '{profile_id}'.")
132
+ if isinstance(payment_id, str) and not payment_id.isdigit():
133
+ raise ValueError(f"'payment_id' must be a digit, got '{payment_id}'.")
134
+ if isinstance(address_id, str) and not address_id.isdigit():
135
+ raise ValueError(f"'address_id' must be a digit, got '{address_id}'.")
136
+
137
+ subscription: apicontractsv1.ARBSubscriptionType = (
138
+ apicontractsv1.ARBSubscriptionType(
139
+ name=name,
140
+ paymentSchedule=schedule,
141
+ amount=amount,
142
+ trialAmount=trial_amount,
143
+ profile=apicontractsv1.customerProfileIdType(
144
+ customerProfileId=str(profile_id),
145
+ customerPaymentProfileId=str(payment_id),
146
+ customerAddressId=str(address_id),
147
+ ),
148
+ )
149
+ )
150
+ self._authorizenet_update_subscription(subscription)
151
+
92
152
  @property
93
153
  def merchantAuthentication(self) -> apicontractsv1.merchantAuthenticationType:
94
154
  """Merchant authentication for API calls."""
@@ -106,6 +166,27 @@ class Subscription(ControllerExecutionMixin):
106
166
  response = self._authorizenet_get_subscription(include_transactions=True)
107
167
  return response.arbTransactions.getchildren() if response else None
108
168
 
169
+ def _authorizenet_create_subscription(
170
+ self, subscription: apicontractsv1.ARBSubscriptionType
171
+ ) -> dict | None:
172
+ """
173
+ Executes a :py:obj:`~authorizenet.apicontractsv1.ARBCreateSubscriptionRequest` using the Authorizenet API.
174
+
175
+ `ARBCreateSubscriptionRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-create-a-subscription-from-customer-profile>`_
176
+
177
+ :raises AssertionError: If :py:attr:`id` wasn't set.
178
+ :raises ControllerExecutionError: If something goes wrong during an Authorizenet API call.
179
+ :returns: An Authorizenet API response, if any.
180
+ :rtype: :py:obj:`dict` | :py:obj:`None`
181
+
182
+ """
183
+ request = apicontractsv1.ARBCreateSubscriptionRequest(
184
+ merchantAuthentication=self.merchantAuthentication,
185
+ subscription=subscription,
186
+ )
187
+ controller = apicontrollers.ARBCreateSubscriptionController(request)
188
+ return self.execute_controller(controller)
189
+
109
190
  def _authorizenet_get_subscription(
110
191
  self, include_transactions: bool = False
111
192
  ) -> dict | None:
@@ -1 +0,0 @@
1
- from .subscriptions import Subscription