getrak-python-sdk 1.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.
__init__.py ADDED
File without changes
getrak/__init__.py ADDED
File without changes
getrak/api.py ADDED
@@ -0,0 +1,46 @@
1
+ import logging, os, jsonpickle
2
+ from http import HTTPMethod
3
+ from fmconsult.http.api import ApiBase
4
+ from fmconsult.utils.url import UrlUtil
5
+
6
+ class GetrakApi(ApiBase):
7
+
8
+ def __init__(self):
9
+ try:
10
+ self.api_auth_code = os.environ['getrak.api.auth_code']
11
+ self.api_login = os.environ['getrak.api.login']
12
+ self.api_password = os.environ['getrak.api.password']
13
+ self.api_grant_type = os.environ['getrak.api.grant_type']
14
+
15
+ self.base_url = 'https://api.getrak.com'
16
+ self.headers = {
17
+ 'Authorization': f'Basic {self.api_auth_code}'
18
+ }
19
+
20
+ self.__login()
21
+ except:
22
+ raise
23
+
24
+ def __login(self):
25
+ try:
26
+ logging.info('api authentication...')
27
+ res = self.call_request(
28
+ http_method=HTTPMethod.POST,
29
+ request_url=UrlUtil().make_url(self.base_url, ['newkoauth','oauth','token']),
30
+ params={
31
+ 'username': self.api_login,
32
+ 'password': self.api_password,
33
+ 'grant_type': self.api_grant_type
34
+ }
35
+ )
36
+ res = jsonpickle.decode(res)
37
+ if not('error' in res):
38
+ self.token_type = res['token_type']
39
+ self.access_token = res['access_token']
40
+ self.headers = {
41
+ 'Authorization': f'{self.token_type} {self.access_token}'
42
+ }
43
+ else:
44
+ raise Exception(res['error_description'])
45
+ except:
46
+ raise
File without changes
@@ -0,0 +1,27 @@
1
+ import logging, jsonpickle
2
+ from http import HTTPMethod
3
+ from fmconsult.utils.url import UrlUtil
4
+ from getrak.api import GetrakApi
5
+
6
+ class Localizacoes(GetrakApi):
7
+
8
+ def get(self, id_veiculo=None, id_modulo=None):
9
+ logging.info('get vehicles locations...')
10
+
11
+ params = { }
12
+
13
+ if not(id_veiculo is None):
14
+ params['id'] = id_veiculo
15
+
16
+ if not(id_modulo is None):
17
+ params['modulo'] = id_modulo
18
+
19
+ res = self.call_request(
20
+ http_method=HTTPMethod.GET,
21
+ request_url=UrlUtil().make_url(self.base_url, ['v0.1','localizacoes']),
22
+ params=params
23
+ )
24
+
25
+ res = jsonpickle.decode(res)
26
+
27
+ return res['veiculos']
@@ -0,0 +1,14 @@
1
+ import logging, jsonpickle
2
+ from http import HTTPMethod
3
+ from fmconsult.utils.url import UrlUtil
4
+ from getrak.api import GetrakApi
5
+
6
+ class Recebidos(GetrakApi):
7
+
8
+ def get(self, id_veiculo, data_inicio, data_fim):
9
+ logging.info(f'get vehicle {id_veiculo} records from {data_inicio} to {data_fim}...')
10
+ res = self.call_request(
11
+ http_method=HTTPMethod.GET,
12
+ request_url=UrlUtil().make_url(self.base_url, ['v0.1','recebidos', id_veiculo, data_inicio, data_fim])
13
+ )
14
+ return jsonpickle.decode(res)
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ from mongoengine import *
3
+ from mongoengine.fields import DateTimeField
4
+
5
+ class DataExplained(EmbeddedDocument):
6
+ date = DateTimeField()
7
+ timezone = StringField()
8
+ timezone_type = IntField()
@@ -0,0 +1,100 @@
1
+ # -*- coding: utf-8 -*-
2
+ import json
3
+ from mongoengine import *
4
+ from mongoengine.fields import DateTimeField, EmbeddedDocumentField, FloatField, IntField, StringField, ListField
5
+ from fmconsult.database.models.base import CustomBaseDocument
6
+ from .dataexplained import DataExplained
7
+
8
+ class Vehicle(CustomBaseDocument):
9
+ meta = {'collection': 'vehicles'}
10
+
11
+ ano = StringField()
12
+ anomodelo = StringField()
13
+ apelido = StringField()
14
+ apn = StringField()
15
+ celmodulo = StringField()
16
+ chassi = StringField()
17
+ cliente_celular = StringField()
18
+ cliente_id = IntField()
19
+ cliente_nome = StringField()
20
+ cliente_telefone = StringField()
21
+ color = StringField()
22
+ contato = StringField()
23
+ cor = StringField()
24
+ data = DateTimeField()
25
+ dataServidor = EmbeddedDocumentField(DataExplained)
26
+ datastatus = EmbeddedDocumentField(DataExplained)
27
+ equipamento = StringField()
28
+ fix = IntField()
29
+ hodometro = IntField()
30
+ horimetro = IntField()
31
+ ico_veiculo = ListField(StringField())
32
+ icone = StringField()
33
+ id_veiculo = IntField(unique=True)
34
+ lat = FloatField()
35
+ latencia = FloatField()
36
+ lig = IntField()
37
+ lng = FloatField()
38
+ lon = FloatField()
39
+ marca = StringField()
40
+ modelo = StringField()
41
+ modulo = StringField()
42
+ num_chip = StringField()
43
+ operadora = StringField()
44
+ placa = StringField()
45
+ status_online = IntField()
46
+ subcliente_id = IntField()
47
+ subcliente_nome = StringField()
48
+ telcontato = StringField()
49
+ tipo = StringField()
50
+ vel = IntField()
51
+ velocidade = IntField()
52
+
53
+ def to_dict(self):
54
+ json_string = {
55
+ "id_veiculo": self.id_veiculo,
56
+ "ano": self.ano,
57
+ "anomodelo": self.anomodelo,
58
+ "apelido": self.apelido,
59
+ "apn": self.apn,
60
+ "celmodulo": self.celmodulo,
61
+ "chassi": self.chassi,
62
+ "cliente_celular": self.cliente_celular,
63
+ "cliente_id": self.cliente_id,
64
+ "cliente_nome": self.cliente_nome,
65
+ "cliente_telefone": self.cliente_telefone,
66
+ "color": self.color,
67
+ "contato": self.contato,
68
+ "cor": self.cor,
69
+ "data": self.data.isoformat(),
70
+ "dataServidor": self.dataServidor.to_mongo(),
71
+ "datastatus": self.datastatus.to_mongo(),
72
+ "equipamento": self.equipamento,
73
+ "fix": self.fix,
74
+ "hodometro": self.hodometro,
75
+ "horimetro": self.horimetro,
76
+ "ico_veiculo": self.ico_veiculo,
77
+ "icone": self.icone,
78
+ "lat": self.lat,
79
+ "latencia": self.latencia,
80
+ "lig": self.lig,
81
+ "lng": self.lng,
82
+ "lon": self.lon,
83
+ "marca": self.marca,
84
+ "modelo": self.modelo,
85
+ "modulo": self.modulo,
86
+ "num_chip": self.num_chip,
87
+ "operadora": self.operadora,
88
+ "placa": self.placa,
89
+ "status_online": self.status_online,
90
+ "subcliente_id": self.subcliente_id,
91
+ "subcliente_nome": self.subcliente_nome,
92
+ "telcontato": self.telcontato,
93
+ "tipo": self.tipo,
94
+ "vel": self.vel,
95
+ "velocidade": self.velocidade,
96
+ "created_at": self.created_at.strftime('%Y-%m-%d %H:%M:%S'),
97
+ "updated_at": self.updated_at.strftime('%Y-%m-%d %H:%M:%S') if not(self.updated_at is None) else None
98
+ }
99
+
100
+ return json.dumps(json_string, default=str)
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: getrak-python-sdk
3
+ Version: 1.0.0
4
+ Summary: Client de comunicaçao c/ API da Getrak
5
+ Author-email: Filipe Coelho <filipe@fmconsult.com.br>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Seu Nome
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy...
11
+
12
+ Project-URL: Homepage, https://github.com/seuuser/minha-biblioteca
13
+ Project-URL: Bug Tracker, https://github.com/seuuser/minha-biblioteca/issues
14
+ Keywords: sdk,api,getrak,fmconsult
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
@@ -0,0 +1,15 @@
1
+ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ getrak/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ getrak/api.py,sha256=IlO0dlqdUjJ3ErfPJhiMmIU-GQs4CU2Tt8VA3nLrz_M,1239
4
+ getrak/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ getrak/apis/localizacoes.py,sha256=UuRqEHRMecUQRdSUVq7gRXLPeKe4IZ0byYFlGbDn-6U,654
6
+ getrak/apis/recebidos.py,sha256=GDwLphfGcYSvFzmYS6oZ7aQVGDTPaSA3nduKOM6KFQw,516
7
+ getrak/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ getrak/database/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ getrak/database/models/dataexplained.py,sha256=9qjXvccphYUVK0LTNvxjMXRzMOsynbMmcYDkaK41Tdo,212
10
+ getrak/database/models/vehicle.py,sha256=04SVD0TVwnF-4bLbMmdN0dKd9KboMa1-KfxkJ8Fwpv8,2941
11
+ getrak_python_sdk-1.0.0.dist-info/licenses/LICENSE,sha256=YZjQnFjzXGFa0D3iCQkNDwGBNuTGJREkRmItGX1B3YM,122
12
+ getrak_python_sdk-1.0.0.dist-info/METADATA,sha256=Ggz2gFc6tasbfOVQMELK9JKlmnmVYhujVmSH8qBY2RY,769
13
+ getrak_python_sdk-1.0.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
14
+ getrak_python_sdk-1.0.0.dist-info/top_level.txt,sha256=LvUv9DvjYEQ08xdxNLM8xrBtFwGphZIKlX1S0KE43oY,16
15
+ getrak_python_sdk-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.7.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Seu Nome
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy...
@@ -0,0 +1,2 @@
1
+ __init__
2
+ getrak