Feat(Session): Reuse session from our DB and only regenerate it when expired
Reuse MM auth sessions saving them into our DB, and only recomputing them when expired.
Add method regenerate_session_if_expired as decorator for that purpose
In [1]: from api.models.MM_session import MMSession
In [2]: from api.asset import Asset
In [3]: MMSession.objects.last() # Empty
In [4]: asset_service = Asset("12345", "change_tariff")
In [5]: asset_service.session
Out[5]: <pymasmovil.models.session.Session at 0x7f65922eaf10>
In [6]: MMSession.objects.last().token == asset_service.session.session_id # Not Empty
Out[6]: True
Edited by Gerard Funosas