getrak-python-sdk 1.0.0__tar.gz

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.
@@ -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,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
File without changes
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "getrak-python-sdk"
7
+ version = "1.0.0"
8
+ description = "Client de comunicaçao c/ API da Getrak"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Filipe Coelho", email = "filipe@fmconsult.com.br"},
14
+ ]
15
+ keywords = ["sdk", "api", "getrak", "fmconsult"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ dependencies = []
23
+
24
+ [project.urls]
25
+ "Homepage" = "https://github.com/seuuser/minha-biblioteca"
26
+ "Bug Tracker" = "https://github.com/seuuser/minha-biblioteca/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes
@@ -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)
@@ -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,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/__init__.py
5
+ src/getrak/__init__.py
6
+ src/getrak/api.py
7
+ src/getrak/apis/__init__.py
8
+ src/getrak/apis/localizacoes.py
9
+ src/getrak/apis/recebidos.py
10
+ src/getrak/database/__init__.py
11
+ src/getrak/database/models/__init__.py
12
+ src/getrak/database/models/dataexplained.py
13
+ src/getrak/database/models/vehicle.py
14
+ src/getrak_python_sdk.egg-info/PKG-INFO
15
+ src/getrak_python_sdk.egg-info/SOURCES.txt
16
+ src/getrak_python_sdk.egg-info/dependency_links.txt
17
+ src/getrak_python_sdk.egg-info/top_level.txt