fix(core): update

This commit is contained in:
Philipp Kunz 2019-10-28 15:55:04 +01:00
parent b7c657a930
commit 4305b53e35
6 changed files with 54 additions and 18 deletions

22
package-lock.json generated
View File

@ -113,6 +113,16 @@
"symbol-tree": "^3.2.4" "symbol-tree": "^3.2.4"
} }
}, },
"@pushrocks/qenv": {
"version": "4.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.6.tgz",
"integrity": "sha512-4uQyhkXYAcNW+f2ZA0DHok6Sb4i91jGW6Nom47JMIRxrNNs0okqA5AW5tdz4S1NcJO9s+0rx3rrGlGeADygn2Q==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartlog": "^2.0.19"
}
},
"@pushrocks/smartcli": { "@pushrocks/smartcli": {
"version": "3.0.7", "version": "3.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcli/-/smartcli-3.0.7.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcli/-/smartcli-3.0.7.tgz",
@ -238,9 +248,9 @@
} }
}, },
"@pushrocks/smartmail": { "@pushrocks/smartmail": {
"version": "1.0.5", "version": "1.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartmail/-/smartmail-1.0.5.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartmail/-/smartmail-1.0.6.tgz",
"integrity": "sha512-AFezij0ftmAW99o5oHdZx2RaI+46Y/1uMRc2cgl+E8V1t7bYoHT6PipUr9SdNQ3UGhH3TPzj7FuXLn9tHnE4Sw==", "integrity": "sha512-dQZi8FOLVfX6qo7b73HQ5SgdMHpS1mHNJTbwpgVT/XlhVCdreXfrAbFLVXECH4EZ8WYt9KoSUo4zHSw31g97sw==",
"requires": { "requires": {
"@pushrocks/smartfile": "^7.0.6", "@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartmustache": "^2.0.8" "@pushrocks/smartmustache": "^2.0.8"
@ -284,9 +294,9 @@
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==" "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
}, },
"@pushrocks/smartrequest": { "@pushrocks/smartrequest": {
"version": "1.1.36", "version": "1.1.41",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.36.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.41.tgz",
"integrity": "sha512-qeTRLFZZ3WOui7TkMNg8eGgZe3J9HG2XoaxR8hW65oX+TBUHcMEwA6EKuBaTWk6WUe/aJmfClw9DjjBnFCqtvQ==", "integrity": "sha512-Kv2HXydJ3epFDEgfXm1RMLMQC6ix3sin8Gb3MioBWStqH3Aik6XvwNqPnBX5MBcVcbFOWQooJjjBRHM5k/hRXA==",
"requires": { "requires": {
"@pushrocks/smartpromise": "^3.0.5", "@pushrocks/smartpromise": "^3.0.5",
"@types/form-data": "^2.5.0", "@types/form-data": "^2.5.0",

View File

@ -15,14 +15,15 @@
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.15",
"@pushrocks/qenv": "^4.0.6",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^12.11.7", "@types/node": "^12.11.7",
"tslint": "^5.11.0", "tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartmail": "^1.0.5", "@pushrocks/smartmail": "^1.0.6",
"@pushrocks/smartrequest": "^1.1.36", "@pushrocks/smartrequest": "^1.1.41",
"@pushrocks/smartstring": "^3.0.14" "@pushrocks/smartstring": "^3.0.14"
}, },
"files": [ "files": [

2
qenv.yml Normal file
View File

@ -0,0 +1,2 @@
required:
- MAILGUN_API_TOKEN

View File

@ -1,8 +1,31 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv';
import * as smartmail from '@pushrocks/smartmail';
const testQenv = new Qenv('./', './.nogit');
import * as mailgun from '../ts/index'; import * as mailgun from '../ts/index';
let testMailgunAccount: mailgun.MailgunAccount;
let testSmartmail: smartmail.Smartmail;
tap.test('first test', async () => { tap.test('first test', async () => {
console.log(mailgun.standardExport); testMailgunAccount = new mailgun.MailgunAccount(testQenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'));
expect(testMailgunAccount).to.be.instanceOf(mailgun.MailgunAccount);
});
tap.test('should create a smartmail', async () => {
testSmartmail = new smartmail.Smartmail({
body: 'hi there. This is the body.',
from: 'noreply@mail.lossless.com',
subject: 'hi there. This is the subject'
});
return testSmartmail;
});
tap.test('should send a smartmail', async () => {
testMailgunAccount.sendSmartMail(testSmartmail, 'phil@lossless.com');
}); });
tap.start(); tap.start();

View File

@ -1,3 +1 @@
import * as plugins from './mailgun.plugins'; export * from './mailgun.classes.account';
export let standardExport = 'Hi there! :) This is an exported string';

View File

@ -14,7 +14,7 @@ export class MailgunAccount {
method: 'GET', method: 'GET',
headers: { headers: {
Authorization: `Basic ${plugins.smartstring.base64.encode( Authorization: `Basic ${plugins.smartstring.base64.encode(
`api:key-a049e048b7029b9621c41b5682fadee9` this.apiToken
)}`, )}`,
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
@ -24,7 +24,7 @@ export class MailgunAccount {
public async postFormData(routeArg: string, formFields: plugins.smartrequest.IFormField[]) { public async postFormData(routeArg: string, formFields: plugins.smartrequest.IFormField[]) {
const requestUrl = `${this.baseUrl}${routeArg}`; // TODO; const requestUrl = `${this.baseUrl}${routeArg}`; // TODO;
const response = await plugins.smartrequest.postFormData( const response = await plugins.smartrequest.postFormData(
routeArg, requestUrl,
{ {
headers: { headers: {
Authorization: `Basic ${plugins.smartstring.base64.encode( Authorization: `Basic ${plugins.smartstring.base64.encode(
@ -40,7 +40,7 @@ export class MailgunAccount {
/** /**
* sends a SmartMail * sends a SmartMail
*/ */
public sendSmartMail(smartmailArg: plugins.smartmail.Smartmail, toArg: string, dataArg = {}) { public async sendSmartMail(smartmailArg: plugins.smartmail.Smartmail, toArg: string, dataArg = {}) {
const domain = smartmailArg.options.from.split('@')[1]; const domain = smartmailArg.options.from.split('@')[1];
const formFields: plugins.smartrequest.IFormField[] = [ const formFields: plugins.smartrequest.IFormField[] = [
{ {
@ -69,10 +69,12 @@ export class MailgunAccount {
formFields.push({ formFields.push({
name: 'attachment', name: 'attachment',
type: 'Buffer', type: 'Buffer',
payload: attachment.contentBuffer payload: attachment.contentBuffer,
}) fileName: attachment.parsedPath.base
});
} }
this.postFormData(`/${domain}/messages`, formFields); const response = await this.postFormData(`/${domain}/messages`, formFields);
console.log(response);
} }
} }