python-terminusgps 36.4.0__py3-none-any.whl → 36.4.2__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: 36.4.0
3
+ Version: 36.4.2
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
@@ -35,13 +35,13 @@ terminusgps/django/tests/test_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
35
35
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
36
36
  terminusgps/twilio/caller.py,sha256=RQax2iZ6SYHiuCvBxXkrooRWQ9J8DwKGAjxa8RYjrLI,5023
37
37
  terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- terminusgps/wialon/constants.py,sha256=Ju2XL2A4DPFD-w8NjYqEfnnqregl1luPT0XGhGSUnO8,6316
38
+ terminusgps/wialon/constants.py,sha256=05pLc_0S-x0tT87cQcxOmr8plesjOQxoXfUdjIHwI90,7732
39
39
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
40
40
  terminusgps/wialon/session.py,sha256=BN8GBfYNIJcjvev9-qOam2Sbkf7EyCoQXTudRrmA3vc,10533
41
- terminusgps/wialon/utils.py,sha256=SwpcxLPBLy0u3AT84G-Co4wxmhRrPFyW3jo_9O6ICvk,11008
41
+ terminusgps/wialon/utils.py,sha256=iGOY8v7cNaSoA9Mo17d1bKAQMBtcotGq3FEQrghgvCo,11222
42
42
  terminusgps/wialon/validators.py,sha256=j5vrtcfClAzRdRkWTvRRAmrne1t0R6cKkmYdE7fAkSs,4247
43
43
  terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
44
- terminusgps/wialon/items/base.py,sha256=ru1IzdVJiXlwZA8TSB1UtxtS300uK8xY4yBOupeVSwU,10345
44
+ terminusgps/wialon/items/base.py,sha256=ZhndkcVWTOjsEKe5L0NQsLvvXj2Fs0Xv-qBjjm1Xmpk,10421
45
45
  terminusgps/wialon/items/resource.py,sha256=DDnyL_Y5P3DxiirUkQb9y4cokMXZVq3xnfn16Vx8sxk,16992
46
46
  terminusgps/wialon/items/retranslator.py,sha256=sVEWrp8q1I-tO_rMTCH7TeQDDbZryIq8d9KVnhYyhH0,3795
47
47
  terminusgps/wialon/items/route.py,sha256=amNPKZqgl8pEzKA_XJudnvBPzEsfHTmrC7uF15sZVI4,1216
@@ -52,7 +52,7 @@ terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
52
52
  terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
54
54
  terminusgps/wialon/tests/test_utils.py,sha256=SK4PxJQGECFnzx_EQeRAQfsQ5_3FLaVcis2W9u_ibuI,1730
55
- python_terminusgps-36.4.0.dist-info/METADATA,sha256=xoH1ax910P2c01YF2hjEHRF_9fhIxD9psr8G23Nhlzw,1616
56
- python_terminusgps-36.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
- python_terminusgps-36.4.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
58
- python_terminusgps-36.4.0.dist-info/RECORD,,
55
+ python_terminusgps-36.4.2.dist-info/METADATA,sha256=moU-r9iotwr4Sb98T_uEnJa6_VK9DYtkoIL7FCT7fQM,1616
56
+ python_terminusgps-36.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
+ python_terminusgps-36.4.2.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
58
+ python_terminusgps-36.4.2.dist-info/RECORD,,
@@ -4,6 +4,56 @@ from typing import override
4
4
  from . import flags
5
5
 
6
6
 
