2024-01-10 12:32:25 -05:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TemplateType(Enum):
|
|
|
|
|
SMS = "sms"
|
|
|
|
|
EMAIL = "email"
|
|
|
|
|
LETTER = "letter"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationType(Enum):
|
|
|
|
|
SMS = "sms"
|
|
|
|
|
EMAIL = "email"
|
|
|
|
|
LETTER = "letter"
|
|
|
|
|
|
|
|
|
|
|
2024-01-12 16:05:18 -05:00
|
|
|
class TemplateProcessType(Enum):
|
|
|
|
|
# TODO: Should Template.process_type be changed to use this?
|
|
|
|
|
NORMAL = "normal"
|
|
|
|
|
PRIORITY = "priority"
|
|
|
|
|
|
|
|
|
|
|
2024-01-18 10:28:15 -05:00
|
|
|
class AuthType(Enum):
|
2024-01-10 12:32:25 -05:00
|
|
|
SMS = "sms_auth"
|
|
|
|
|
EMAIL = "email_auth"
|
|
|
|
|
WEBAUTHN = "webauthn_auth"
|
|
|
|
|
|
|
|
|
|
|
2024-01-18 10:28:15 -05:00
|
|
|
class CallbackType(Enum):
|
2024-01-10 12:32:25 -05:00
|
|
|
DELIVERY_STATUS = "delivery_status"
|
|
|
|
|
COMPLAINT = "complaint"
|
|
|
|
|
|
|
|
|
|
|
2024-01-18 10:28:15 -05:00
|
|
|
class OrganizationType(Enum):
|
|
|
|
|
FEDERAL = "federal"
|
|
|
|
|
STATE = "state"
|
|
|
|
|
OTHER = "other"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationStatus(Enum):
|
|
|
|
|
CANCELLED = "cancelled"
|
|
|
|
|
CREATED = "created"
|
|
|
|
|
SENDING = "sending"
|
|
|
|
|
SENT = "sent"
|
|
|
|
|
DELIVERED = "delivered"
|
|
|
|
|
PENDING = "pending"
|
|
|
|
|
FAILED = "failed"
|
|
|
|
|
TECHNICAL_FAILURE = "technical-failure"
|
|
|
|
|
TEMPORARY_FAILURE = "temporary-failure"
|
|
|
|
|
PERMANENT_FAILURE = "permanent-failure"
|
|
|
|
|
PENDING_VIRUS_CHECK = "pending-virus-check"
|
|
|
|
|
VALIDATION_FAILED = "validation-failed"
|
|
|
|
|
VIRUS_SCAN_FAILED = "virus-scan-failed"
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def failed_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.TECHNICAL_FAILURE,
|
|
|
|
|
cls.TEMPORARY_FAILURE,
|
|
|
|
|
cls.PERMANENT_FAILURE,
|
|
|
|
|
cls.VALIDATION_FAILED,
|
|
|
|
|
cls.VIRUS_SCAN_FAILED,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def completed_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.SENT,
|
|
|
|
|
cls.DELIVERED,
|
|
|
|
|
cls.FAILED,
|
|
|
|
|
cls.TECHNICAL_FAILURE,
|
|
|
|
|
cls.TEMPORARY_FAILURE,
|
|
|
|
|
cls.PERMANENT_FAILURE,
|
|
|
|
|
cls.CANCELLED,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def success_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (cls.SENT, cls.DELIVERED)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def billable_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.SENDING,
|
|
|
|
|
cls.SENT,
|
|
|
|
|
cls.DELIVERED,
|
|
|
|
|
cls.PENDING,
|
|
|
|
|
cls.FAILED,
|
|
|
|
|
cls.TEMPORARY_FAILURE,
|
|
|
|
|
cls.PERMANENT_FAILURE,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def billable_sms_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.SENDING,
|
|
|
|
|
cls.SENT, # internationally
|
|
|
|
|
cls.DELIVERED,
|
|
|
|
|
cls.PENDING,
|
|
|
|
|
cls.TEMPORARY_FAILURE,
|
|
|
|
|
cls.PERMANENT_FAILURE,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def sent_email_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-18 10:28:15 -05:00
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.SENDING,
|
|
|
|
|
cls.DELIVERED,
|
|
|
|
|
cls.TEMPORARY_FAILURE,
|
|
|
|
|
cls.PERMANENT_FAILURE,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@property
|
2024-01-16 14:46:17 -05:00
|
|
|
def non_billable_types(self) -> tuple["NotificationStatus", ...]:
|
2024-01-16 07:37:21 -05:00
|
|
|
self._non_billable: tuple["NotificationStatus", ...]
|
|
|
|
|
try:
|
|
|
|
|
return self._non_billable
|
|
|
|
|
except AttributeError:
|
|
|
|
|
self._non_billable = tuple(set(type(self)) - set(self.billable))
|
|
|
|
|
return self._non_billable
|
2024-01-18 10:28:15 -05:00
|
|
|
|
|
|
|
|
|
2024-01-12 16:05:18 -05:00
|
|
|
class PermissionType(Enum):
|
|
|
|
|
MANAGE_USERS = "manage_users"
|
|
|
|
|
MANAGE_TEMPLATES = "manage_templates"
|
|
|
|
|
MANAGE_SETTINGS = "manage_settings"
|
|
|
|
|
SEND_TEXTS = "send_texts"
|
|
|
|
|
SEND_EMAILS = "send_emails"
|
|
|
|
|
MANAGE_API_KEYS = "manage_api_keys"
|
|
|
|
|
PLATFORM_ADMIN = "platform_admin"
|
|
|
|
|
VIEW_ACTIVITY = "view_activity"
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def defaults(self) -> tuple["PermissionType", ...]:
|
|
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.MANAGE_USERS,
|
|
|
|
|
cls.MANAGE_TEMPLATES,
|
|
|
|
|
cls.MANAGE_SETTINGS,
|
|
|
|
|
cls.SEND_TEXTS,
|
|
|
|
|
cls.SEND_EMAILS,
|
|
|
|
|
cls.MANAGE_API_KEYS,
|
|
|
|
|
cls.VIEW_ACTIVITY,
|
|
|
|
|
)
|
|
|
|
|
|
2024-01-12 17:27:31 -05:00
|
|
|
|
2024-01-10 12:32:25 -05:00
|
|
|
class ServicePermissionType(Enum):
|
|
|
|
|
EMAIL = "email"
|
|
|
|
|
SMS = "sms"
|
|
|
|
|
INTERNATIONAL_SMS = "international_sms"
|
|
|
|
|
INBOUND_SMS = "inbound_sms"
|
|
|
|
|
SCHEDULE_NOTIFICATIONS = "schedule_notifications"
|
|
|
|
|
EMAIL_AUTH = "email_auth"
|
|
|
|
|
UPLOAD_DOCUMENT = "upload_document"
|
|
|
|
|
EDIT_FOLDER_PERMISSIONS = "edit_folder_permissions"
|
|
|
|
|
|
2024-01-12 16:05:18 -05:00
|
|
|
@property
|
|
|
|
|
def defaults(self) -> tuple["ServicePermissionType", ...]:
|
|
|
|
|
cls = type(self)
|
|
|
|
|
return (
|
|
|
|
|
cls.SMS,
|
|
|
|
|
cls.EMAIL,
|
|
|
|
|
cls.INTERNATIONAL_SMS,
|
|
|
|
|
)
|
2024-01-10 12:32:25 -05:00
|
|
|
|
2024-01-12 17:27:31 -05:00
|
|
|
|
|
|
|
|
class RecipientType(Enum):
|
2024-01-10 12:32:25 -05:00
|
|
|
MOBILE = "mobile"
|
|
|
|
|
EMAIL = "email"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class KeyType(Enum):
|
|
|
|
|
NORMAL = "normal"
|
|
|
|
|
TEAM = "team"
|
|
|
|
|
TEST = "test"
|
|
|
|
|
|
|
|
|
|
|
2024-01-15 14:22:56 -05:00
|
|
|
class JobStatus(Enum):
|
2024-01-10 12:32:25 -05:00
|
|
|
PENDING = "pending"
|
|
|
|
|
IN_PROGRESS = "in progress"
|
|
|
|
|
FINISHED = "finished"
|
|
|
|
|
SENDING_LIMITS_EXCEEDED = "sending limits exceeded"
|
|
|
|
|
SCHEDULED = "scheduled"
|
|
|
|
|
CANCELLED = "cancelled"
|
|
|
|
|
READY_TO_SEND = "ready to send"
|
|
|
|
|
SENT_TO_DVLA = "sent to dvla"
|
|
|
|
|
ERROR = "error"
|
|
|
|
|
|
|
|
|
|
|
2024-01-12 17:46:00 -05:00
|
|
|
class InvitedUserStatus(Enum):
|
2024-01-12 16:05:18 -05:00
|
|
|
PENDING = "pending"
|
|
|
|
|
ACCEPTED = "accepted"
|
|
|
|
|
CANCELLED = "cancelled"
|
|
|
|
|
EXPIRED = "expired"
|
|
|
|
|
|
|
|
|
|
|
2024-01-18 10:28:15 -05:00
|
|
|
class BrandType(Enum):
|
2024-01-12 16:05:18 -05:00
|
|
|
# TODO: Should EmailBranding.branding_type be changed to use this?
|
|
|
|
|
GOVUK = "govuk" # Deprecated outside migrations
|
|
|
|
|
ORG = "org"
|
|
|
|
|
BOTH = "both"
|
|
|
|
|
ORG_BANNER = "org_banner"
|
|
|
|
|
|
|
|
|
|
|
2024-01-12 17:46:00 -05:00
|
|
|
class CodeType(Enum):
|
2024-01-12 16:05:18 -05:00
|
|
|
EMAIL = "email"
|
|
|
|
|
SMS = "sms"
|
|
|
|
|
|
|
|
|
|
|
2024-01-10 12:32:25 -05:00
|
|
|
class AgreementType(Enum):
|
|
|
|
|
MOU = "MOU"
|
|
|
|
|
IAA = "IAA"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AgreementStatus(Enum):
|
|
|
|
|
ACTIVE = "active"
|
|
|
|
|
EXPIRED = "expired"
|