Add callback_type column to service_callback_api table

Also add service_callback_type table with allowed types
This commit is contained in:
Pea Tyczynska
2018-07-17 16:15:57 +01:00
parent 9c99e45008
commit 183aa160c6
4 changed files with 51 additions and 2 deletions

View File

@@ -57,6 +57,10 @@ SMS_AUTH_TYPE = 'sms_auth'
EMAIL_AUTH_TYPE = 'email_auth'
USER_AUTH_TYPE = [SMS_AUTH_TYPE, EMAIL_AUTH_TYPE]
DELIVERY_STATUS_CALLBACK_TYPE = 'delivery_status'
COMPLAINT_CALLBACK_TYPE = 'complaint'
SERVICE_CALLBACK_TYPES = [DELIVERY_STATUS_CALLBACK_TYPE, COMPLAINT_CALLBACK_TYPE]
def filter_null_value_fields(obj):
return dict(
@@ -596,6 +600,7 @@ class ServiceCallbackApi(db.Model, Versioned):
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), index=True, nullable=False, unique=True)
service = db.relationship('Service', backref='service_callback_api')
url = db.Column(db.String(), nullable=False)
callback_type = db.Column(db.String(), db.ForeignKey('service_callback_type.name'), nullable=True)
_bearer_token = db.Column("bearer_token", db.String(), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow, nullable=False)
updated_at = db.Column(db.DateTime, nullable=True)
@@ -624,6 +629,12 @@ class ServiceCallbackApi(db.Model, Versioned):
}
class ServiceCallbackType(db.Model):
__tablename__ = 'service_callback_type'
name = db.Column(db.String, primary_key=True)
class ApiKey(db.Model, Versioned):
__tablename__ = 'api_keys'