python-terminusgps 20.6.2__py3-none-any.whl → 20.7.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: 20.6.2
3
+ Version: 20.7.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
@@ -19,17 +19,15 @@ terminusgps/wialon/flags.py,sha256=_NIL3mrEGhvI5YISVjimjYtUatdgOqhZPJX368MtKSU,1
19
19
  terminusgps/wialon/logger.py,sha256=nUBsaLMaffSaAHGHAM6mFXDzix9hbNecVtA3INVtii8,968
20
20
  terminusgps/wialon/session.py,sha256=6xg65LZz6cebWclTQp1KRLvPss0aM-bWhAmmwiDOlMg,10267
21
21
  terminusgps/wialon/utils.py,sha256=IN45hASI6iP3Wd35ejGeoIYDIQ_w65-W05eVUdWFRxo,5712
22
- terminusgps/wialon/items/__init__.py,sha256=cfUC5sfVsTwmpgsR-w9wA4ay6_EZYAPgEeuw2k06RJM,256
22
+ terminusgps/wialon/items/__init__.py,sha256=3BVthghekMvhMQSzQgBMlD_phxmKSmp3Zvmo-z0O8Bs,211
23
23
  terminusgps/wialon/items/base.py,sha256=EAtzlnCvB7WTu3iX1bV1-S9TvwXc-Eez7e0X4TMiK9U,6943
24
- terminusgps/wialon/items/geofence.py,sha256=LOjWWtRpAFMhE_16SU4sqNEZphmswpeTNtiFCZBB5Ig,1740
25
- terminusgps/wialon/items/notification.py,sha256=6IrswN6fdEkJErIqtMq45bTl9xVARQw8nokDsy3x1MA,97
26
- terminusgps/wialon/items/resource.py,sha256=79SwbCyE1zlaoeBfU0erEqvqBAYUC4KAKs8AOLJqflU,9652
24
+ terminusgps/wialon/items/resource.py,sha256=z264-upqaAWjrI7Mv2Ryy8yRy7XQLBR26GCCswLsdx4,13567
27
25
  terminusgps/wialon/items/retranslator.py,sha256=8q9EDc92w92MElnHIeEzH3Ra4kiPXrx4t9V5nPDZuRU,3728
28
26
  terminusgps/wialon/items/route.py,sha256=PTJx1gmT_PGz7nlSSUS2VzjYD-aAuvkEOIdIFneUSSQ,1148
29
- terminusgps/wialon/items/unit.py,sha256=sXgEW3mbGgHCI9-lD69voy8yiKv39rKJei6ybYODKpM,8531
27
+ terminusgps/wialon/items/unit.py,sha256=K5IoGSRoH_JiAZoKK6Wb9DToaDScaL7mPKqSOAwtg0A,8618
30
28
  terminusgps/wialon/items/unit_group.py,sha256=vGVJMBY1BrKK0tP-C1DCIz4Bh6P-HKRnKY1g8g95UIs,5031
31
29
  terminusgps/wialon/items/user.py,sha256=INwAibQVmjNNelepQXMfDevgJqMvIjHHgEjAMLRvhB0,7082
32
- python_terminusgps-20.6.2.dist-info/METADATA,sha256=zWNeCwUyy0L3XVwB8vizM3tACdq1P8sO8OmQBPEDFlE,912
33
- python_terminusgps-20.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
- python_terminusgps-20.6.2.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
35
- python_terminusgps-20.6.2.dist-info/RECORD,,
30
+ python_terminusgps-20.7.0.dist-info/METADATA,sha256=_VCihk48_Dh60rQSGjKm-PP6A26obKdUENWPQCij17E,912
31
+ python_terminusgps-20.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
+ python_terminusgps-20.7.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
33
+ python_terminusgps-20.7.0.dist-info/RECORD,,
@@ -1,4 +1,3 @@
1
- from .notification import WialonNotification
2
1
  from .resource import WialonResource
3
2
  from .retranslator import WialonRetranslator
4
3
  from .route import WialonRoute
@@ -1,9 +1,13 @@
1
+ from urllib.parse import quote_plus
2
+
1
3
  from terminusgps.wialon import flags
2
4
  from terminusgps.wialon.items.base import WialonBase
