Skip to content

Transactional templates support #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module.exports = {

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

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

Expand Down
3 changes: 1 addition & 2 deletions connect/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ const sendEmail = (templateId, message) => { // send email
return sgMail.send({
to,
templateId,
substitutions,
dynamicTemplateData: substitutions,
from,
substitutionWrappers: ['{{', '}}'],
replyTo,
categories,
cc,
Expand Down
34 changes: 4 additions & 30 deletions docs/swagger_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,20 @@ securityDefinitions:
description: JWT Authentication. Provide API Key in the form 'Bearer <token>'.

paths:
/templates/{name}:
/health:
get:
description:
get email template placholders name
health check endpoint
produces:
- application/json
security:
- jwt: []
parameters:
- name: name
in: path
description: The Kafka topic name
required: true
type: string
responses:
200:
description: OK
schema:
type: object
properties:
items:
type: array
items:
type: string
400:
description: "Bad request error."
schema:
$ref: "#/definitions/Error"
404:
description: "Template is not found error."
schema:
$ref: "#/definitions/Error"
401:
description: "Authentication failed."
schema:
$ref: "#/definitions/Error"
500:
description: "Internal server error."
schema:
$ref: "#/definitions/Error"
health:
type: string
definitions:
Error:
properties:
Expand Down
249 changes: 5 additions & 244 deletions docs/tc-email-server-api.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,239 +1,18 @@
{
"variables": [],
"info": {
"name": "tc-email-server-api",
"_postman_id": "f9d855bc-e0a5-3501-ab56-9a144830c431",
"_postman_id": "1b69bb54-1908-a951-8597-aa50db53b5ba",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "failure",
"description": "",
"item": [
{
"name": "Email - invalid token",
"event": [
{
"listen": "test",
"script": {
"id": "6bbbb6e1-3ef8-4e4e-802e-c6bfd892378c",
"type": "text/javascript",
"exec": [
"pm.test(\"Invalid GET request\", function () {",
" pm.expect(pm.response.code).to.be.oneOf([403]);",
"});"
]
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "BAD_TOKEN",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.project.created",
"host": [
"{{URL}}"
],
"path": [
"email.project.created"
]
},
"description": ""
},
"response": []
},
{
"name": "Email - invalid topic",
"event": [
{
"listen": "test",
"script": {
"id": "5a75ca22-fb44-4a40-b6fa-d47f7421465b",
"type": "text/javascript",
"exec": [
"pm.test(\"Bad request GET request\", function () {",
" pm.expect(pm.response.code).to.be.oneOf([400]);",
"});"
]
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{TC_ADMIN_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.invalid",
"host": [
"{{URL}}"
],
"path": [
"email.invalid"
]
},
"description": ""
},
"response": []
},
{
"name": "Email - invalid template",
"event": [
{
"listen": "test",
"script": {
"id": "2e5a6ff8-bd38-457a-8c94-5cb745e11de5",
"type": "text/javascript",
"exec": [
"pm.test(\"Not found GET request\", function () {",
" pm.expect(pm.response.code).to.be.oneOf([404]);",
"});"
]
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{TC_ADMIN_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.tempate.invalid",
"host": [
"{{URL}}"
],
"path": [
"email.tempate.invalid"
]
},
"description": ""
},
"response": []
},
{
"name": "Email - invalid template version",
"event": [
{
"listen": "test",
"script": {
"id": "2e5a6ff8-bd38-457a-8c94-5cb745e11de5",
"type": "text/javascript",
"exec": [
"pm.test(\"Not found GET request\", function () {",
" pm.expect(pm.response.code).to.be.oneOf([404]);",
"});"
]
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{TC_ADMIN_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.template.no.version",
"host": [
"{{URL}}"
],
"path": [
"email.template.no.version"
]
},
"description": ""
},
"response": []
}
]
},
{
"name": "Email - project.created",
"event": [
{
"listen": "test",
"script": {
"id": "db43bdd5-1b84-42c3-9033-59a8756ab3ba",
"type": "text/javascript",
"exec": [
"pm.test(\"Successful GET request\", function () {",
" pm.expect(pm.response.code).to.be.oneOf([200,204]);",
"});"
]
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{TC_ADMIN_TOKEN}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.project.created",
"host": [
"{{URL}}"
],
"path": [
"email.project.created"
]
},
"description": ""
},
"response": []
},
{
"name": "Email - project.updated",
"name": "Health",
"event": [
{
"listen": "test",
"script": {
"id": "9732b9ef-c3b0-4ea3-92e3-624f9e84c6e6",
"type": "text/javascript",
"exec": [
"pm.test(\"Successful GET request\", function () {",
Expand All @@ -244,28 +23,10 @@
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{TC_ADMIN_TOKEN}}",
"type": "string"
}
]
},
"url": "{{URL}}/health",
"method": "GET",
"header": [],
"body": {},
"url": {
"raw": "{{URL}}/email.project.updated",
"host": [
"{{URL}}"
],
"path": [
"email.project.updated"
]
},
"description": ""
},
"response": []
Expand Down
Loading