python-terminusgps 31.1.0__py3-none-any.whl → 31.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 31.1.0
3
+ Version: 31.3.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
@@ -26,7 +26,9 @@ Description-Content-Type: text/markdown
26
26
 
27
27
  # python-terminusgps
28
28
 
29
- [python-terminusgps](https://docs.terminusgps.com/) is a collection of Python libraries intended for use by Terminus GPS developers.
29
+ *python-terminusgps* is a collection of Python libraries intended for use by Terminus GPS developers.
30
+
31
+ [Documentation](https://docs.terminusgps.com/)
30
32
 
31
33
  Currently, the following services are streamlined for web development:
32
34
 
@@ -34,3 +36,4 @@ Currently, the following services are streamlined for web development:
34
36
  * [Authorizenet API](https://developer.authorize.net/api/reference/index.html)
35
37
  * [Twilio API](https://www.twilio.com/docs)
36
38
  * [Wialon Remote API](https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/apiref)
39
+
@@ -14,27 +14,27 @@ terminusgps/aws/connect.py,sha256=TWf2bVz6LqSNQfVD7FKRn3K71VuLOwBj05Gs-9BsROg,69
14
14
  terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
15
15
  terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
17
- terminusgps/django/settings.py,sha256=vY5yNjyMu-7Ya0bIPWUvrrSLERtxHGdkfeoY4Ul6cP0,613
17
+ terminusgps/django/settings.py,sha256=cKUpFXH-uYWStvT6vzclczJAKwCGNx_2wY9-fqsbmIs,624
18
18
  terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
19
19
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
20
20
  terminusgps/twilio/caller.py,sha256=Q0wcJ5aaNDGvKfht7ARwPTFdqpFoB81DmZ_K2oZixyA,5077
21
21
  terminusgps/twilio/validators.py,sha256=HWCpzgDXTedofty4Zhrm2OenbgtkzrDUC08B1l15gqc,1112
22
22
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- terminusgps/wialon/constants.py,sha256=-fRrvtQuSAJ6hpBJzp_Xa4GDI4LuQbqZ1z1L_QFzZiE,5609
23
+ terminusgps/wialon/constants.py,sha256=l67mdjTpnU9uA9zb3jKCdPaKEPGCcrN_iN_lm5mK_Pg,5697
24
24
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
25
25
  terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
26
- terminusgps/wialon/session.py,sha256=emB0XHJjFObtb6WbttsXZXTeRaPztcbjAV212B_Ssek,9781
27
- terminusgps/wialon/utils.py,sha256=eRo-NHWEi8zq8mMWFnCs8__iDbkpPvSkCqcsdr13ltI,9953
26
+ terminusgps/wialon/session.py,sha256=21ZRBUnsuK5zhkUHeccQW1lR39A4kQ_0qkLlRT1hsS8,10044
27
+ terminusgps/wialon/utils.py,sha256=JWHZ7VEeo8VNBH67gjOAQk5ITKuPllWDlJ4dVSQ5blA,11002
28
28
  terminusgps/wialon/validators.py,sha256=CVEpFsxqplEcpv4U2ipA6v9y5cSrMKFUXLvze-3vs4U,4223
29
29
  terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
30
- terminusgps/wialon/items/base.py,sha256=y0z3eW_Gz7dlusKHj3T3TH3_nPsx5yGUKuImEJSK10M,10215
30
+ terminusgps/wialon/items/base.py,sha256=7J5B-EPj997GJV7TbZP7pAfjl2G4nTcKmP-RMxmuzoY,10959
31
31
  terminusgps/wialon/items/resource.py,sha256=FmuY0thel8aIThSWKJXur72Sptful3MuwBfIn9bdeaY,14616
32
32
  terminusgps/wialon/items/retranslator.py,sha256=sVEWrp8q1I-tO_rMTCH7TeQDDbZryIq8d9KVnhYyhH0,3795
33
33
  terminusgps/wialon/items/route.py,sha256=amNPKZqgl8pEzKA_XJudnvBPzEsfHTmrC7uF15sZVI4,1216
34
34
  terminusgps/wialon/items/unit.py,sha256=jq4S8EV_yukRTTE8rr2oXpu_9AdXDFYA6-GCjkR6shw,12282
35
35
  terminusgps/wialon/items/unit_group.py,sha256=QV2ZZgICaN3n6W1pFIyMLyNKB6KYBsLyKG64i-qXoOg,4113
36
- terminusgps/wialon/items/user.py,sha256=N30wdejdG7LXrgafdKZH74YArGkX3xpZfTucn3m3aqM,7155
37
- python_terminusgps-31.1.0.dist-info/METADATA,sha256=MIfipx-9aKDFbozGWwy-i6MXtywcZMOk8O968CjS2TQ,1630
38
- python_terminusgps-31.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
- python_terminusgps-31.1.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
- python_terminusgps-31.1.0.dist-info/RECORD,,
36
+ terminusgps/wialon/items/user.py,sha256=5LgwalGO8KS_7psmAVmAlnC0S6SPBDZMOuT5ZqPKRmo,7758
37
+ python_terminusgps-31.3.0.dist-info/METADATA,sha256=n-d09k232ROHl_dbQ-Ky0SyWY-_ajnFxhPVSo9Ta2LY,1648
38
+ python_terminusgps-31.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
+ python_terminusgps-31.3.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
+ python_terminusgps-31.3.0.dist-info/RECORD,,
@@ -1,15 +1,17 @@
1
1
  import os
2
2
  import pathlib
3
3
 
4
- DEBUG = True
5
4
  BASE_DIR = pathlib.Path(__file__).resolve().parent
5
+ DEBUG = True
6
+ SECRET_KEY = "xem*6no%8d9%^qzt2f3x3ar-uq4_+7h9myc$t0!+4%bj5us6f)"
7
+
8
+ # Secrets
9
+ CONNECT_SECRET = os.getenv("CONNECT_SECRET")
6
10
  MERCHANT_AUTH_LOGIN_ID = os.getenv("MERCHANT_AUTH_LOGIN_ID")
7
11
  MERCHANT_AUTH_TRANSACTION_KEY = os.getenv("MERCHANT_AUTH_TRANSACTION_KEY")
8
- SECRET_KEY = "xem*6no%8d9%^qzt2f3x3ar-uq4_+7h9myc$t0!+4%bj5us6f)"
9
12
  TWILIO_FROM_NUMBER = os.getenv("TWILIO_FROM_NUMBER")
10
13
  TWILIO_MESSAGING_SID = os.getenv("TWILIO_MESSAGING_SID")
11
14
  TWILIO_SID = os.getenv("TWILIO_SID")
12
15
  TWILIO_TOKEN = os.getenv("TWILIO_TOKEN")
13
16
  WIALON_ADMIN_ID = os.getenv("WIALON_ADMIN_ID")
14
17
  WIALON_TOKEN = os.getenv("WIALON_TOKEN")
15
- CONNECT_SECRET = os.getenv("CONNECT_SECRET")
@@ -4,6 +4,12 @@ from typing import override
4
4
  from . import flags
5
5
 
6
6
 
7
+ class WialonMeasurementUnit(enum.IntEnum):
8
+ METRIC = 0
9
+ US = 1
10
+ IMPERIAL = 2
11
+
12
+
7
13
  class WialonItemsType(enum.StrEnum):
8
14
  """
9
15
  Wialon item types for Wialon API calls.
@@ -1,7 +1,7 @@
1
1
  from abc import abstractmethod
2
2
  from typing import Type
3
3
 
4
- from terminusgps.wialon import flags
4
+ from terminusgps.wialon import constants, flags
5
5
  from terminusgps.wialon.session import WialonSession
6
6
 
7
7
 
@@ -119,6 +119,26 @@ class WialonBase:
119
119
  """Creates a Wialon object and returns its id."""
120
120
  raise NotImplementedError("Subclasses must implement this method.")
121
121
 
122
+ def set_measurement_unit(
123
+ self,
124
+ unit: constants.WialonMeasurementUnit = constants.WialonMeasurementUnit.US,
125
+ convert: bool = False,
126
+ ) -> None:
127
+ """
128
+ Sets the Wialon object's measurement unit to ``unit``.
129
+
130
+ :param unit: A Wialon measurement unit.
131
+ :type unit: :py:obj:`~terminusgps.constants.WialonMeasurementUnit`
132
+ :param convert: Whether or not to convert the object's measurements before setting the new unit.
133
+ :type convert: :py:obj:`bool`
134
+ :returns: Nothing.
135
+ :rtype: :py:obj:`None`
136
+
137
+ """
138
+ self.session.wialon_api.item_update_measure_units(
139
+ **{"itemId": str(self.id), "type": unit, "flags": int(convert)}
140
+ )
141
+
122
142
  def rename(self, new_name: str) -> None:
123
143
  """
124
144
  Renames the Wialon object to the new name.
@@ -161,6 +161,24 @@ class WialonUser(WialonBase):
161
161
  **{"userId": self.id, "flags": flags, "flagsMask": flags_mask}
162
162
  )
163
163
 
164
+ def reset_password(self, username: str, email: str, url: str) -> None:
165
+ """
166
+ Sends a password reset email for a user to ``email``.
167
+
168
+ :param username: A Wialon user name.
169
+ :type username: :py:obj:`str`
170
+ :param email: A Wialon user email.
171
+ :type email: :py:obj:`str`
172
+ :param url: A password reset URL for the user.
173
+ :type url: :py:obj:`str`
174
+ :returns: Nothing.
175
+ :rtype: :py:obj:`None`
176
+
177
+ """
178
+ self.session.wialon_api.core_reset_password_request(
179
+ **{"user": username, "url": url, "email": email}
180
+ )
181
+
164
182
  def update_password(self, old_password: str, new_password: str) -> None:
165
183
  """
166
184
  Updates the password of the user.
@@ -105,13 +105,26 @@ class WialonSession:
105
105
  return f"{self.__class__}(sid={self.id})"
106
106
 
107
107
  def __enter__(self) -> "WialonSession":
108
- """Logs into the Wialon API using a token set in :py:meth:`__init__`."""
108
+ """
109
+ Logs into the Wialon API using :py:meth:`login`.
110
+
111
+ :raises AssertionError: If the Wialon API token was not set.
112
+ :returns: A valid Wialon API session.
113
+ :rtype: :py:obj:`~terminusgps.wialon.session.WialonSession`
114
+
115
+ """
109
116
  assert self.token, "Wialon API token was not set"
110
117
  self.login(self.token)
111
118
  return self
112
119
 
113
120
  def __exit__(self, exc_type, exc_value, exc_traceback) -> None:
114
- """Logs out of the session by calling :py:meth:`logout`."""
121
+ """
122
+ Logs out of the session by calling :py:meth:`logout`.
123
+
124
+ :returns: Nothing.
125
+ :rtype: :py:obj:`None`
126
+
127
+ """
115
128
  self.logout()
116
129
 
117
130
  @property
@@ -7,6 +7,36 @@ from .items import WialonResource, WialonUnit
7
7
  from .session import WialonSession
8
8
 
9
9
 
10
+ def get_user_by_name(name: str, session: WialonSession) -> WialonUnit | None:
11
+ """
12
+ Returns a Wialon user by name, if it exists.
13
+
14
+ :param name: A Wialon user name.
15
+ :type name: :py:obj:`str`
16
+ :param session: A valid Wialon API session.
17
+ :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
18
+ :returns: A Wialon unit, if any.
19
+ :rtype: :py:obj:`~terminusgps.wialon.items.unit.WialonUnit` | :py:obj:`None`
20
+
21
+ """
22
+ results: dict = session.wialon_api.core_search_items(
23
+ **{
24
+ "spec": {
25
+ "itemsType": constants.WialonItemsType.USER,
26
+ "propName": constants.WialonItemProperty.NAME,
27
+ "propValueMask": name,
28
+ "sortType": constants.WialonItemProperty.NAME,
29
+ },
30
+ "force": 0,
31
+ "flags": flags.DataFlag.USER_BASE,
32
+ "from": 0,
33
+ "to": 0,
34
+ }
35
+ )
36
+ if results and results.get("items", [{}]):
37
+ return WialonUnit(id=results.get("items", [{}])[0].get("id"), session=session)
38
+
39
+
10
40
  def get_carrier_names(session: WialonSession) -> list[str]:
11
41
  """
12
42
  Returns a list of all telecommunication carrier company names present in Wialon.