mirror of
https://github.com/GSA/notifications-api.git
synced 2026-03-03 00:42:37 -05:00
This class doesn’t actually wrap JSON, it wraps serialised data. So this name feels better. This commit only renames the file for an easier diff.
31 lines
628 B
Python
31 lines
628 B
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class JSONModel(ABC):
|
|
|
|
@property
|
|
@abstractmethod
|
|
def ALLOWED_PROPERTIES(self):
|
|
pass
|
|
|
|
def __init__(self, _dict):
|
|
for property in self.ALLOWED_PROPERTIES:
|
|
setattr(self, property, _dict[property])
|
|
|
|
def __dir__(self):
|
|
return super().__dir__() + list(sorted(self.ALLOWED_PROPERTIES))
|
|
|
|
|
|
class TemplateJSONModel(JSONModel):
|
|
ALLOWED_PROPERTIES = {
|
|
'archived',
|
|
'content',
|
|
'id',
|
|
'postage',
|
|
'process_type',
|
|
'reply_to_text',
|
|
'subject',
|
|
'template_type',
|
|
'version',
|
|
}
|