3
5
 
4
6
 
5
7
  class WialonResource(WialonBase):
6
- def create(self, creator_id: str | int, name: str) -> int | None:
8
+ def create(
9
+ self, creator_id: str | int, name: str, skip_creator_check: bool = False
10
+ ) -> int | None:
7
11
  """
8
12
  Creates a new Wialon resource.
9
13
 
@@ -11,6 +15,8 @@ class WialonResource(WialonBase):
11
15
  :type creator_id: :py:obj:`int` | :py:obj:`str`
12
16
  :param name: A name for the resource.
13
17
  :type name: :py:obj:`str`
18
+ :param skip_creator_check: Bypass object creation restrictions while creating the resource.
19
+ :type skip_creator_check: :py:obj:`bool`
14
20
  :raises ValueError: If ``creator_id`` is not a digit.
15
21
  :raises WialonError: If something goes wrong with Wialon.
16
22
  :returns: The Wialon id for the new resource, if it was created.
@@ -25,6 +31,7 @@ class WialonResource(WialonBase):
25
31
  "creatorId": creator_id,
26
32
  "name": name,
27
33
  "dataFlags": flags.DATAFLAG_UNIT_BASE,
34
+ "skipCreatorCheck": int(skip_creator_check),
28
35
  }
29
36
  )
30
37
  return int(response.get("item", {}).get("id")) if response.get("item") else None
@@ -272,3 +279,106 @@ class WialonResource(WialonBase):
272
279
  "denyBalance": deny_balance_val,
273
280
  }
274
281
  )
282
+
283
+ def create_driver(
284
+ self,
285
+ name: str,
286
+ code: str = "",
287
+ desc: str = "",
288
+ phone: str = "",
289
+ mobile_auth_code: str = "",
290
+ image_checksum: str = "",
291
+ image_ratio: str = "",
292
+ custom_fields: dict[str, str] | None = None,
293
+ ) -> None:
294
+ """
295
+ Creates a driver for the resource.
296
+
297
+ :param name: A name for the new driver.
298
+ :type name: :py:obj:`str`
299
+ :param code: A unique code for the new driver.
300
+ :type code: :py:obj:`str`
301
+ :param desc: Description for the driver.
302
+ :type desc: :py:obj:`str`
303
+ :param phone: A phone number beginning in a country code. No spaces.
304
+ :type phone: :py:obj:`str`
305
+ :param mobile_auth_code: Authentication code for Wialon mobile app.
306
+ :type mobile_auth_code: :py:obj:`str`
307
+ :param image_checksum: Checksum for driver image.
308
+ :type image_checksum: :py:obj:`str`
309
+ :param image_ratio: Driver image aspect ratio.
310
+ :type image_ratio: :py:obj:`float` | :py:obj:`None`
311
+ :param custom_fields: Additional custom fields to add to the driver.
312
+ :type custom_fields: :py:obj:`dict` | :py:obj:`None`
313
+ :raises WialonError: If something goes wrong calling the Wialon API.
314
+ :returns: Nothing.
315
+ :rtype: :py:obj:`None`
316
+
317
+ """
318
+ params = {
319
+ "itemId": self.id,
320
+ "id": 0,
321
+ "callMode": "create",
322
+ "ej": {"apps": []},
323
+ "c": code,
324
+ "ds": desc,
325
+ "n": name,
326
+ "f": 1,
327
+ "pwd": mobile_auth_code,
328
+ }
329
+
330
+ if phone:
331
+ params.update({"p": quote_plus(phone)})
332
+ if custom_fields:
333
+ params.update({"jp": custom_fields})
334
+ response = self.session.wialon_api.resource_update_driver(**params)
335
+ print(f"{response = }")
336
+
337
+ def create_passenger(
338
+ self,
339
+ name: str,
340
+ code: str,
341
+ phone: str = "",
342
+ timezone: int | None = None,
343
+ image_checksum: str = "",
344
+ image_ratio: float | None = None,
345
+ custom_fields: dict[str, str] | None = None,
346
+ ) -> None:
347
+ """
348
+ Creates a passenger/tag for the resource.
349
+
350
+ :param name: A name for the new passenger.
351
+ :type name: :py:obj:`str`
352
+ :param code: A unique code for the new passenger.
353
+ :type code: :py:obj:`str`
354
+ :param phone: A phone number beginning in a country code. No spaces.
355
+ :type phone: :py:obj:`str`
356
+ :param timezone: A timezone integer.
357
+ :type timezone: :py:obj:`int` | :py:obj:`None`
358
+ :param image_checksum: Checksum for passenger image.
359
+ :type image_checksum: :py:obj:`str`
360
+ :param image_ratio: Passenger image aspect ratio.
361
+ :type image_ratio: :py:obj:`float` | :py:obj:`None`
362
+ :param custom_fields: Additional custom fields to add to the passenger.
363
+ :type custom_fields: :py:obj:`dict` | :py:obj:`None`
364
+ :raises WialonError: If something goes wrong calling the Wialon API.
365
+ :returns: Nothing.
366
+ :rtype: :py:obj:`None`
367
+
368
+ """
369
+ params = {
370
+ "itemId": self.id,
371
+ "id": 0,
372
+ "callMode": "create",
373
+ "c": code,
374
+ "ck": image_checksum,
375
+ "r": image_ratio,
376
+ "n": name,
377
+ }
378
+ if phone:
379
+ params.update({"p": quote_plus(phone)})
380
+ if timezone:
381
+ params.update({"tz": timezone})
382
+ if custom_fields:
383
+ params.update({"jp": custom_fields})
384
+ self.session.wialon_api.resource_update_tag(**params)
@@ -199,6 +199,7 @@ class WialonUnit(WialonBase):
199
199
  return list(dict.fromkeys(phone_numbers)) # Removes duplicate phone numbers
200
200
 
201
201
  def clean_phone_numbers(self, phones: list[str]) -> list[str]:
202
+ """Takes a list of phone numbers and returns a list of clean phone numbers."""
202
203
  cleaned_phones = []
203
204
  for num in phones:
204
205
  if "," in num:
@@ -1,60 +0,0 @@
1
- from django.db import models
2
-
3
- from terminusgps.wialon.items.base import WialonBase
4
-
5
-
6
- class WialonGeofence(WialonBase):
7
- def __new__(cls) -> "WialonGeofence":
8
- raise NotImplementedError()
9
-
10
- class WialonGeofenceShape(models.IntegerChoices):
11
- LINE = 1
12
- POLYGON = 2
13
- CIRCLE = 3
14
-
15
- class WialonGeofenceColor(models.IntegerChoices):
16
- RED = int("ff0000", 16)
17
- ORANGE = int("ff7b00", 16)
18
- YELLOW = int("fffb00", 16)
19
- GREEN = int("20ff00", 16)
20
- BLUE = int("0090ff", 16)
21
- PURPLE = int("7000ff", 16)
22
- WHITE = int("f3f3f3", 16)
23
- BLACK = int("030303", 16)
24
-
25
- def create(
26
- self,
27
- resource_id: str | int,
28
- name: str,
29
- xpos: float,
30
- ypos: float,
31
- desc: str | None = None,
32
- shape: int = WialonGeofenceShape.CIRCLE,
33
- width: int = 100,
34
- flags: int = 0x04,
35
- color: int = WialonGeofenceColor.GREEN,
36
- text_color: int = WialonGeofenceColor.BLACK,
37
- text_size: int = 12,
38
- min_zoom: int = 2,
39
- max_zoom: int = 19,
40
- ) -> int | None:
41
- response = self.session.wialon_api.resource_update_zone(
42
- **{
43
- "itemId": resource_id,
44
- "id": 0,
45
- "callMode": "create",
46
- "n": name,
47
- "d": desc if desc else name,
48
- "t": shape,
49
- "w": width,
50
- "f": flags,
51
- "c": color,
52
- "tc": text_color,
53
- "ts": text_size,
54
- "min": min_zoom,
55
- "max": max_zoom,
56
- "p": [{"x": xpos, "y": ypos, "r": width}],
57
- }
58
- )
59
- if response:
60
- return int(response[0])
@@ -1,4 +0,0 @@
1
- from terminusgps.wialon.items.base import WialonBase
2
-
3
-
4
- class WialonNotification(WialonBase): ...