python-terminusgps 30.1.0__py3-none-any.whl → 31.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 30.1.0
3
+ Version: 31.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://app.terminusgps.com/docs/apps/python-terminusgps/index.html
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -1,7 +1,4 @@
1
1
  terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- terminusgps/mixins.py,sha256=jzs_dH_YDmohH86I3uPnN-66C9OPVXaDPVdRHXA6vdk,940
3
- terminusgps/settings.py,sha256=vY5yNjyMu-7Ya0bIPWUvrrSLERtxHGdkfeoY4Ul6cP0,613
4
- terminusgps/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
5
2
  terminusgps/authorizenet/__init__.py,sha256=LiGLlWNNiqS7RSOP4Apabx-b9EBYyNbxRY_a0mvJoaE,466
6
3
  terminusgps/authorizenet/auth.py,sha256=ICxPPzoUc64VbsIIemEWKrn8xjHGwbNdo2VbtaFCFss,1107
7
4
  terminusgps/authorizenet/errors.py,sha256=HG5NwVxQCtOYidVl30y49PC0Ovw5VYdsy9wTgUFMw9M,949
@@ -15,6 +12,10 @@ terminusgps/authorizenet/profiles/subscriptions.py,sha256=N4_0kbBBJ0FtKdIydN8FLn
15
12
  terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
13
  terminusgps/aws/connect.py,sha256=TWf2bVz6LqSNQfVD7FKRn3K71VuLOwBj05Gs-9BsROg,693
17
14
  terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
15
+ terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ terminusgps/django/mixins.py,sha256=jzs_dH_YDmohH86I3uPnN-66C9OPVXaDPVdRHXA6vdk,940
17
+ terminusgps/django/settings.py,sha256=vY5yNjyMu-7Ya0bIPWUvrrSLERtxHGdkfeoY4Ul6cP0,613
18
+ terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
18
19
  terminusgps/twilio/__init__.py,sha256=dYo41F2jft_eHDWSUtSpKGSRG1bewq_qClqilUJZkYM,33
19
20
  terminusgps/twilio/caller.py,sha256=TiQ4f0TDDC35he1M1iSsBM2vutdGriwtV4pc17T--6I,3552
20
21
  terminusgps/twilio/validators.py,sha256=nn7CCBTktNjcln6M4MR0ACxEsClgioSu89LRLgIiBZk,1112
@@ -23,17 +24,17 @@ terminusgps/wialon/constants.py,sha256=-fRrvtQuSAJ6hpBJzp_Xa4GDI4LuQbqZ1z1L_QFzZ
23
24
  terminusgps/wialon/flags.py,sha256=M50EdhxQ8IMnJnU0mrHK7-h8Asc6tvNiTOOfd1dBW6A,12815
24
25
  terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
25
26
  terminusgps/wialon/session.py,sha256=emB0XHJjFObtb6WbttsXZXTeRaPztcbjAV212B_Ssek,9781
26
- terminusgps/wialon/utils.py,sha256=TKUYPs-0-nn-TeeYoARREizOZEBNvbDEzQPxt4kg_6I,9605
27
+ terminusgps/wialon/utils.py,sha256=iRZi4uLk-qqNUXdEIbL-4ibfXh9xvEjXWmdoML9CubQ,10051
27
28
  terminusgps/wialon/validators.py,sha256=NNqMhoXn1M_f4Edm6oD8I7lzzXKZSqyZ6n7fR3obWj8,4241
28
29
  terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
29
- terminusgps/wialon/items/base.py,sha256=99fw7FAHszWkdEzHKbo56z3kQfJJzhPrd6tsANc4fQ8,7986
30
+ terminusgps/wialon/items/base.py,sha256=4TAsmSQ-pw4mqiuL4_clN_Kvplcze4lZwL9oO1p7gkk,8001
30
31
  terminusgps/wialon/items/resource.py,sha256=wfUxACO4OdzT2IdCF9oBmU_7nYiH3Xvs6BripPD5IMI,14622
31
32
  terminusgps/wialon/items/retranslator.py,sha256=sVEWrp8q1I-tO_rMTCH7TeQDDbZryIq8d9KVnhYyhH0,3795
32
33
  terminusgps/wialon/items/route.py,sha256=amNPKZqgl8pEzKA_XJudnvBPzEsfHTmrC7uF15sZVI4,1216
