10 Commits

Author SHA1 Message Date
275c4351e4 1.0.11 2019-11-22 16:13:49 +00:00
8dd5f59286 fix(build): now including all necessary types 2019-11-22 16:13:48 +00:00
6e5faaef35 1.0.10 2019-11-22 14:15:38 +00:00
5aa148ef7d fix(security): update snyk 2019-11-22 14:15:37 +00:00
9a08c869ed 1.0.9 2019-11-22 14:02:57 +00:00
37850f92b6 fix(core): update 2019-11-22 14:02:56 +00:00
cf02cd86e5 1.0.8 2019-11-21 14:01:42 +00:00
d50cb5449a fix(core): update 2019-11-21 14:01:41 +00:00
c40d745f98 1.0.7 2019-11-18 16:26:02 +00:00
a619fbb239 fix(readme): show how to instantiate account 2019-11-18 16:26:01 +00:00
8 changed files with 218 additions and 78 deletions

9
.snyk Normal file
View File

@@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.5
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
SNYK-JS-MARKED-451341:
- '@pushrocks/smartletter > @pushrocks/smartmarkdown > marked':
reason: None given
expires: '2019-12-22T14:15:23.685Z'
patch: {}

114
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@mojoio/letterxpress",
"version": "1.0.6",
"version": "1.0.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -99,7 +99,6 @@
"version": "3.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.11.tgz",
"integrity": "sha512-SDKRPj9+xBTqozlDPcA7O6BcccM1Tw/sXPVP+OnhNxCubDZ/L2kGNpPpqm43NJUoNxSSo5wdBw4N7MAFYCGdVg==",
"dev": true,
"requires": {
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartpromise": "^3.0.2",
@@ -160,20 +159,12 @@
"@pushrocks/smartpromise": "^3.0.6",
"@types/node": "^12.12.7",
"is-wsl": "^2.1.1"
},
"dependencies": {
"@types/node": {
"version": "12.12.8",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.8.tgz",
"integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w=="
}
}
},
"@pushrocks/smartevent": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartevent/-/smartevent-2.0.3.tgz",
"integrity": "sha512-x4B1mzzE6LrMATXsRLNuZpMTlB2JodL44MA4bF4FucU3SBBiWhFv3CFJRlO9B23SKZ1fwdJQrk2lT7YTUHXXJQ==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^2.0.5"
},
@@ -181,8 +172,7 @@
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==",
"dev": true
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
}
},
@@ -213,12 +203,12 @@
}
},
"@pushrocks/smarthash": {
"version": "2.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.0.6.tgz",
"integrity": "sha512-jHk9srgRLkszk/oPCUOkxTX2Fqu7qKwx13aEeSIBx8UCtFbXPLecJAqEaGEVk1mw9e4Oq0iC6O0jEnxKo5NQwA==",
"version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarthash/-/smarthash-2.1.1.tgz",
"integrity": "sha512-zVfqXsi0T+PZQJpXsQf7KJpoCUOv97q7//ccp5o/07Bo77gjLO966fevYO+1y7pbvLZ0nQ4pE536YmLkgwluPQ==",
"requires": {
"@pushrocks/smartjson": "^3.0.5",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartjson": "^3.0.8",
"@pushrocks/smartpromise": "^3.0.6",
"@types/through2": "^2.0.34",
"through2": "^3.0.1"
}
@@ -234,13 +224,13 @@
}
},
"@pushrocks/smartletter": {
"version": "1.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartletter/-/smartletter-1.0.10.tgz",
"integrity": "sha512-ya2IBEAmH1YfZ+DYsrGBksFShUJkyjpJDgd+pB3uA87tUCkvVDoskAFYFthnMk/RWm7IG1Tml0v1Vj/9QSiz3Q==",
"version": "1.0.16",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartletter/-/smartletter-1.0.16.tgz",
"integrity": "sha512-58+e0TW+lQkmJguq9uegrlk+k34XC2/TrWspMZa7ElviNSi6Xp6ON/lnuf5L6Uos3716t4ErkojwN6VNLJSmjw==",
"requires": {
"@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartmarkdown": "^2.0.2",
"@pushrocks/smartpdf": "^1.0.29",
"@pushrocks/smartpdf": "^2.0.2",
"@tsclass/tsclass": "^2.0.13",
"lit-ntml": "^2.10.0"
}
@@ -286,18 +276,18 @@
}
},
"@pushrocks/smartnetwork": {
"version": "1.1.14",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartnetwork/-/smartnetwork-1.1.14.tgz",
"integrity": "sha512-0zNTypPGqA9mUaGxTPkqHYWDnonY6QpRo5ejVpFMdRI3H/3V4PyKkb6BTOnbMHcUFv38CnvnR9TYteCdiIbLKg==",
"version": "1.1.16",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartnetwork/-/smartnetwork-1.1.16.tgz",
"integrity": "sha512-IWvOqpV/PN4XXQ74fJy5Qc9MThPhY1C0T1IS1AY36wskiS5ExZ8ekT0352uMomTTtsBRtkrLwO+LIiBhFwdnwA==",
"requires": {
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartstring": "^3.0.10",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartstring": "^3.0.14",
"@types/default-gateway": "^3.0.0",
"@types/portscanner": "^2.1.0",
"default-gateway": "^5.0.3",
"default-gateway": "^5.0.5",
"portscanner": "^2.2.0",
"speedtest-net": "^1.5.1",
"systeminformation": "^4.14.8"
"speedtest-net": "^1.6.0",
"systeminformation": "^4.15.3"
}
},
"@pushrocks/smartparam": {
@@ -323,9 +313,9 @@
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA=="
},
"@pushrocks/smartpdf": {
"version": "1.0.29",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpdf/-/smartpdf-1.0.29.tgz",
"integrity": "sha512-McJ9EVEzPs9F6nNT+6okJMwLlJ8kerzevyVjgQPCgjnxk3atdcbc91ojoBerQp3Cjf3c0Dh3xeC4CFDqx2ACKQ==",
"version": "2.0.2",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpdf/-/smartpdf-2.0.2.tgz",
"integrity": "sha512-fzKFWCBbmx76h/rStJckx3dGHOgWRuMalBBCLKLtY+KZk4/fT/kL88Bax4dZ3cCGKDaBfSiJNL9CJX7gsHl70w==",
"requires": {
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartnetwork": "^1.1.14",
@@ -353,9 +343,9 @@
}
},
"@pushrocks/smartrequest": {
"version": "1.1.42",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.42.tgz",
"integrity": "sha512-sCEousyvnbW9IvBVHt3ZTjV1IP2vxJQ8TqG5GqxRk82wyVB0SCZfuMWW/guQA1+DmxfUfMsqBxzvovtM/bOc1w==",
"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",
@@ -367,7 +357,6 @@
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.5.tgz",
"integrity": "sha512-BOlIJmnCO8pxqu9f18D9UV5rIsyrmKeK/mWNMiAe/NH2OTeRPNLpgmhZBkXSKNVD8tSsD8aazs4BcACgYOg1FQ==",
"dev": true,
"requires": {
"@pushrocks/lik": "^3.0.11",
"@pushrocks/smartevent": "^2.0.3",
@@ -404,7 +393,6 @@
"version": "3.0.12",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.12.tgz",
"integrity": "sha512-NoMt1NUhNqcF5y7fCTHoC3d/+MobzgNUg6yHbSGxFRaentQzCrMPNahQIVLbrAStf03LUUBePUjSRdPYucP1gw==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^3.0.2",
"@types/cron": "^1.7.1",
@@ -425,12 +413,13 @@
}
},
"@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==",
"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"
}
@@ -485,7 +474,6 @@
"version": "1.7.1",
"resolved": "https://verdaccio.lossless.one/@types%2fcron/-/cron-1.7.1.tgz",
"integrity": "sha512-48brwgU18DqA0mQX1As5OcJEo1yNjaXMM6Mk4r8K1dOzLJRQ37FE/kCivKx7ClKEHfhX2FdcxKzJ1B744a+V3A==",
"dev": true,
"requires": {
"@types/node": "*",
"moment": ">=2.14.0"
@@ -548,8 +536,7 @@
"@types/luxon": {
"version": "1.15.2",
"resolved": "https://verdaccio.lossless.one/@types%2fluxon/-/luxon-1.15.2.tgz",
"integrity": "sha512-zHPoyVrLvNaiMRYdhmh88Rn489ZgAgbc6iLxR5Yi0VCNfeNYHcszbhJV2vDHLNrVGy35BPtWBRn4OP2F9BBvFw==",
"dev": true
"integrity": "sha512-zHPoyVrLvNaiMRYdhmh88Rn489ZgAgbc6iLxR5Yi0VCNfeNYHcszbhJV2vDHLNrVGy35BPtWBRn4OP2F9BBvFw=="
},
"@types/marked": {
"version": "0.6.5",
@@ -564,13 +551,12 @@
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://verdaccio.lossless.one/@types%2fminimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "10.17.5",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-10.17.5.tgz",
"integrity": "sha512-RElZIr/7JreF1eY6oD5RF3kpmdcreuQPjg5ri4oQ5g9sq7YWU8HkfB3eH8GwAwxf5OaCh0VPi7r4N/yoTGelrA=="
"version": "12.12.11",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.11.tgz",
"integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ=="
},
"@types/portscanner": {
"version": "2.1.0",
@@ -578,9 +564,9 @@
"integrity": "sha512-II0FA05TSt4r7PBUvYTqub+yrXTRu7L/PQnTtjcJYzAeBts6xHM/OA2MKyeQ80sFxX7p+0BTo68Nh1P3N6Oj/g=="
},
"@types/puppeteer": {
"version": "1.20.2",
"resolved": "https://verdaccio.lossless.one/@types%2fpuppeteer/-/puppeteer-1.20.2.tgz",
"integrity": "sha512-oSFCtftHSfVx8K9XPdNNYs79Zt4pYJs/0NP78ltuGCB25zS3UNGJSiypBfbhbvRC5Dcsh0k1R5Z0i8HHtqQUPQ==",
"version": "1.20.3",
"resolved": "https://verdaccio.lossless.one/@types%2fpuppeteer/-/puppeteer-1.20.3.tgz",
"integrity": "sha512-U1H7E4wHDsPe2s7wa2fpUD4kPYmu3n4hYRmlFK4WgKQxXE1ctY2h9Exely8GXs7743gLvrnzuX7aJuyG0SEMIQ==",
"requires": {
"@types/node": "*"
}
@@ -1076,7 +1062,6 @@
"version": "1.7.2",
"resolved": "https://verdaccio.lossless.one/cron/-/cron-1.7.2.tgz",
"integrity": "sha512-+SaJ2OfeRvfQqwXQ2kgr0Y5pzBR/lijf5OpnnaruwWnmI799JfWr2jN2ItOV9s3A/+TFOt6mxvKzQq5F0Jp6VQ==",
"dev": true,
"requires": {
"moment-timezone": "^0.5.x"
}
@@ -1260,9 +1245,9 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
},
"which": {
"version": "2.0.1",
"resolved": "https://verdaccio.lossless.one/which/-/which-2.0.1.tgz",
"integrity": "sha512-N7GBZOTswtB9lkQBZA4+zAXrjEIWAUOB93AvzUiudRzRxhUdLURQ7D/gAIMY1gatT/LTbmbcv8SiYazy3eYB7w==",
"version": "2.0.2",
"resolved": "https://verdaccio.lossless.one/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"requires": {
"isexe": "^2.0.0"
}
@@ -1917,11 +1902,11 @@
"dev": true
},
"is-symbol": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/is-symbol/-/is-symbol-1.0.2.tgz",
"integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/is-symbol/-/is-symbol-1.0.3.tgz",
"integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==",
"requires": {
"has-symbols": "^1.0.0"
"has-symbols": "^1.0.1"
}
},
"is-typedarray": {
@@ -2126,8 +2111,7 @@
"luxon": {
"version": "1.21.1",
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.21.1.tgz",
"integrity": "sha512-3zxaKX7mj7eA80TU0sm4CfNEtiUZ2QXGjMc80rfG4d1dOnnOOWz63U9j4nYR7+1w716DYtWfdOeVhDXYlH+D4w==",
"dev": true
"integrity": "sha512-3zxaKX7mj7eA80TU0sm4CfNEtiUZ2QXGjMc80rfG4d1dOnnOOWz63U9j4nYR7+1w716DYtWfdOeVhDXYlH+D4w=="
},
"make-error": {
"version": "1.3.5",
@@ -2237,14 +2221,12 @@
"moment": {
"version": "2.24.0",
"resolved": "https://verdaccio.lossless.one/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==",
"dev": true
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
},
"moment-timezone": {
"version": "0.5.27",
"resolved": "https://verdaccio.lossless.one/moment-timezone/-/moment-timezone-0.5.27.tgz",
"integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==",
"dev": true,
"requires": {
"moment": ">= 2.9.0"
}
@@ -2744,7 +2726,6 @@
"version": "6.5.3",
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.5.3.tgz",
"integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
}
@@ -3066,8 +3047,7 @@
"tslib": {
"version": "1.10.0",
"resolved": "https://verdaccio.lossless.one/tslib/-/tslib-1.10.0.tgz",
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
"dev": true
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ=="
},
"tslint": {
"version": "5.20.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@mojoio/letterxpress",
"version": "1.0.6",
"version": "1.0.11",
"private": false,
"description": "an unofficial API package for the letterxpress API",
"main": "dist/index.js",
@@ -9,21 +9,23 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/qenv": "^4.0.6",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.12.11",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@pushrocks/smartletter": "^1.0.10",
"@pushrocks/smartrequest": "^1.1.42"
"@pushrocks/smarthash": "^2.1.1",
"@pushrocks/smartletter": "^1.0.16",
"@pushrocks/smartrequest": "^1.1.43",
"@pushrocks/smartrx": "^2.0.5"
},
"files": [
"ts/**/*",

View File

@@ -1,3 +1,3 @@
required:
- API_EMAIL
- API_USERNAME
- API_TOKEN

View File

@@ -22,6 +22,15 @@ Use TypeScript for best in class intellisense.
letterxpress implements the LXP API documented here: [LXP API Documentation](https://www.letterxpress.de/briefe-uebertragen/api)
```typescript
import * as letterxpress from '@mojoio/letterxpress'
const account = new letterxpress.LetterXpressAccount({
email: 'myemail@example.com',
apiToken: 'abcdefghijklmnop1234567890'
})
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@@ -1,17 +1,95 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as letterxpress from '../ts/index';
import * as smartletter from '@pushrocks/smartletter';
const smartletterInstance = new smartletter.Smartletter();
let testletter: smartletter.Letter;
import { Qenv } from '@pushrocks/qenv';
let testQenv = new Qenv('./', './.nogit/');
let testAccount: letterxpress.LetterXpressAccount;
tap.test('start things', async () => {
await smartletterInstance.start();
});
tap.test('should create a valid account', async () => {
testAccount = new letterxpress.LetterXpressAccount({
apiKey: testQenv.getEnvVarOnDemand('API_TOKEN'),
email: testQenv.getEnvVarOnDemand('API_EMAIL')
username: testQenv.getEnvVarOnDemand('API_USERNAME')
});
expect(testAccount).to.be.instanceOf(letterxpress.LetterXpressAccount);
});
tap.test('should send an actual letter', async () => {
testletter = await smartletterInstance.createLetter({
from: {
name: 'Lossless GmbH',
city: 'Bremen',
country: 'Germany',
postalCode: '28213',
houseNumber: '16',
streetName: 'Ottilie-Hoffmann-Str.'
},
to: {
name: 'Lossless GmbH',
city: 'Berlin',
country: 'Germany',
postalCode: '10245',
houseNumber: '16a, Scanbox #06320',
streetName: 'Ehrenbergstr.'
},
incidenceId: 'abc123',
legalInfo: {
name: 'Lossless GmbH',
status: 'active',
contact: {
type: 'company',
salutation: null,
surname: null,
title: null,
address: {
city: 'Bremen',
country: 'Germany',
houseNumber: '16',
name: 'Lossless GmbH',
postalCode: '28213',
streetName: 'Ottilie-Hoffmann Str.'
},
bankAccountNumber: 'NL83 BUNQ 2035 5639 41',
customerNumber: null,
description: null,
email: 'hello@lossless.com',
fax: '+49 421 408951 46',
phone: '+49 421 16767 548',
legalEntity: 'Lossless GmbH',
name: 'Lossless GmbH',
vatId: 'DE293580420'
},
closedDate: null,
foundedDate: null
},
subject: 'General Terms - Update',
text: `<p>To whome it may concern,</p>
<p>
<strong>this is a testmessage.</strong> we write to inform you about a change in our General Terms.
As of December 1st 2019 we will start storing IPs that connect to our app for a period of 3 month.
<p>
Regards<br>
Lossless GmbH - Legal Department`
});
await testAccount.sendLetter(testletter);
});
tap.test('should be able to delete the sending job', async () => {
await testAccount.cancelLetter(testletter);
});
tap.test('should wrap things up', async () => {
await smartletterInstance.stop();
})
tap.start();

View File

@@ -1,16 +1,75 @@
import * as plugins from './letterxpress.plugins';
import { response } from 'express';
export interface ILetterXpressConstructorOptions {
email: string;
username: string;
apiKey: string;
}
export class LetterXpressAccount {
public baseApiUrl = 'https://api.letterxpress.de/v1';
public options: ILetterXpressConstructorOptions;
public letterSentObservable = new plugins.smartrx.rxjs.Subject<plugins.smartletter.Letter>();
constructor(optionsArg: ILetterXpressConstructorOptions) {
this.options = optionsArg;
}
public request() {}
/**
* sends a letter
* @param letterArg
*/
public async sendLetter(letterArg: plugins.smartletter.Letter) {
const letterPdfResult = await letterArg.getPdfResult();
const response = await this.request('/setJob', 'POST', {
letter: {
base64_file: letterPdfResult.buffer.toString('base64'),
base64_checksum: await plugins.smarthash.md5FromString(
letterPdfResult.buffer.toString('base64')
),
specification: {
color: '4',
mode: 'simplex',
ship: letterArg.options.to.country === 'Germany' ? 'national' : 'international'
}
}
});
letterArg.setProcessingId(response.body.letter.job_id);
return letterArg;
}
public async cancelLetter(letterArg: plugins.smartletter.Letter) {
const processingId = letterArg.getProcessingId();
return await this.cancelLetterByProcessingId(processingId);
}
public async cancelLetterByProcessingId(processingId: string) {
const response = await this.request(`/deleteJob/${processingId}`, 'DELETE');
return response;
}
/**
* fires the request
*/
private async request(routeArg: string, methodArg: 'GET' | 'POST' | 'DELETE', payload: any = {}) {
const requestUrl = `${this.baseApiUrl}${routeArg}`;
console.log(requestUrl);
const requestData = {
auth: {
username: this.options.username,
apikey: this.options.apiKey
},
...payload
};
const response = await plugins.smartrequest.request(requestUrl, {
method: methodArg,
headers: {
'Content-Type': 'application/json'
},
requestBody: JSON.stringify(requestData)
});
console.log(response.body);
return response;
}
}

View File

@@ -1,3 +1,6 @@
import * as smartletter from '@pushrocks/smartletter';
import * as smarthash from '@pushrocks/smarthash';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartrx from '@pushrocks/smartrx';
export { smartrequest };
export { smarthash, smartletter, smartrequest, smartrx };