Skip to content

Commit fe1b3f0

Browse files
committed
Cleverreach: Make sure the zip is string
1 parent a99574b commit fe1b3f0

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

dist/crm/cleverreach/client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const getContact = (email, token) => __awaiter(void 0, void 0, void 0, function*
6262
throw new Error(`Get receiver failed: ${response.statusText}`);
6363
}
6464
const data = yield response.json();
65-
// if there are values for quelle, name and lastname, we will use those values if they are empty in the message
65+
// if there are values for quelle, name, zip and lastname, we will use those values if they are empty in the message
6666
if (data === null || data === void 0 ? void 0 : data.global_attributes) {
6767
const { firstname, lastname, company, quelle, zip } = data.global_attributes;
6868
return { firstname, lastname, company, quelle, zip };

dist/crm/cleverreach/data.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.formatAction = void 0;
44
const formatAction = (message, hasValues, customLabel) => {
5-
var _a, _b, _c;
5+
var _a, _b, _c, _d, _e;
66
// do not overwrite 'quelle'
77
// do not delete first and lastname if they exist in the old record but not it the message
88
const global = {
@@ -12,11 +12,11 @@ const formatAction = (message, hasValues, customLabel) => {
1212
"phone": ((_a = message.contact) === null || _a === void 0 ? void 0 : _a.phone) || "",
1313
"double_opt_in": "yes",
1414
"street": message.contact.street || "",
15-
"zip": message.contact.postcode || "",
15+
"zip": ((_b = message.contact) === null || _b === void 0 ? void 0 : _b.postcode) ? (_c = message.contact) === null || _c === void 0 ? void 0 : _c.postcode.toString() : (hasValues === null || hasValues === void 0 ? void 0 : hasValues.zip) || "",
1616
"lastname": (hasValues === null || hasValues === void 0 ? void 0 : hasValues.lastname) && !message.contact.lastName ? hasValues.lastname : message.contact.lastName || "",
1717
"firstname": message.contact.firstName,
1818
"country": message.contact.country || message.contact.area || "",
19-
"company": (hasValues === null || hasValues === void 0 ? void 0 : hasValues.company) && !message.contact.company ? hasValues.company : ((_c = (_b = message.action.customFields) === null || _b === void 0 ? void 0 : _b.organisation) === null || _c === void 0 ? void 0 : _c.toString()) || "",
19+
"company": (hasValues === null || hasValues === void 0 ? void 0 : hasValues.company) && !message.contact.company ? hasValues.company : ((_e = (_d = message.action.customFields) === null || _d === void 0 ? void 0 : _d.organisation) === null || _e === void 0 ? void 0 : _e.toString()) || "",
2020
"city": message.contact.locality || "",
2121
"last_changed": message.privacy.emailStatusChanged || "",
2222
// each campaign should have custom field with the name date (6 figures) and campaign title

src/crm/cleverreach/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const getContact = async (email: string, token: string): Promise<any> =>
5555

5656
const data = await response.json();
5757

58-
// if there are values for quelle, name and lastname, we will use those values if they are empty in the message
58+
// if there are values for quelle, name, zip and lastname, we will use those values if they are empty in the message
5959
if (data?.global_attributes) {
6060
const { firstname, lastname, company, quelle, zip } = data.global_attributes;
6161
return { firstname, lastname, company, quelle, zip };

src/crm/cleverreach/data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const formatAction = (message: Message, hasValues: any, customLabel: stri
4444
"phone": message.contact?.phone || "",
4545
"double_opt_in": "yes",
4646
"street": message.contact.street || "",
47-
"zip": message.contact.postcode || "",
47+
"zip": message.contact?.postcode ? message.contact?.postcode.toString() : hasValues?.zip || "",
4848
"lastname": hasValues?.lastname && !message.contact.lastName ? hasValues.lastname : message.contact.lastName || "",
4949
"firstname": message.contact.firstName,
5050
"country": message.contact.country || message.contact.area || "",

0 commit comments

Comments
 (0)