33
34
  terminusgps/wialon/items/unit.py,sha256=ChONjm3wlFSlbNz-yEXziNbbs4LJ70F9-MI2c-p905k,10638
34
35
  terminusgps/wialon/items/unit_group.py,sha256=QV2ZZgICaN3n6W1pFIyMLyNKB6KYBsLyKG64i-qXoOg,4113
35
36
  terminusgps/wialon/items/user.py,sha256=N30wdejdG7LXrgafdKZH74YArGkX3xpZfTucn3m3aqM,7155
36
- python_terminusgps-30.1.0.dist-info/METADATA,sha256=UO4P_9gRSmHL1gV8cKAvDUt3FFEHV5fK1RMbt2JNQCU,1061
37
- python_terminusgps-30.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
- python_terminusgps-30.1.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
39
- python_terminusgps-30.1.0.dist-info/RECORD,,
37
+ python_terminusgps-31.0.0.dist-info/METADATA,sha256=y4fXM6pCMkZ0znIWvVqoAOzitHrjZDbrhSDPIy06qcE,1061
38
+ python_terminusgps-31.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
+ python_terminusgps-31.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
+ python_terminusgps-31.0.0.dist-info/RECORD,,
File without changes
@@ -22,12 +22,12 @@ class WialonBase:
22
22
  return str(self.id)
23
23
 
24
24
  def __repr__(self) -> str:
25
- return f"{type(self).__name__}(id={self.id}, session={self.session})"
25
+ return f"{type(self).__name__}(id={self.id}, session={self.session.id})"
26
26
 
27
27
  def populate(self) -> None:
28
28
  """Retrieves and saves the latest data for the item from Wialon."""
29
29
  response = self.session.wialon_api.core_search_item(
30
- **{"id": str(self.id), "flags": flags.DataFlag.UNIT_BASE.value}
30
+ **{"id": str(self.id), "flags": flags.DataFlag.UNIT_BASE}
31
31
  )
32
32
  if response is not None:
33
33
  item = response.get("item", {})
@@ -109,6 +109,7 @@ class WialonBase:
109
109
  self.session.wialon_api.item_update_name(
110
110
  **{"itemId": self.id, "name": new_name}
111
111
  )
112
+ self._name = new_name
112
113
 
113
114
  def add_afield(self, key: str, value: str) -> None:
114
115
  """
@@ -231,7 +232,7 @@ class WialonBase:
231
232
  def cfields(self) -> dict[str, str]:
232
233
  """Custom fields for the Wialon object."""
233
234
  response = self.session.wialon_api.core_search_item(
234
- **{"id": self.id, "flags": flags.DataFlag.UNIT_CUSTOM_FIELDS.value}
235
+ **{"id": self.id, "flags": flags.DataFlag.UNIT_CUSTOM_FIELDS}
235
236
  )
236
237
  fields = response.get("item", {}).get("flds") if response is not None else {}
237
238
  return {field["n"]: field["v"] for field in fields.values()} if fields else {}
@@ -240,7 +241,7 @@ class WialonBase:
240
241
  def afields(self) -> dict[str, str]:
241
242
  """Admin fields for the Wialon object."""
242
243
  response = self.session.wialon_api.core_search_item(
243
- **{"id": self.id, "flags": flags.DataFlag.UNIT_ADMIN_FIELDS.value}
244
+ **{"id": self.id, "flags": flags.DataFlag.UNIT_ADMIN_FIELDS}
244
245
  )
245
246
  fields = response.get("item", {}).get("aflds") if response is not None else {}
246
247
  return {field["n"]: field["v"] for field in fields.values()} if fields else {}
@@ -3,6 +3,8 @@ import string
3
3
  import typing
4
4
 
5
5
  from terminusgps.wialon import constants, flags
6
+ from terminusgps.wialon.items import WialonUnit
7
+ from terminusgps.wialon.items.resource import WialonResource
6
8
  from terminusgps.wialon.session import WialonSession
7
9
 
8
10
 
@@ -41,15 +43,17 @@ def get_carrier_names(session: WialonSession) -> list[str]:
41
43
  return sorted(list(frozenset(carrier_names)))
42
44
 
43
45
 
44
- def get_units_by_carrier(carrier_name: str, session: WialonSession) -> list[str]:
46
+ def get_units_by_carrier(
47
+ carrier_name: str, session: WialonSession
48
+ ) -> list[WialonUnit] | None:
45
49
  """
