-
Notifications
You must be signed in to change notification settings - Fork 19
/
log_event.py
81 lines (72 loc) · 3.28 KB
/
log_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import datetime
import uuid
from microsetta_private_api.model.model_base import ModelBase
from enum import Enum, unique
# NOTE: The string values of these enums are persisted to the database
# therefore. They MUST NOT BE CHANGED.
@unique
class EventType(Enum):
# The event type indicating an email was sent to an end user
EMAIL = "email"
@unique
class EventSubtype(Enum):
# Email event subtypes refer to the various email templates we can send out
# The welcome to microsetta email containing an email and
# code to send to the new user for signup
EMAIL_ACTIVATION = "send_activation_code"
# indicate a sample was received, and is good, but is being banked
EMAIL_SAMPLE_RECEIVED_BANKED = "sample_received_banked"
# indicate a sample was received, is good, and is being plated
EMAIL_SAMPLE_RECEIVED_PLATED = "sample_received_plated"
# indicate a previously banked sample is now being plated
EMAIL_BANKED_SAMPLE_NOW_PLATED = "banked_sample_plated"
# Indicate a sample was received but doesn't match the information provided
EMAIL_INCORRECT_SAMPLE_TYPE = "incorrect_sample_type"
# Indicate a sample was received but necessary information was not provided
EMAIL_MISSING_SAMPLE_INFO = "missing_sample_info"
# A valid sample was received
EMAIL_SAMPLE_IS_VALID = "sample_is_valid"
# Sample is not associated with a source
EMAIL_NO_SOURCE = "no_associated_source"
# Fulfillment of a daklapack order must be held
DAK_ORDER_HOLD = "daklapack_order_hold"
# Daklapack order polling idenfitied orders with errors
DAK_ORDER_ERRORS_REPORT = "daklapack_orders_error_report"
# Daklapack polling encountered code errors
DAK_POLLING_ERRORS_REPORT = "daklapack_polling_errors_report"
# Pester daniel if for what are expected to be unusual situations
PESTER_DANIEL = "pester_daniel"
# for project per-sample summaries
EMAIL_PER_PROJECT_SUMMARY = "per_project_summary"
# for addresses that Melissa deems invalid
EMAIL_ADDRESS_INVALID = "address_invalid"
# for confirmation emails of interested user signups
EMAIL_SUBMIT_INTEREST_CONFIRMATION = "submit_interest_confirmation"
# Thank you for Fundrazr contribution - kit or subscription
EMAIL_THANK_YOU_WITH_KIT = "thank_you_with_kit"
# Thank you for Fundrazr contribution - FFQ only
EMAIL_THANK_YOU_NO_KIT = "thank_you_no_kit"
# Send tracking number for newly shipped kit
EMAIL_KIT_TRACKING_NUMBER = "kit_tracking_number"
# When next subscription fulfillment occurs, send FFQ code
EMAIL_SUBSCRIPTION_FFQ_CODE = "subscription_ffq_code"
class LogEvent(ModelBase):
def __init__(self,
event_id: uuid.UUID,
event_type: EventType,
event_subtype: EventSubtype,
event_time: datetime,
event_state: dict):
self.event_id = event_id
self.event_type = event_type
self.event_subtype = event_subtype
self.event_time = event_time
self.event_state = event_state
def to_api(self):
return {
"event_id": str(self.event_id),
"event_type": self.event_type.value,
"event_subtype": self.event_subtype.value,
"event_time": self.event_time,
"event_state": self.event_state
}