wexa-chat 0.3.2 → 0.3.3
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/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +60 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -176,6 +176,7 @@ interface IMessage extends Document {
|
|
|
176
176
|
linkedin?: {
|
|
177
177
|
subject?: string;
|
|
178
178
|
isInMail?: boolean;
|
|
179
|
+
linkedinApi?: string;
|
|
179
180
|
senderName?: string;
|
|
180
181
|
senderProfileUrl?: string;
|
|
181
182
|
};
|
|
@@ -276,6 +277,7 @@ type SendMessageArgs = {
|
|
|
276
277
|
linkedin?: {
|
|
277
278
|
subject?: string;
|
|
278
279
|
isInMail?: boolean;
|
|
280
|
+
linkedinApi?: 'classic' | 'recruiter' | 'sales_navigator';
|
|
279
281
|
};
|
|
280
282
|
};
|
|
281
283
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ interface IMessage extends Document {
|
|
|
176
176
|
linkedin?: {
|
|
177
177
|
subject?: string;
|
|
178
178
|
isInMail?: boolean;
|
|
179
|
+
linkedinApi?: string;
|
|
179
180
|
senderName?: string;
|
|
180
181
|
senderProfileUrl?: string;
|
|
181
182
|
};
|
|
@@ -276,6 +277,7 @@ type SendMessageArgs = {
|
|
|
276
277
|
linkedin?: {
|
|
277
278
|
subject?: string;
|
|
278
279
|
isInMail?: boolean;
|
|
280
|
+
linkedinApi?: 'classic' | 'recruiter' | 'sales_navigator';
|
|
279
281
|
};
|
|
280
282
|
};
|
|
281
283
|
};
|
package/dist/index.js
CHANGED
|
@@ -594,32 +594,67 @@ function createMessagesService(models, hooks = {}) {
|
|
|
594
594
|
const linkedinMeta = metadata == null ? void 0 : metadata.linkedin;
|
|
595
595
|
lastLinkedInId = LinkedinConnector == null ? void 0 : LinkedinConnector.connectorId;
|
|
596
596
|
if (LinkedinConnector) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
597
|
+
if (linkedinMeta == null ? void 0 : linkedinMeta.isInMail) {
|
|
598
|
+
const missingFields = [];
|
|
599
|
+
if (!linkedinMeta.subject) missingFields.push("subject");
|
|
600
|
+
if (!linkedinMeta.linkedinApi) missingFields.push("linkedinApi");
|
|
601
|
+
if (missingFields.length > 0) {
|
|
602
|
+
failed_source.push({
|
|
603
|
+
source: "linkedin",
|
|
604
|
+
message: `InMail requires the following fields: ${missingFields.join(", ")}`
|
|
605
|
+
});
|
|
606
|
+
} else {
|
|
607
|
+
tasks.push({
|
|
608
|
+
name: "linkedin",
|
|
609
|
+
run: async () => {
|
|
610
|
+
const path = paths.linkedin.startChat(String(LinkedinConnector.connectorId));
|
|
611
|
+
const payload = {
|
|
612
|
+
linkedin_url: LinkedinConnector.contactId,
|
|
613
|
+
text
|
|
614
|
+
};
|
|
615
|
+
if (linkedinMeta.subject) {
|
|
616
|
+
payload.subject = linkedinMeta.subject;
|
|
617
|
+
}
|
|
618
|
+
if (linkedinMeta.linkedinApi) {
|
|
619
|
+
payload.linkedin_api = linkedinMeta.linkedinApi;
|
|
620
|
+
}
|
|
621
|
+
if (linkedinMeta.isInMail) {
|
|
622
|
+
payload.linkedin_inmail = linkedinMeta.isInMail;
|
|
623
|
+
}
|
|
624
|
+
try {
|
|
625
|
+
const res = await getAxios().post(path, payload);
|
|
626
|
+
const data = res.data;
|
|
627
|
+
linkedinChatId = data.chat_data.chat_id;
|
|
628
|
+
return { status: "fulfilled", value: data };
|
|
629
|
+
} catch (error) {
|
|
630
|
+
return { status: "rejected", reason: error };
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
});
|
|
621
634
|
}
|
|
622
|
-
}
|
|
635
|
+
} else {
|
|
636
|
+
tasks.push({
|
|
637
|
+
name: "linkedin",
|
|
638
|
+
run: async () => {
|
|
639
|
+
const path = paths.linkedin.startChat(String(LinkedinConnector.connectorId));
|
|
640
|
+
const payload = {
|
|
641
|
+
linkedin_url: LinkedinConnector.contactId,
|
|
642
|
+
text
|
|
643
|
+
};
|
|
644
|
+
if (linkedinMeta == null ? void 0 : linkedinMeta.linkedinApi) {
|
|
645
|
+
payload.linkedin_api = linkedinMeta.linkedinApi;
|
|
646
|
+
}
|
|
647
|
+
try {
|
|
648
|
+
const res = await getAxios().post(path, payload);
|
|
649
|
+
const data = res.data;
|
|
650
|
+
linkedinChatId = data.chat_data.chat_id;
|
|
651
|
+
return { status: "fulfilled", value: data };
|
|
652
|
+
} catch (error) {
|
|
653
|
+
return { status: "rejected", reason: error };
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
623
658
|
} else {
|
|
624
659
|
failed_source.push({ source: "linkedin", message: "Missing connector configuration" });
|
|
625
660
|
}
|