Skip to content

Commit 029deee

Browse files
author
sachin-maheshwari
authored
Merge pull request #19 from topcoder-platform/feature/apiv3
Transactional templates support
2 parents 989f604 + 89cc9cb commit 029deee

11 files changed

+131
-432
lines changed

config/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ module.exports = {
3838

3939
//in every 2 minutes will retry for failed status
4040
EMAIL_RETRY_SCHEDULE: process.env.EMAIL_RETRY_SCHEDULE || '0 */2 * * * *',
41+
//wont't retry failed emails older than this time (msec)
42+
EMAIL_RETRY_MAX_AGE: process.env.EMAIL_RETRY_MAX_AGE || 1000*60*60*24,
4143

4244
API_CONTEXT_PATH: process.env.API_CONTEXT_PATH || '/v5/email',
4345

connect/service.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ const sendEmail = (templateId, message) => { // send email
2222
return sgMail.send({
2323
to,
2424
templateId,
25-
substitutions,
25+
dynamicTemplateData: substitutions,
2626
from,
27-
substitutionWrappers: ['{{', '}}'],
2827
replyTo,
2928
categories,
3029
cc,

docs/swagger_api.yaml

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,20 @@ securityDefinitions:
1515
description: JWT Authentication. Provide API Key in the form 'Bearer <token>'.
1616

1717
paths:
18-
/templates/{name}:
18+
/health:
1919
get:
2020
description:
21-
get email template placholders name
21+
health check endpoint
2222
produces:
2323
- application/json
24-
security:
25-
- jwt: []
26-
parameters:
27-
- name: name
28-
in: path
29-
description: The Kafka topic name
30-
required: true
31-
type: string
3224
responses:
3325
200:
3426
description: OK
3527
schema:
3628
type: object
3729
properties:
38-
items:
39-
type: array
40-
items:
41-
type: string
42-
400:
43-
description: "Bad request error."
44-
schema:
45-
$ref: "#/definitions/Error"
46-
404:
47-
description: "Template is not found error."
48-
schema:
49-
$ref: "#/definitions/Error"
50-
401:
51-
description: "Authentication failed."
52-
schema:
53-
$ref: "#/definitions/Error"
54-
500:
55-
description: "Internal server error."
56-
schema:
57-
$ref: "#/definitions/Error"
30+
health:
31+
type: string
5832
definitions:
5933
Error:
6034
properties:

docs/tc-email-server-api.postman_collection.json

Lines changed: 5 additions & 244 deletions
Original file line numberDiff line numberDiff line change
@@ -1,239 +1,18 @@
11
{
2+
"variables": [],
23
"info": {
34
"name": "tc-email-server-api",
4-
"_postman_id": "f9d855bc-e0a5-3501-ab56-9a144830c431",
5+
"_postman_id": "1b69bb54-1908-a951-8597-aa50db53b5ba",
56
"description": "",
6-
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
7+
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
78
},
89
"item": [
910
{
10-
"name": "failure",
11-
"description": "",
12-
"item": [
13-
{
14-
"name": "Email - invalid token",
15-
"event": [
16-
{
17-
"listen": "test",
18-
"script": {
19-
"id": "6bbbb6e1-3ef8-4e4e-802e-c6bfd892378c",
20-
"type": "text/javascript",
21-
"exec": [
22-
"pm.test(\"Invalid GET request\", function () {",
23-
" pm.expect(pm.response.code).to.be.oneOf([403]);",
24-
"});"
25-
]
26-
}
27-
}
28-
],
29-
"request": {
30-
"auth": {
31-
"type": "bearer",
32-
"bearer": [
33-
{
34-
"key": "token",
35-
"value": "BAD_TOKEN",
36-
"type": "string"
37-
}
38-
]
39-
},
40-
"method": "GET",
41-
"header": [],
42-
"body": {},
43-
"url": {
44-
"raw": "{{URL}}/email.project.created",
45-
"host": [
46-
"{{URL}}"
47-
],
48-
"path": [
49-
"email.project.created"
50-
]
51-
},
52-
"description": ""
53-
},
54-
"response": []
55-
},
56-
{
57-
"name": "Email - invalid topic",
58-
"event": [
59-
{
60-
"listen": "test",
61-
"script": {
62-
"id": "5a75ca22-fb44-4a40-b6fa-d47f7421465b",
63-
"type": "text/javascript",
64-
"exec": [
65-
"pm.test(\"Bad request GET request\", function () {",
66-
" pm.expect(pm.response.code).to.be.oneOf([400]);",
67-
"});"
68-
]
69-
}
70-
}
71-
],
72-
"request": {
73-
"auth": {
74-
"type": "bearer",
75-
"bearer": [
76-
{
77-
"key": "token",
78-
"value": "{{TC_ADMIN_TOKEN}}",
79-
"type": "string"
80-
}
81-
]
82-
},
83-
"method": "GET",
84-
"header": [],
85-
"body": {},
86-
"url": {
87-
"raw": "{{URL}}/email.invalid",
88-
"host": [
89-
"{{URL}}"
90-
],
91-
"path": [
92-
"email.invalid"
93-
]
94-
},
95-
"description": ""
96-
},
97-
"response": []
98-
},
99-
{
100-
"name": "Email - invalid template",
101-
"event": [
102-
{
103-
"listen": "test",
104-
"script": {
105-
"id": "2e5a6ff8-bd38-457a-8c94-5cb745e11de5",
106-
"type": "text/javascript",
107-
"exec": [
108-
"pm.test(\"Not found GET request\", function () {",
109-
" pm.expect(pm.response.code).to.be.oneOf([404]);",
110-
"});"
111-
]
112-
}
113-
}
114-
],
115-
"request": {
116-
"auth": {
117-
"type": "bearer",
118-
"bearer": [
119-
{
120-
"key": "token",
121-
"value": "{{TC_ADMIN_TOKEN}}",
122-
"type": "string"
123-
}
124-
]
125-
},
126-
"method": "GET",
127-
"header": [],
128-
"body": {},
129-
"url": {
130-
"raw": "{{URL}}/email.tempate.invalid",
131-
"host": [
132-
"{{URL}}"
133-
],
134-
"path": [
135-
"email.tempate.invalid"
136-
]
137-
},
138-
"description": ""
139-
},
140-
"response": []
141-
},
142-
{
143-
"name": "Email - invalid template version",
144-
"event": [
145-
{
146-
"listen": "test",
147-
"script": {
148-
"id": "2e5a6ff8-bd38-457a-8c94-5cb745e11de5",
149-
"type": "text/javascript",
150-
"exec": [
151-
"pm.test(\"Not found GET request\", function () {",
152-
" pm.expect(pm.response.code).to.be.oneOf([404]);",
153-
"});"
154-
]
155-
}
156-
}
157-
],
158-
"request": {
159-
"auth": {
160-
"type": "bearer",
161-
"bearer": [
162-
{
163-
"key": "token",
164-
"value": "{{TC_ADMIN_TOKEN}}",
165-
"type": "string"
166-
}
167-
]
168-
},
169-
"method": "GET",
170-
"header": [],
171-
"body": {},
172-
"url": {
173-
"raw": "{{URL}}/email.template.no.version",
174-
"host": [
175-
"{{URL}}"
176-
],
177-
"path": [
178-
"email.template.no.version"
179-
]
180-
},
181-
"description": ""
182-
},
183-
"response": []
184-
}
185-
]
186-
},
187-
{
188-
"name": "Email - project.created",
189-
"event": [
190-
{
191-
"listen": "test",
192-
"script": {
193-
"id": "db43bdd5-1b84-42c3-9033-59a8756ab3ba",
194-
"type": "text/javascript",
195-
"exec": [
196-
"pm.test(\"Successful GET request\", function () {",
197-
" pm.expect(pm.response.code).to.be.oneOf([200,204]);",
198-
"});"
199-
]
200-
}
201-
}
202-
],
203-
"request": {
204-
"auth": {
205-
"type": "bearer",
206-
"bearer": [
207-
{
208-
"key": "token",
209-
"value": "{{TC_ADMIN_TOKEN}}",
210-
"type": "string"
211-
}
212-
]
213-
},
214-
"method": "GET",
215-
"header": [],
216-
"body": {},
217-
"url": {
218-
"raw": "{{URL}}/email.project.created",
219-
"host": [
220-
"{{URL}}"
221-
],
222-
"path": [
223-
"email.project.created"
224-
]
225-
},
226-
"description": ""
227-
},
228-
"response": []
229-
},
230-
{
231-
"name": "Email - project.updated",
11+
"name": "Health",
23212
"event": [
23313
{
23414
"listen": "test",
23515
"script": {
236-
"id": "9732b9ef-c3b0-4ea3-92e3-624f9e84c6e6",
23716
"type": "text/javascript",
23817
"exec": [
23918
"pm.test(\"Successful GET request\", function () {",
@@ -244,28 +23,10 @@
24423
}
24524
],
24625
"request": {
247-
"auth": {
248-
"type": "bearer",
249-
"bearer": [
250-
{
251-
"key": "token",
252-
"value": "{{TC_ADMIN_TOKEN}}",
253-
"type": "string"
254-
}
255-
]
256-
},
26+
"url": "{{URL}}/health",
25727
"method": "GET",
25828
"header": [],
25929
"body": {},
260-
"url": {
261-
"raw": "{{URL}}/email.project.updated",
262-
"host": [
263-
"{{URL}}"
264-
],
265-
"path": [
266-
"email.project.updated"
267-
]
268-
},
26930
"description": ""
27031
},
27132
"response": []

0 commit comments

Comments
 (0)