@@ -26,7 +26,7 @@ def __init__(self, app):
26
26
27
27
web_app = app .WebContainer .WebApp
28
28
web_app .router .add_put (r"/send_email" , self .send_email )
29
- web_app .router .add_put (r"/send_mail" , self .send_email ) # This one is for backward compatiblity
29
+ web_app .router .add_put (r"/send_mail" , self .send_email ) # This one is for backward compatibility
30
30
web_app .router .add_put (r"/render" , self .render )
31
31
web_app .router .add_put (r"/send_slack" , self .send_alert )
32
32
@@ -55,24 +55,24 @@ async def send_email(self, request, *, json_data):
55
55
"subject": "Lufthansa Hiest",
56
56
"from": "Jimmy.Conway@Goodfellas.com",
57
57
"body": {
58
- "template": "test.md",
58
+ "template": "/Templates/Emails/ test.md",
59
59
"params": {
60
60
"Name": "Toddy Siciro"
61
61
}
62
62
},
63
63
"attachments": [
64
64
{
65
- "template": "test.md ",
65
+ "template": "/Templates/Emails/hello.html ",
66
66
"params": {
67
67
"Name": "Michael Corleone"
68
68
},
69
69
"format": "pdf",
70
- "filename": "Made .pdf"
70
+ "filename": "Alert .pdf"
71
71
}]
72
72
}
73
73
74
74
```
75
- Attached will be retrieved from request.conent when rendering the email is not required.
75
+ Attached will be retrieved from request.content when rendering the email is not required.
76
76
77
77
Example of the email body template:
78
78
```
@@ -93,7 +93,7 @@ async def send_email(self, request, *, json_data):
93
93
"""
94
94
95
95
try :
96
- await self .App .SendMailOrchestrator . send_mail (
96
+ await self .App .SendEmailOrchestrator . send_email (
97
97
email_to = json_data ["to" ],
98
98
body_template = json_data ["body" ]["template" ],
99
99
email_cc = json_data .get ("cc" , []), # Optional
@@ -103,7 +103,6 @@ async def send_email(self, request, *, json_data):
103
103
body_params = json_data ["body" ].get ("params" , {}), # Optional
104
104
attachments = json_data .get ("attachments" , []), # Optional
105
105
)
106
-
107
106
except KeyError as e :
108
107
raise aiohttp .web .HTTPNotFound (text = "{}" .format (e ))
109
108
@@ -128,7 +127,7 @@ async def send_alert(self, request, *, json_data):
128
127
{
129
128
"type": "slack",
130
129
"body": {
131
- "template": "test .md",
130
+ "template": "/Templates/Slack/alert .md",
132
131
"params": {
133
132
"Name": "Toddy Siciro"
134
133
}
@@ -154,7 +153,7 @@ async def render(self, request):
154
153
This endpoint renders request body into template based on the format specified.
155
154
Example:
156
155
```
157
- localhost:8080/render?format=pdf&template=test.md
156
+ localhost:8080/render?format=pdf&template=/Templates/General/ test.md
158
157
159
158
format: pdf/html
160
159
@@ -176,11 +175,12 @@ async def render(self, request):
176
175
template_data = await request .json ()
177
176
178
177
# Render a body
179
- html = await self .render (template , template_data )
178
+ html = await self .App .RenderReportOrchestrator .render (template , template_data )
179
+
180
180
# get pdf from html if present.
181
181
if fmt == 'pdf' :
182
182
content_type = "application/pdf"
183
- pdf = self .App .HtmlToPdfService .format (html )
183
+ pdf = self .App .PdfFormatterService .format (html )
184
184
elif fmt == 'html' :
185
185
content_type = "text/html"
186
186
else :
0 commit comments