@vasrefil/api-toolkit 1.5.2 → 1.6.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.
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
|
@@ -22,6 +22,7 @@ declare class GoMailerUtil_ {
|
|
|
22
22
|
}) => Promise<void>;
|
|
23
23
|
trigger_event: (payload: GoMailerEventPayload) => Promise<any>;
|
|
24
24
|
send_transactional_email: (payload: GoMailerEmailPayload) => Promise<any>;
|
|
25
|
+
sync_contact: (payload: any, throw_new_error?: boolean) => Promise<any>;
|
|
25
26
|
}
|
|
26
27
|
declare const GoMailerUtil: GoMailerUtil_;
|
|
27
28
|
export { GoMailerUtil };
|
|
@@ -13,6 +13,8 @@ class GoMailerUtil_ {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
this.send_event = async (dto) => {
|
|
15
15
|
try {
|
|
16
|
+
if (env_1.default.NODE_ENV !== env_1.default.NODE_ENVS.PROD)
|
|
17
|
+
return;
|
|
16
18
|
const { req, actionType } = dto.serviceResponse;
|
|
17
19
|
const user = req.user;
|
|
18
20
|
const transaction = req.transaction;
|
|
@@ -84,6 +86,18 @@ class GoMailerUtil_ {
|
|
|
84
86
|
throw err;
|
|
85
87
|
}
|
|
86
88
|
};
|
|
89
|
+
this.sync_contact = async (payload, throw_new_error = false) => {
|
|
90
|
+
try {
|
|
91
|
+
const headers = { Authorization: `Bearer ${env_1.default.GO_MAILER.API_KEY}` };
|
|
92
|
+
const url = 'https://api.go-mailer.com/v1/contacts';
|
|
93
|
+
const { data } = await axios_1.default.post(url, payload, { headers });
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
98
|
+
throw throw_new_error ? new Error(err) : err;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
103
|
const GoMailerUtil = new GoMailerUtil_;
|