@vasrefil/api-toolkit 1.1.2 → 1.2.0
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.
|
@@ -28,9 +28,10 @@ class GoMailerUtil_ {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
this.send_user_event = async (payload) => {
|
|
31
|
+
let body;
|
|
31
32
|
try {
|
|
32
33
|
const { actionType, user, transaction } = payload;
|
|
33
|
-
|
|
34
|
+
body = {
|
|
34
35
|
event_code: actionType,
|
|
35
36
|
contact_email: user.email,
|
|
36
37
|
context: {
|
|
@@ -46,7 +47,14 @@ class GoMailerUtil_ {
|
|
|
46
47
|
await this.trigger_event(body);
|
|
47
48
|
}
|
|
48
49
|
catch (error) {
|
|
49
|
-
|
|
50
|
+
log_util_1.LogUtil.app_log({
|
|
51
|
+
distinct_id: 'admin',
|
|
52
|
+
response: error,
|
|
53
|
+
request: { body },
|
|
54
|
+
function_name: "GoMailerUtil_send_event",
|
|
55
|
+
category: "SEND_EVENT",
|
|
56
|
+
subcategory: "GO_MAILER_SEND_EVENT",
|
|
57
|
+
});
|
|
50
58
|
}
|
|
51
59
|
};
|
|
52
60
|
this.trigger_event = async (payload) => {
|
|
@@ -58,15 +66,18 @@ class GoMailerUtil_ {
|
|
|
58
66
|
}
|
|
59
67
|
catch (error) {
|
|
60
68
|
const err = helpers_1.RequestHelper.get_error(error);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
this.send_transactional_email = async (payload) => {
|
|
73
|
+
try {
|
|
74
|
+
const headers = { Authorization: `Bearer ${env_1.default.GO_MAILER.API_KEY}` };
|
|
75
|
+
const url = 'https://mailing.go-mailer.com/api/v1/transactionals/dispatch';
|
|
76
|
+
const { data } = await axios_1.default.post(url, payload, { headers });
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
70
81
|
throw err;
|
|
71
82
|
}
|
|
72
83
|
};
|