2017-06-15 11:32:51 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
2021-03-10 13:55:06 +00:00
|
|
|
from app import create_uuid, db
|
2021-04-14 07:11:01 +01:00
|
|
|
from app.dao.dao_utils import autocommit, version_class
|
2017-06-15 11:32:51 +01:00
|
|
|
from app.models import ServiceInboundApi
|
2017-06-13 15:27:13 +01:00
|
|
|
|
|
|
|
|
|
2021-04-14 07:11:01 +01:00
|
|
|
@autocommit
|
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()
|
2017-11-30 12:39:19 +00:00
|
|
|
service_inbound_api.created_at = datetime.utcnow()
|
2017-06-13 15:27:13 +01:00
|
|
|
db.session.add(service_inbound_api)
|
2017-06-15 11:32:51 +01:00
|
|
|
|
|
|
|
|
|
2021-04-14 07:11:01 +01:00
|
|
|
@autocommit
|
2017-06-15 11:32:51 +01:00
|
|
|
@version_class(ServiceInboundApi)
|
2023-08-29 14:54:30 -07:00
|
|
|
def reset_service_inbound_api(
|
|
|
|
|
service_inbound_api, updated_by_id, url=None, bearer_token=None
|
|
|
|
|
):
|
2017-06-19 12:25:05 +01:00
|
|
|
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):
|
2023-08-29 14:54:30 -07:00
|
|
|
return ServiceInboundApi.query.filter_by(
|
|
|
|
|
id=service_inbound_api_id, service_id=service_id
|
|
|
|
|
).first()
|
2017-06-19 16:35:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_service_inbound_api_for_service(service_id):
|
|
|
|
|
return ServiceInboundApi.query.filter_by(service_id=service_id).first()
|
2018-07-05 11:09:17 +01:00
|
|
|
|
|
|
|
|
|
2021-04-14 07:11:01 +01:00
|
|
|
@autocommit
|
2018-07-05 11:09:17 +01:00
|
|
|
def delete_service_inbound_api(service_inbound_api):
|
|
|
|
|
db.session.delete(service_inbound_api)
|