From 0212d476c2a22bb0c92e66dc0b963db601597ff4 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 11 Jan 2020 19:01:59 +0000 Subject: [PATCH] fix(core): update --- package-lock.json | 57 ++++++++++++++++++----------------- package.json | 10 +++--- ts/mailgun.classes.account.ts | 18 +++++++++-- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index f8ac5d3..e5a0702 100644 --- a/package-lock.json +++ b/package-lock.json @@ -294,9 +294,9 @@ "integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==" }, "@pushrocks/smartrequest": { - "version": "1.1.41", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.41.tgz", - "integrity": "sha512-Kv2HXydJ3epFDEgfXm1RMLMQC6ix3sin8Gb3MioBWStqH3Aik6XvwNqPnBX5MBcVcbFOWQooJjjBRHM5k/hRXA==", + "version": "1.1.43", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.43.tgz", + "integrity": "sha512-bgzzKN9SxJaYhh+BN3tuLSgdphWsxAOHgNjWWay3o/ib8/c2RwRlmjoxzxXrIhKFEwJjGIo7w04045VgkoWkMQ==", "requires": { "@pushrocks/smartpromise": "^3.0.5", "@types/form-data": "^2.5.0", @@ -330,9 +330,9 @@ } }, "@pushrocks/smartstring": { - "version": "3.0.14", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.14.tgz", - "integrity": "sha512-hN3IwTb5VBUis8Z5U5U6dDCnap6zBmkc9/IVx8lxAbsxl5TYQ4RiYlJ2JM4tih7EdE80ZeSdpprzChYrWmSwDg==", + "version": "3.0.17", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.17.tgz", + "integrity": "sha512-60JQptpgw+PjxoC5Gx+Y9m3/dtMstHC5ElpdJhIlbJ7dQV7LkCGSonLAG+NZhPbvrhow2KZ3fob8stW0Iuy3JQ==", "requires": { "crypto-random-string": "^3.0.1", "js-base64": "^2.5.1", @@ -355,21 +355,22 @@ } }, "@pushrocks/tapbundle": { - "version": "3.0.13", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.13.tgz", - "integrity": "sha512-23O4UMBafCuD+RnUlXNvtT9DGbL1HMD+xZE1Zcr7Ll7WvgxUgRQQfk9kq6qbLLbjaRe1J2Ijsgh1HuZbBaucLQ==", + "version": "3.2.0", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.0.tgz", + "integrity": "sha512-xnKIGe7NJqxWBaFeKIEXShDjV2wap1XJqmlp3m1MKqmIF62vRpZnkzpyE1ZAoNwiYQmIsXIpvP/PDv+iPevPfw==", "dev": true, "requires": { "@pushrocks/early": "^3.0.3", "@pushrocks/smartdelay": "^2.0.3", + "@pushrocks/smartfile": "^7.0.6", "@pushrocks/smartpromise": "^3.0.2", "smartchai": "^2.0.1" } }, "@types/chai": { - "version": "4.2.4", - "resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.4.tgz", - "integrity": "sha512-7qvf9F9tMTzo0akeswHPGqgUx/gIaJqrOEET/FCD8CFRkSUHlygQiM5yB6OvjrtdxBVLSyw7COJubsFYs0683g==", + "version": "4.2.7", + "resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.7.tgz", + "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", "dev": true }, "@types/chai-as-promised": { @@ -443,9 +444,9 @@ "dev": true }, "@types/node": { - "version": "12.11.7", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.11.7.tgz", - "integrity": "sha512-JNbGaHFCLwgHn/iCckiGSOZ1XYHsKFwREtzPwSGCVld1SGhOlmZw2D4ZI94HQCrBHbADzW9m4LER/8olJTRGHA==" + "version": "13.1.6", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.1.6.tgz", + "integrity": "sha512-Jg1F+bmxcpENHP23sVKkNuU3uaxPnsBMW0cLjleiikFKomJQbsn0Cqk2yDvQArqzZN6ABfBkZ0To7pQ8sLdWDg==" }, "@types/through2": { "version": "2.0.34", @@ -1056,16 +1057,16 @@ } }, "mime-db": { - "version": "1.40.0", - "resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + "version": "1.43.0", + "resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" }, "mime-types": { - "version": "2.1.24", - "resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "version": "2.1.26", + "resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "requires": { - "mime-db": "1.40.0" + "mime-db": "1.43.0" } }, "mimic-fn": { @@ -1342,9 +1343,9 @@ "dev": true }, "resolve": { - "version": "1.12.0", - "resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "version": "1.14.2", + "resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.14.2.tgz", + "integrity": "sha512-EjlOBLBO1kxsUxsKjLt7TAECyKW6fOh1VRkykQkKGzcBbjjPIxBqGh0jf7GJ3k/f5mxMqW3htMD3WdTUVtW8HQ==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1525,9 +1526,9 @@ "dev": true }, "tslint": { - "version": "5.20.0", - "resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.0.tgz", - "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "version": "5.20.1", + "resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", diff --git a/package.json b/package.json index 4b7d070..09de59f 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,15 @@ "@gitzone/tsbuild": "^2.0.22", "@gitzone/tstest": "^1.0.15", "@pushrocks/qenv": "^4.0.6", - "@pushrocks/tapbundle": "^3.0.7", - "@types/node": "^12.11.7", - "tslint": "^5.11.0", + "@pushrocks/tapbundle": "^3.2.0", + "@types/node": "^13.1.6", + "tslint": "^5.20.1", "tslint-config-prettier": "^1.15.0" }, "dependencies": { "@pushrocks/smartmail": "^1.0.6", - "@pushrocks/smartrequest": "^1.1.41", - "@pushrocks/smartstring": "^3.0.14" + "@pushrocks/smartrequest": "^1.1.43", + "@pushrocks/smartstring": "^3.0.17" }, "files": [ "ts/**/*", diff --git a/ts/mailgun.classes.account.ts b/ts/mailgun.classes.account.ts index 8672aeb..d0e776b 100644 --- a/ts/mailgun.classes.account.ts +++ b/ts/mailgun.classes.account.ts @@ -2,6 +2,7 @@ import * as plugins from './mailgun.plugins'; export class MailgunAccount { public baseUrl = 'https://api.mailgun.net/v3'; + public baseUrlSe = 'https://se.api.mailgun.net/v3'; public apiToken: string; constructor(apiTokenArg: string) { @@ -9,8 +10,10 @@ export class MailgunAccount { } public getRequest(routeArg: string) { - const requestUrl = `${this.baseUrl}${routeArg}`; // TODO; - const response = plugins.smartrequest.request(routeArg, { + let requestUrl = routeArg; + const needsBaseUrlPrefix = (routeArg.startsWith(this.baseUrl)) || routeArg.startsWith(this.baseUrlSe); + needsBaseUrlPrefix ? requestUrl = `${this.baseUrl}${routeArg}` : null; + const response = plugins.smartrequest.request(requestUrl, { method: 'GET', headers: { Authorization: `Basic ${plugins.smartstring.base64.encode( @@ -19,6 +22,7 @@ export class MailgunAccount { 'Content-Type': 'application/json' } }); + return response; } public async postFormData(routeArg: string, formFields: plugins.smartrequest.IFormField[]) { @@ -78,7 +82,17 @@ export class MailgunAccount { if (response.statusCode === 200) { return response.body; } else { + console.log(response.body); throw new Error('could not send email'); } } + + public async retrieveSmartMailFromMessageUrl(messageUrlArg: string) { + const response = await this.getRequest(messageUrlArg); + return response.body; + } + + public async retrieveSmartMailFromNotifyPayload(notifyPayloadArg: any) { + return await this.retrieveSmartMailFromMessageUrl(notifyPayloadArg['message-url']); + } }