7
+ class WialonProfileField(enum.StrEnum):
8
+ """
9
+ Valid profile ids for Wialon objects.
10
+
11
+ `Profile field reference <https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/item/update_profile_field>`_.
12
+
13
+ """
14
+
15
+ VEHICLE_CLASS = "vehicle_class"
16
+ """`Vehicle Type <https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/file/type_library>`_."""
17
+ VIN = "vin"
18
+ """Vin number."""
19
+ REGISTRATION_PLATE = "registration_plate"
20
+ """Registration plate."""
21
+ BRAND = "brand"
22
+ """Brand."""
23
+ MODEL = "model"
24
+ """Model."""
25
+ YEAR = "year"
26
+ """Year."""
27
+ COLOR = "color"
28
+ """Color."""
29
+ ENGINE_MODEL = "engine_model"
30
+ """Engine model."""
31
+ ENGINE_POWER = "engine_power"
32
+ """Engine power, in kW."""
33
+ ENGINE_DISPLACEMENT = "engine_displacement"
34
+ """Engine displacement, in cm."""
35
+ PRIMARY_FUEL_TYPE = "primary_fuel_type"
36
+ """Primary fuel type."""
37
+ CARGO_TYPE = "cargo_type"
38
+ """Cargo type."""
39
+ CARRYING_CAPACITY = "carrying_capacity"
40
+ """Carrying capacity, in tons."""
41
+ WIDTH = "width"
42
+ """Width, in mm."""
43
+ HEIGHT = "height"
44
+ """Height, in mm."""
45
+ DEPTH = "depth"
46
+ """Depth, in mm."""
47
+ EFFECTIVE_CAPACITY = "effective_capacity"
48
+ """Effective capacity."""
49
+ GROSS_VEHICLE_WEIGHT = "gross_vehicle_weight"
50
+ """Gross vehicle weight."""
51
+ AXLES = "axles"
52
+ """Axles."""
53
+ VEHICLE_TYPE = "vehicle_type"
54
+ """Comment."""
55
+
56
+
7
57
  class WialonGeofenceType(enum.IntEnum):
8
58
  """
9
59
  A type of Wialon geofence.
@@ -212,12 +212,12 @@ class WialonBase:
212
212
  if field["n"] == key:
213
213
  return int(field["id"])
214
214
 
215
- def update_pfield(self, key: str, value: str) -> None:
215
+ def update_pfield(self, key: constants.WialonProfileField, value: str) -> None:
216
216
  """
217
217
  Updates a profile field by key.
218
218
 
219
219
  :param key: A profile field key (name).
220
- :type key: :py:obj:`str`
220
+ :type key: :py:obj:`~terminusgps.wialon.constants.WialonProfileField`
221
221
  :param value: A string.
222
222
  :type value: :py:obj:`str`
223
223
  :raises WialonError: If something goes wrong with Wialon.
@@ -226,7 +226,7 @@ class WialonBase:
226
226
 
227
227
  """
228
228
  self.session.wialon_api.item_update_profile_field(
229
- **{"itemId": self.id, "n": key, "v": value}
229
+ **{"itemId": self.id, "n": key.value, "v": value}
230
230
  )
231
231
 
232
232
  def update_afield(self, key: str, value: str) -> None:
@@ -204,6 +204,7 @@ def get_unit_by_imei(imei: str, session: WialonSession) -> WialonUnit | None:
204
204
  :param session: A valid Wialon API session.
205
205
  :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
206
206
  :raises ValueError: If ``imei`` contains non-digit characters.
207
+ :raises ValueError: If ``imei`` points to multiple Wialon units.
207
208
  :raises WialonError: If something goes wrong during a Wialon API call.
208
209
  :returns: A Wialon object id, if it was found.
209
210
  :rtype: :py:obj:`str` | :py:obj:`None`
@@ -217,19 +218,21 @@ def get_unit_by_imei(imei: str, session: WialonSession) -> WialonUnit | None:
217
218
  "spec": {
218
219
  "itemsType": "avl_unit",
219
220
  "propName": "sys_unique_id",
220
- "propValueMask": f"*{imei}*",
221
+ "propValueMask": imei,
221
222
  "sortType": "sys_unique_id",
222
223
  "propType": "property",
223
224
  "or_logic": 0,
224
225
  },
225
226
  "force": 0,
226
- "flags": flags.DataFlag.UNIT_BASE.value,
227
+ "flags": flags.DataFlag.UNIT_BASE,
227
228
  "from": 0,
228
229
  "to": 0,
229
230
  }
230
231
  )
231
232
 
232
- if results and results.get("totalItemsCount", 0) == 1:
233
+ if results is not None and results.get("totalItemsCount", 0) != 1:
234
+ raise ValueError(f"Multiple units found with IMEI #: '{imei}'.")
235
+ elif results is not None and results.get("totalItemsCount", 0) == 1:
233
236
  return WialonUnit(id=results["items"][0].get("id"), session=session)
234
237
 
235
238