-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syncing up to 1cfe8fc3169b9728b7e0150e0edaecc390f65317
Co-authored-by: Joey Greco <[email protected]>
- Loading branch information
1 parent
e421359
commit 41a3cae
Showing
3 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "ff2052f4-9acc-4efe-8b1c-e8616d464336", | ||
"_postman_id": "5435b4bc-a466-4819-a943-1c14adbfdb6c", | ||
"name": "collection.json - [HTTP] Superblocks Orchestrator", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | ||
"_exporter_id": "28659047" | ||
"_exporter_id": "25579613" | ||
}, | ||
"item": [ | ||
{ | ||
|
@@ -13325,6 +13325,71 @@ | |
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "email", | ||
"item": [ | ||
{ | ||
"name": "execute", | ||
"item": [ | ||
{ | ||
"name": "no api key", | ||
"event": [ | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"exec": [ | ||
"const response = pm.response.json();", | ||
"", | ||
"pm.test(\"assert response body\", () => {", | ||
" pm.expect(response.execution.length).to.gt(0);", | ||
" pm.expect(response.status).to.be.eql(\"STATUS_COMPLETED\");", | ||
" pm.expect(response.errors).to.eql([{", | ||
" \"name\": \"IntegrationError\",", | ||
" \"message\": \"Payment required. Email isn't available for your organization's plan. Upgrade your account or [contact sales](mailto://[email protected]) to use this feature.\",", | ||
" \"blockPath\": \"put\"", | ||
" }])", | ||
"});", | ||
"", | ||
"pm.test(\"assert status\", () => {", | ||
" pm.response.to.have.status(200);", | ||
"});" | ||
], | ||
"type": "text/javascript", | ||
"packages": {} | ||
} | ||
} | ||
], | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"options\": {\n \"include_events\": false\n },\n \"definition\": {\n \"api\": {\n \"metadata\": {\n \"name\": \"s3 integration test\",\n \"organization\": \"00000000-0000-0000-0000-000000000001\"\n },\n \"blocks\": [\n {\n \"name\": \"put\",\n \"step\": {\n \"integration\": \"email-i\",\n \"email\": {\n \"emailTo\": \"[email protected]\",\n \"emailSubject\": \"bar\"\n }\n }\n }\n ]\n },\n \"integrations\": {\n \"email-i\": {\n \"authentication\": {\n \"custom\": {\n \"apiKey\": {\n \"value\": \"\"\n },\n \"senderEmail\": {\n \"value\": \"foo\"\n },\n \"senderName\": {\n \"value\": \"bar\"\n }\n }\n }\n }\n }\n }\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{orchestrator_scheme}}://{{orchestrator_host}}:{{orchestrator_port}}/v2/execute", | ||
"protocol": "{{orchestrator_scheme}}", | ||
"host": [ | ||
"{{orchestrator_host}}" | ||
], | ||
"port": "{{orchestrator_port}}", | ||
"path": [ | ||
"v2", | ||
"execute" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,11 @@ export default class EmailPlugin extends BasePlugin { | |
|
||
createClient(datasourceConfiguration: EmailDatasourceConfiguration): MailService { | ||
const key = datasourceConfiguration.authentication?.custom?.apiKey?.value ?? ''; | ||
// NOTE: (joey) the api key will be empty when an organization is not allowed to use this plugin | ||
if (isEmpty(key)) { | ||
throw new IntegrationError(`No API key found`, ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName }); | ||
const errorMsg = | ||
"Payment required. Email isn't available for your organization's plan. Upgrade your account or [contact sales](mailto://[email protected]) to use this feature."; | ||
throw new IntegrationError(errorMsg, ErrorCode.INTEGRATION_MISSING_REQUIRED_FIELD, { pluginName: this.pluginName }); | ||
} | ||
|
||
sgMail.setApiKey(key); | ||
|