@vasrefil/api-toolkit 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const env_1 = __importDefault(require("../env"));
|
|
9
9
|
const log_util_1 = require("./log.util");
|
|
10
10
|
const helpers_1 = require("../helpers");
|
|
11
|
+
const log_interface_1 = require("../interfaces/log.interface");
|
|
11
12
|
class GoMailerUtil_ {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.send_event = async (dto) => {
|
|
@@ -28,9 +29,10 @@ class GoMailerUtil_ {
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
this.send_user_event = async (payload) => {
|
|
32
|
+
let body;
|
|
31
33
|
try {
|
|
32
34
|
const { actionType, user, transaction } = payload;
|
|
33
|
-
|
|
35
|
+
body = {
|
|
34
36
|
event_code: actionType,
|
|
35
37
|
contact_email: user.email,
|
|
36
38
|
context: {
|
|
@@ -46,7 +48,15 @@ class GoMailerUtil_ {
|
|
|
46
48
|
await this.trigger_event(body);
|
|
47
49
|
}
|
|
48
50
|
catch (error) {
|
|
49
|
-
|
|
51
|
+
log_util_1.LogUtil.app_log({
|
|
52
|
+
distinct_id: 'admin',
|
|
53
|
+
response: error,
|
|
54
|
+
request: { body },
|
|
55
|
+
function_name: "GoMailerUtil_send_event",
|
|
56
|
+
category: "SEND_EVENT",
|
|
57
|
+
subcategory: "GO_MAILER_SEND_EVENT",
|
|
58
|
+
log_status: log_interface_1.AppLogStatusI.unresolved
|
|
59
|
+
});
|
|
50
60
|
}
|
|
51
61
|
};
|
|
52
62
|
this.trigger_event = async (payload) => {
|
|
@@ -58,15 +68,18 @@ class GoMailerUtil_ {
|
|
|
58
68
|
}
|
|
59
69
|
catch (error) {
|
|
60
70
|
const err = helpers_1.RequestHelper.get_error(error);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
this.send_transactional_email = async (payload) => {
|
|
75
|
+
try {
|
|
76
|
+
const headers = { Authorization: `Bearer ${env_1.default.GO_MAILER.API_KEY}` };
|
|
77
|
+
const url = 'https://mailing.go-mailer.com/api/v1/transactionals/dispatch';
|
|
78
|
+
const { data } = await axios_1.default.post(url, payload, { headers });
|
|
79
|
+
return data;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
70
83
|
throw err;
|
|
71
84
|
}
|
|
72
85
|
};
|