@ikoabo/notifications
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,4 +8,4 @@ "use strict"; | ||
const core_1 = require("@ikoabo/core"); | ||
const request_1 = __importDefault(require("request")); | ||
const errors_enum_1 = require("../models/errors.enum"); | ||
const axios_1 = __importDefault(require("axios")); | ||
class Mails { | ||
@@ -28,3 +28,3 @@ constructor() { | ||
reject({ | ||
boError: errors_enum_1.NOTIFICATION_ERRORS.INVALID_NOTIFICATIONS_SERVER, | ||
boError: errors_enum_1.NOTIFICATION_ERRORS.INVALID_MAIL_SERVER, | ||
boStatus: core_1.HTTP_STATUS.HTTP_4XX_NOT_ACCEPTABLE | ||
@@ -34,25 +34,21 @@ }); | ||
} | ||
const opts = { | ||
auth: { bearer: this._token }, | ||
json: { | ||
project: project, | ||
mail: mail, | ||
subject: subject, | ||
lang: lang, | ||
to: to, | ||
cc: cc, | ||
bcc: bcc, | ||
data: data | ||
axios_1.default | ||
.post(`${this._notificationsService}/v1/mails/send`, { | ||
project: project, | ||
mail: mail, | ||
subject: subject, | ||
lang: lang, | ||
to: to, | ||
cc: cc, | ||
bcc: bcc, | ||
data: data | ||
}, { | ||
headers: { | ||
Authorization: `Bearer ${this._token}` | ||
} | ||
}; | ||
request_1.default.post(`${this._notificationsService}/v1/mails/send`, opts, (error, response, body) => { | ||
if (error) { | ||
reject({ | ||
boError: errors_enum_1.NOTIFICATION_ERRORS.UNKNOWN_NOTIFICATIONS_SERVER_ERROR, | ||
boStatus: core_1.HTTP_STATUS.HTTP_4XX_FORBIDDEN | ||
}); | ||
return; | ||
} | ||
}) | ||
.then((response) => { | ||
try { | ||
body = JSON.parse(body); | ||
JSON.parse(response.data); | ||
resolve(); | ||
} | ||
@@ -66,7 +62,15 @@ catch (_a) { | ||
} | ||
if (body["error"]) { | ||
reject({ boStatus: response.statusCode, boError: body["error"], boData: body["data"] }); | ||
return; | ||
}) | ||
.catch((err) => { | ||
if (core_1.Objects.get(err, "response.data.error", null)) { | ||
return reject({ | ||
boStatus: err.response.status, | ||
boError: core_1.Objects.get(err, "response.data.error", null), | ||
boData: core_1.Objects.get(err, "response.data.data", null) | ||
}); | ||
} | ||
resolve(); | ||
reject({ | ||
boError: errors_enum_1.NOTIFICATION_ERRORS.UNKNOWN_NOTIFICATIONS_SERVER_ERROR, | ||
boStatus: core_1.HTTP_STATUS.HTTP_4XX_FORBIDDEN | ||
}); | ||
}); | ||
@@ -73,0 +77,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NOTIFICATION_ERRORS = exports.MailCtrl = void 0; | ||
var mails_controller_1 = require("./controllers/mails.controller"); | ||
@@ -4,0 +5,0 @@ Object.defineProperty(exports, "MailCtrl", { enumerable: true, get: function () { return mails_controller_1.MailCtrl; } }); |
export declare enum NOTIFICATION_ERRORS { | ||
INVALID_TEMPLATE = 1501, | ||
INVALID_SETTINGS = 1502, | ||
INVALID_NOTIFICATIONS_SERVER = 1503, | ||
UNKNOWN_NOTIFICATIONS_SERVER_ERROR = 1504 | ||
UNKNOWN_NOTIFICATIONS_SERVER_ERROR = 1500, | ||
INVALID_MAIL_TEMPLATE = 1501, | ||
INVALID_MAIL_SETTINGS = 1502, | ||
INVALID_MAIL_SERVER = 1503, | ||
INVALID_PUSH_NOTIFICATION = 1525, | ||
INVALID_TELEGRAM_SETTINGS = 1550, | ||
INVALID_TELEGRAM_AUTHENTICATION = 1551 | ||
} |
@@ -6,7 +6,10 @@ "use strict"; | ||
(function (NOTIFICATION_ERRORS) { | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_TEMPLATE"] = 1501] = "INVALID_TEMPLATE"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_SETTINGS"] = 1502] = "INVALID_SETTINGS"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_NOTIFICATIONS_SERVER"] = 1503] = "INVALID_NOTIFICATIONS_SERVER"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["UNKNOWN_NOTIFICATIONS_SERVER_ERROR"] = 1504] = "UNKNOWN_NOTIFICATIONS_SERVER_ERROR"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["UNKNOWN_NOTIFICATIONS_SERVER_ERROR"] = 1500] = "UNKNOWN_NOTIFICATIONS_SERVER_ERROR"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_MAIL_TEMPLATE"] = 1501] = "INVALID_MAIL_TEMPLATE"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_MAIL_SETTINGS"] = 1502] = "INVALID_MAIL_SETTINGS"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_MAIL_SERVER"] = 1503] = "INVALID_MAIL_SERVER"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_PUSH_NOTIFICATION"] = 1525] = "INVALID_PUSH_NOTIFICATION"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_TELEGRAM_SETTINGS"] = 1550] = "INVALID_TELEGRAM_SETTINGS"; | ||
NOTIFICATION_ERRORS[NOTIFICATION_ERRORS["INVALID_TELEGRAM_AUTHENTICATION"] = 1551] = "INVALID_TELEGRAM_AUTHENTICATION"; | ||
})(NOTIFICATION_ERRORS = exports.NOTIFICATION_ERRORS || (exports.NOTIFICATION_ERRORS = {})); | ||
//# sourceMappingURL=errors.enum.js.map |
{ | ||
"name": "@ikoabo/notifications", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "IKOA Business Opportunity Notifications API", | ||
@@ -8,9 +8,10 @@ "main": "lib/index.js", | ||
"engines": { | ||
"npm": ">=12.16.1" | ||
"node": ">=12.0.0", | ||
"npm": ">=6.0.0" | ||
}, | ||
"scripts": { | ||
"prepare": "install-peers", | ||
"build": "tsc", | ||
"deploy": "tsc && npm run publish-npm && npm run publish-nexus", | ||
"deploy": "tsc && npm run publish-npm", | ||
"publish-npm": "npm publish --registry='https://registry.npmjs.org/' --access public", | ||
"publish-nexus": "npm publish --registry='https://nxs.ikoabo.com/repository/npm-local/'", | ||
"lint": "tsc --noEmit && eslint '*/**/*.ts' --fix", | ||
@@ -41,22 +42,24 @@ "test": "mocha --require ts-node/register tests/*.ts", | ||
"dependencies": { | ||
"@ikoabo/core": "^1.0.5", | ||
"request": "^2.88.2" | ||
"@ikoabo/core": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.11", | ||
"@types/mocha": "^7.0.2", | ||
"@types/request": "^2.48.5", | ||
"@typescript-eslint/eslint-plugin": "^3.9.0", | ||
"@typescript-eslint/parser": "^3.9.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.7.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"mocha": "^7.1.1", | ||
"@types/chai": "^4.2.18", | ||
"@types/mocha": "^8.2.2", | ||
"@typescript-eslint/eslint-plugin": "^4.26.0", | ||
"@typescript-eslint/parser": "^4.26.0", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.27.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"install-peers-cli": "^2.2.0", | ||
"mocha": "^8.4.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.0.5", | ||
"ts-node": "^8.10.2", | ||
"typescript": "^3.8.3" | ||
"prettier": "^2.3.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.2" | ||
}, | ||
"peerDependencies": { | ||
"axios": "0.21.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13208
118
12
+ Addedaxios@0.21.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removedrequest@^2.88.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updated@ikoabo/core@^1.1.2