-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathselectPlacementsAttributePersistence.ts
More file actions
47 lines (43 loc) · 1.33 KB
/
Copy pathselectPlacementsAttributePersistence.ts
File metadata and controls
47 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const SELECT_PLACEMENTS_ATTRIBUTE_PERSISTENCE_DENY_LIST = [
'billingaddress1',
'billingaddress2',
'billingcity',
'billingstate',
'billingzipcode',
'cartitems',
'ccbin',
'confirmationref',
'conversiontype',
'country',
'couponcode',
'currency',
'language',
'paymentserviceprovider',
'paymentserviceproviderattribute',
'paymenttype',
'shippingaddress1',
'shippingcity',
'shippingcountry',
'shippingmethod',
'shippingstate',
'shippingzipcode',
'totalprice',
];
const SELECT_PLACEMENTS_ATTRIBUTE_PERSISTENCE_DENY_SET = new Set(SELECT_PLACEMENTS_ATTRIBUTE_PERSISTENCE_DENY_LIST);
export function isSelectPlacementsAttributePersistenceDenied(key: string): boolean {
return SELECT_PLACEMENTS_ATTRIBUTE_PERSISTENCE_DENY_SET.has(key.toLowerCase());
}
export function removeSelectPlacementsAttributePersistenceDeniedAttributes(
attributes: Record<string, unknown> | null | undefined,
): Record<string, unknown> {
const filteredAttributes: Record<string, unknown> = {};
const sourceAttributes = attributes || {};
const attributeKeys = Object.keys(sourceAttributes);
for (let i = 0; i < attributeKeys.length; i++) {
const key = attributeKeys[i];
if (!isSelectPlacementsAttributePersistenceDenied(key)) {
filteredAttributes[key] = sourceAttributes[key];
}
}
return filteredAttributes;
}