python-terminusgps 41.3.0__py3-none-any.whl → 42.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: 41.3.0
3
+ Version: 42.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
@@ -29,14 +29,14 @@ terminusgps/wialon/validators.py,sha256=o5__H9HHnGYth8QAKErJG5rEub7FnT8ue0S3IQ8b
29
29
  terminusgps/wialon/items/__init__.py,sha256=RTiY9ziXqKCB8VWGoExOIErDlUMBBfzzsA7nlOlCZ2w,41
30
30
  terminusgps/wialon/items/account.py,sha256=OSTTbw-nBFqzL1AnGYQ7-Gaymr-S5wx1a0uDzOFlxCM,7888
31
31
  terminusgps/wialon/items/base.py,sha256=579Dmapm_v8QDJYa0NJhdqSWYR0X6aVx53slD38pltw,8639
32
- terminusgps/wialon/items/factory.py,sha256=a2XNiSsFR0zagYx9gYTNj8LyQMSXsQrv-C4RzTCtSvU,2156
32
+ terminusgps/wialon/items/factory.py,sha256=VoQgbw9r_5qdpKPQ3GPc_DQY_34m3kJPaze8eBk3RKs,2144
33
33
  terminusgps/wialon/items/resource.py,sha256=eW33Jt5gnkeUKXUhf3TIfufgD2IfVc9qmJy8-pF4apA,4516
34
- terminusgps/wialon/items/retranslator.py,sha256=nJvYsvRCyb8hIx2qmUUcXfYeNiBUMW018xnOfv2w-Fg,1753
34
+ terminusgps/wialon/items/retranslator.py,sha256=nxp_SNsd9VBqEJcKOVLF6fxq4XS3gGjBX_Xk9h5zrEc,1850
35
35
  terminusgps/wialon/items/route.py,sha256=xixlex6bUeFHXucVQdbfQUSLxI1Rhwk6slhoFP2odp0,1307
36
- terminusgps/wialon/items/unit.py,sha256=kfiqysdPxiU_8fHomKZEz3Ypbkaoc5HevOzpqr7R7rI,5189
36
+ terminusgps/wialon/items/unit.py,sha256=kIjnMOjjI3siCaA6wXojzEK2xqFIm5mN4xNqzKDUa1Q,5473
37
37
  terminusgps/wialon/items/unit_group.py,sha256=L7-PAVCj8Bf50fa04Ials4VHg8LOWkw6hwNhtSyMksE,2133
38
38
  terminusgps/wialon/items/user.py,sha256=hZlFeXCgOAdivl_Anjp_We6Cy5U8IxWNDAgm5MFZfp0,5194
39
- python_terminusgps-41.3.0.dist-info/METADATA,sha256=9BHo1xTbDTjTZJmo6xJhAyboF8MopV0ILY9ff4U-Dlw,976
40
- python_terminusgps-41.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
- python_terminusgps-41.3.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
42
- python_terminusgps-41.3.0.dist-info/RECORD,,
39
+ python_terminusgps-42.0.0.dist-info/METADATA,sha256=3vJ_3IV5mqPZ6vxw9ZVyLte-UlAQYzREpEE2dYnEhJE,976
40
+ python_terminusgps-42.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ python_terminusgps-42.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
42
+ python_terminusgps-42.0.0.dist-info/RECORD,,
@@ -27,24 +27,27 @@ class WialonObjectFactory:
27
27
  # TODO: Add session refreshing
28
28
  self.session = session
29
29
 
30
- def get(self, id: int | str, items_type: str) -> WialonObject:
31
- """Returns a Wialon object that already exists in Wialon by id."""
32
- if isinstance(id, str) and not id.isdigit():
33
- raise ValueError(f"'id' can only be digits, got '{id}'.")
34
- if items_type not in WIALON_ITEMSTYPE_MAP:
35
- raise ValueError(f"Invalid Wialon items type: '{items_type}'.")
36
- cls = WIALON_ITEMSTYPE_MAP.get(items_type)
37
- if cls is None:
38
- raise ValueError(f"Wialon items type '{items_type}' is not implemented.")
39
- return cls(session=self.session, id=int(id))
40
-
41
30
  def create(self, items_type: str, *args, **kwargs) -> WialonObject:
42
- """Returns a Wialon object after creating it in Wialon."""
43
- if items_type not in WIALON_ITEMSTYPE_MAP:
31
+ """Creates a Wialon object in Wialon and returns its Python equivalent."""
32
+ cls = self._get_wialon_cls(items_type)
33
+ if cls is None:
44
34
  raise ValueError(f"Invalid Wialon items type: '{items_type}'.")
45
- cls = WIALON_ITEMSTYPE_MAP.get(items_type)
35
+ return self._create_wialon_obj(cls, *args, **kwargs)
36
+
37
+ def get(self, items_type: str, id: int | str) -> WialonObject:
38
+ """Retrieves a Wialon object from Wialon and returns its Python equivalent."""
39
+ cls = self._get_wialon_cls(items_type)
46
40
  if cls is None:
47
- raise ValueError(f"Wialon items type '{items_type}' is not implemented.")
41
+ raise ValueError(f"Invalid Wialon items type: '{items_type}'.")
42
+ return self._retrieve_wialon_obj(cls, id)
43
+
44
+ def _get_wialon_cls(self, items_type) -> WialonObject | None:
45
+ return WIALON_ITEMSTYPE_MAP.get(items_type)
46
+
47
+ def _create_wialon_obj(self, cls, *args, **kwargs) -> WialonObject:
48
48
  obj = cls(session=self.session, id=None)
49
49
  obj.create(*args, **kwargs)
50
50
  return obj
51
+
52
+ def _retrieve_wialon_obj(self, cls, id) -> WialonObject:
53
+ return cls(session=self.session, id=int(id))
@@ -3,15 +3,18 @@ from typing import TypedDict
3
3
  from terminusgps.wialon import flags
4
4
  from terminusgps.wialon.items.base import WialonObject
5
5
 
6
-
7
- class WialonRetranslatorConfiguration(TypedDict):
8
- protocol: str
9
- server: str
10
- port: int
11
- auth: str
12
- ssl: int
13
- debug: int
14
- v6type: int
6
+ WialonRetranslatorConfiguration = TypedDict(
7
+ "WialonRetranslatorConfiguration",
8
+ {
9
+ "protocol": str,
10
+ "server": str,
11
+ "port": int,
12
+ "auth": str,
13
+ "ssl": int,
14
+ "debug": int,
15
+ "v6type": int,
16
+ },
17
+ )
15
18
 
16
19
 
17
20
  class WialonRetranslator(WialonObject):
@@ -132,3 +132,13 @@ class WialonUnit(WialonObject):
132
132
  if command_ids is not None
133
133
  else {"itemId": self.id}
134
134
  )
135
+
136
+ @requires_id
137
+ def get_imei(self) -> str:
138
+ return str(
139
+ self.session.wialon_api.core_search_item(
140
+ **{"id": self.id, "flags": flags.DataFlag.UNIT_ADVANCED_PROPERTIES}
141
+ )
142
+ .get("item", {})
143
+ .get("uid")
144
+ )