@nimee/inforu 1.0.10 → 1.0.11
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/sendEmail.js +23 -22
- package/dist/sendEmail.js.map +1 -1
- package/package.json +1 -1
- package/src/sendEmail.ts +24 -23
package/dist/sendEmail.js
CHANGED
|
@@ -42,29 +42,30 @@ function sendEmail(params) {
|
|
|
42
42
|
try {
|
|
43
43
|
const { apiKey, campaignName, fromAddress, replyAddress, fromName, subject, preHeader, body, contacts } = params;
|
|
44
44
|
if (!apiKey || !campaignName || !fromAddress || !replyAddress || !fromName || !subject || !body || !contacts) {
|
|
45
|
-
|
|
46
|
-
const normalizeContact = (0, normalize_1.prepareContactsPayload)(contactsPayload);
|
|
47
|
-
const apiUrl = "https://capi.inforu.co.il/api/v2/Umail/Message/Send";
|
|
48
|
-
const data = {
|
|
49
|
-
Data: {
|
|
50
|
-
CampaignName: campaignName,
|
|
51
|
-
FromAddress: fromAddress,
|
|
52
|
-
ReplyAddress: replyAddress,
|
|
53
|
-
FromName: fromName,
|
|
54
|
-
Subject: subject,
|
|
55
|
-
PreHeader: preHeader,
|
|
56
|
-
Body: body,
|
|
57
|
-
IncludeContacts: normalizeContact,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
const response = yield axios_1.default.post(apiUrl, data, {
|
|
61
|
-
headers: {
|
|
62
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
63
|
-
Authorization: apiKey,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
return response.data;
|
|
45
|
+
throw new error_handler_1.CustomError("Missing_params_inforu_send_mail", 450, `Missing params in sendMail ${JSON.stringify(params)}`);
|
|
67
46
|
}
|
|
47
|
+
const contactsPayload = { endUsers: contacts };
|
|
48
|
+
const normalizeContact = (0, normalize_1.prepareContactsPayload)(contactsPayload);
|
|
49
|
+
const apiUrl = "https://capi.inforu.co.il/api/v2/Umail/Message/Send";
|
|
50
|
+
const data = {
|
|
51
|
+
Data: {
|
|
52
|
+
CampaignName: campaignName,
|
|
53
|
+
FromAddress: fromAddress,
|
|
54
|
+
ReplyAddress: replyAddress,
|
|
55
|
+
FromName: fromName,
|
|
56
|
+
Subject: subject,
|
|
57
|
+
PreHeader: preHeader,
|
|
58
|
+
Body: body,
|
|
59
|
+
IncludeContacts: normalizeContact,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const response = yield axios_1.default.post(apiUrl, data, {
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
65
|
+
Authorization: apiKey,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
return response.data;
|
|
68
69
|
}
|
|
69
70
|
catch (error) {
|
|
70
71
|
const errorResponse = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
|
package/dist/sendEmail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../src/sendEmail.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,qfAAqf;;;;;;;;;;;;;;;AAErf,iBAAiB;AACjB,oBAAoB;AACpB,2BAA2B;AAC3B,gEAAgE;AAChE,eAAe;AACf,yDAAyD;AACzD,+CAA+C;AAC/C,OAAO;AACP,gBAAgB;AAChB,KAAK;AAEL,gBAAgB;AAChB,8BAA8B;AAC9B,gDAAgD;AAChD,KAAK;AACL,4BAA4B;AAC5B,wBAAwB;AACxB,MAAM;AACN,wDAAiE;AACjE,2DAAmC;AAEnC,kDAA0B;AAC1B,2CAAqD;AAErD,SAAsB,SAAS,CAAC,MAU/B;;;QACC,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;YACjH,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,IAAI,CAAC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MAAM,GAAG,qDAAqD,CAAC;YACrE,MAAM,IAAI,GAAG;gBACX,IAAI,EAAE;oBACJ,YAAY,EAAE,YAAY;oBAC1B,WAAW,EAAE,WAAW;oBACxB,YAAY,EAAE,YAAY;oBAC1B,QAAQ,EAAE,QAAQ;oBAClB,OAAO,EAAE,OAAO;oBAChB,SAAS,EAAE,SAAS;oBACpB,IAAI,EAAE,IAAI;oBACV,eAAe,EAAE,gBAAgB;iBAClC;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE;gBAC9C,OAAO,EAAE;oBACP,cAAc,EAAE,iCAAiC;oBACjD,aAAa,EAAE,MAAM;iBACtB;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,aAAa,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAC3C,IAAI,aAAa,EAAE,CAAC;gBAClB,gBAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,gBAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,MAAM,IAAI,2BAAW,CAAC,6BAA6B,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACnE,CAAC;;CACF;AAjDD,8BAiDC"}
|
package/package.json
CHANGED
package/src/sendEmail.ts
CHANGED
|
@@ -39,31 +39,32 @@ export async function sendEmail(params: {
|
|
|
39
39
|
try {
|
|
40
40
|
const { apiKey, campaignName, fromAddress, replyAddress, fromName, subject, preHeader, body, contacts } = params;
|
|
41
41
|
if (!apiKey || !campaignName || !fromAddress || !replyAddress || !fromName || !subject || !body || !contacts) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
throw new CustomError("Missing_params_inforu_send_mail", 450, `Missing params in sendMail ${JSON.stringify(params)}`);
|
|
43
|
+
}
|
|
44
|
+
const contactsPayload = { endUsers: contacts };
|
|
45
|
+
const normalizeContact = prepareContactsPayload(contactsPayload);
|
|
46
|
+
const apiUrl = "https://capi.inforu.co.il/api/v2/Umail/Message/Send";
|
|
47
|
+
const data = {
|
|
48
|
+
Data: {
|
|
49
|
+
CampaignName: campaignName,
|
|
50
|
+
FromAddress: fromAddress,
|
|
51
|
+
ReplyAddress: replyAddress,
|
|
52
|
+
FromName: fromName,
|
|
53
|
+
Subject: subject,
|
|
54
|
+
PreHeader: preHeader,
|
|
55
|
+
Body: body,
|
|
56
|
+
IncludeContacts: normalizeContact,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const response = await axios.post(apiUrl, data, {
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
63
|
+
Authorization: apiKey,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
+
return response.data;
|
|
67
68
|
} catch (error: any) {
|
|
68
69
|
const errorResponse = error.response?.data;
|
|
69
70
|
if (errorResponse) {
|