46
- Returns a list of all unit ids by telecommunications carrier company name.
50
+ Returns a list of all units by telecommunications carrier company name.
47
51
 
48
52
  :param carrier_name: A telecommunications carrier company name, e.g. ``"US Cell"`` or ``"Conetixx"``.
49
53
  :type carrier_name: :py:obj:`str`
50
54
  :param session: A valid Wialon API session.
51
55
  :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
52
- :returns: A list of unit ids.
56
+ :returns: A list of units, if any were found.
53
57
  :rtype: :py:obj:`list`
54
58
 
55
59
  """
@@ -67,19 +71,23 @@ def get_units_by_carrier(carrier_name: str, session: WialonSession) -> list[str]
67
71
  "to": 0,
68
72
  }
69
73
  )
70
- return [item.get("id") for item in results.get("items", [])]
74
+ if results:
75
+ return [
76
+ WialonUnit(id=item.get("id"), session=session)
77
+ for item in results.get("items", [])
78
+ ]
71
79
 
72
80
 
73
- def get_unit_by_iccid(iccid: str, session: WialonSession) -> int | None:
81
+ def get_unit_by_iccid(iccid: str, session: WialonSession) -> WialonUnit | None:
74
82
  """
75
- Returns a unit id by iccid (SIM card #).
83
+ Returns a unit by iccid (SIM card #).
76
84
 
77
85
  :param iccid: A SIM card #.
78
86
  :type iccid: :py:obj:`str`
79
87
  :param session: A valid Wialon API session.
80
88
  :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
81
- :returns: The unit id, if it was found.
82
- :rtype: :py:obj:`int` | :py:obj:`None`
89
+ :returns: The unit, if it was found.
90
+ :rtype: :py:obj:`~terminusgps.wialon.items.WialonUnit` | :py:obj:`None`
83
91
 
84
92
  """
85
93
  results = session.wialon_api.core_search_items(
@@ -96,17 +104,18 @@ def get_unit_by_iccid(iccid: str, session: WialonSession) -> int | None:
96
104
  "to": 0,
97
105
  }
98
106
  )
99
- return int(results.get("items", [{}])[0].get("id"))
107
+ if results:
108
+ return WialonUnit(id=results.get("items", [{}])[0].get("id"), session=session)
100
109
 
101
110
 
102
- def get_resources(session: WialonSession) -> list[int] | None:
111
+ def get_resources(session: WialonSession) -> list[WialonResource] | None:
103
112
  """
104
- Returns a list of all resource ids in Wialon.
113
+ Returns a list of all resources in Wialon.
105
114
 
106
115
  :param session: A valid Wialon API session.
107
116
  :type session: :py:obj:`~terminusgps.wialon.session.WialonSession`
108
- :returns: A list of account ids.
109
- :rtype: :py:obj:`list`
117
+ :returns: A list of resources, if found.
118
+ :rtype: :py:obj:`list` | :py:obj:`None`
110
119
 
111
120
  """
112
121
  results = session.wialon_api.core_search_items(
@@ -126,7 +135,10 @@ def get_resources(session: WialonSession) -> list[int] | None:
126
135
  }
127
136
  )
128
137
  if results:
129
- return [int(item.get("id")) for item in results.get("items", [])]
138
+ return [
139
+ WialonResource(id=item.get("id"), session=session)
140
+ for item in results.get("items", [])
141
+ ]
130
142
 
131
143
 
132
144
  def get_hw_type_id(name: str, session: WialonSession) -> int | None:
@@ -154,7 +166,7 @@ def get_hw_type_id(name: str, session: WialonSession) -> int | None:
154
166
  return int(hw_types.get(name)) if name in hw_types.keys() else None
155
167
 
156
168
 
157
- def get_unit_by_imei(imei: str, session: WialonSession) -> str | None:
169
+ def get_unit_by_imei(imei: str, session: WialonSession) -> WialonUnit | None:
158
170
  """
159
171
  Takes a Wialon unit's IMEI # and returns its unit id.
160
172
 
@@ -189,7 +201,7 @@ def get_unit_by_imei(imei: str, session: WialonSession) -> str | None:
189
201
  )
190
202
 
191
203
  if results and results.get("totalItemsCount", 0) == 1:
192
- return results["items"][0].get("id")
204
+ return WialonUnit(id=results["items"][0].get("id"), session=session)
193
205
 
194
206
 
195
207
  def get_vin_info(vin_number: str, session: WialonSession) -> dict:
File without changes
File without changes
File without changes