2017-06-15 11:32:51 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from app import db, create_uuid
|
|
|
|
|
from app.dao.dao_utils import transactional, version_class
|
|
|
|
|
from app.models import ServiceInboundApi
|
2017-06-13 15:27:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@transactional
|
2017-06-15 11:32:51 +01:00
|
|
|
@version_class(ServiceInboundApi)
|
2017-06-13 15:27:13 +01:00
|
|
|
def save_service_inbound_api(service_inbound_api):
|
2017-06-15 11:32:51 +01:00
|
|
|
service_inbound_api.id = create_uuid()
|
|
|
|
|
service_inbound_api.created_at == datetime.utcnow()
|
2017-06-19 14:32:22 +01:00
|
|
|
service_inbound_api.bearer_token = service_inbound_api.bearer_token
|
2017-06-13 15:27:13 +01:00
|
|
|
db.session.add(service_inbound_api)
|
2017-06-15 11:32:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@transactional
|
|
|
|
|
@version_class(ServiceInboundApi)
|
2017-06-19 12:25:05 +01:00
|
|
|
def reset_service_inbound_api(service_inbound_api, updated_by_id, url=None, bearer_token=None):
|
|
|
|
|
if url:
|
|
|
|
|
service_inbound_api.url = url
|
|
|
|
|
if bearer_token:
|
2017-06-19 14:32:22 +01:00
|
|
|
service_inbound_api.bearer_token = bearer_token
|
2017-06-19 12:25:05 +01:00
|
|
|
service_inbound_api.updated_by_id = updated_by_id
|
|
|
|
|
service_inbound_api.updated_at = datetime.utcnow()
|
|
|
|
|
|
2017-06-15 11:32:51 +01:00
|
|
|
db.session.add(service_inbound_api)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_service_inbound_api(service_inbound_api_id, service_id):
|
|
|
|
|
return ServiceInboundApi.query.filter_by(id=service_inbound_api_id,
|
2017-06-15 16:19:12 +01:00
|
|
|
service_id=service_id).first()
|