mod-build 4.0.36 → 4.0.37
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/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/tasks/templates.js +62 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 4.0.37
|
|
2
|
+
|
|
3
|
+
- Updated `getConsentCaptureLanguage` to include the `profileId` version of the display name API.
|
|
4
|
+
*Currently being used for Best Company branded form pages.*
|
|
5
|
+
|
|
1
6
|
## 4.0.36
|
|
2
7
|
|
|
3
8
|
- Included an option for `service` to be appended to the `brandedIncludeServiceConsentCapture` for consent capture.
|
package/package.json
CHANGED
package/tasks/templates.js
CHANGED
|
@@ -148,6 +148,42 @@ const fetchTcpaFromSitegenie = async (config, tempConfig, pathSubdirectory) => {
|
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
// goes through the config to find the object that contains Match: '' & then finds the value of that same object
|
|
152
|
+
function findVendorKey(config) {
|
|
153
|
+
if (Array.isArray(config)) {
|
|
154
|
+
for (let item of config) {
|
|
155
|
+
const result = findVendorKey(item);
|
|
156
|
+
if (result) {
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} else if (typeof config === 'object' && config !== null) {
|
|
161
|
+
if (config.name === 'Match' && config.value !== undefined) {
|
|
162
|
+
return config.value;
|
|
163
|
+
}
|
|
164
|
+
for (let key in config) {
|
|
165
|
+
const result = findVendorKey(config[key]);
|
|
166
|
+
if (result) {
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function embedBrandedDisplayName(apiUrl, consentCaptureObject, key, service) {
|
|
175
|
+
let resp = '';
|
|
176
|
+
const getBrandedDisplayName = await axios.get(apiUrl);
|
|
177
|
+
if (getBrandedDisplayName.status !== 200) {
|
|
178
|
+
throw new Error(`${resp.status}: Error while getting branded display name from HS Form Service`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const brandedDisplayName = getBrandedDisplayName.data.data[key];
|
|
182
|
+
consentCaptureObject.brandedConsentCapture.tcpaStart = consentCaptureObject.brandedConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`);
|
|
183
|
+
consentCaptureObject.brandedIncludeExclusivelyConsentCapture.tcpaStart = consentCaptureObject.brandedIncludeExclusivelyConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`);
|
|
184
|
+
consentCaptureObject.brandedIncludeServiceConsentCapture.tcpaStart = consentCaptureObject.brandedIncludeServiceConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`).replace(/<span data-service><\/span>/g, `<span data-service>${service}</span>`);
|
|
185
|
+
}
|
|
186
|
+
|
|
151
187
|
const getConsentCaptureLanguage = async function(config, tempConfig) {
|
|
152
188
|
await new Promise((resolve) => {
|
|
153
189
|
consentCaptureAxiosInstance.get(`https://${defaultSettings.nodeEnv}/quote/resources/mod-site/consent-capture/tcpa.json`)
|
|
@@ -156,8 +192,7 @@ const getConsentCaptureLanguage = async function(config, tempConfig) {
|
|
|
156
192
|
throw new Error(`${resp.status}: Error while fetching tcpa.json`);
|
|
157
193
|
}
|
|
158
194
|
|
|
159
|
-
let
|
|
160
|
-
consentCaptureObject = resp.data,
|
|
195
|
+
let consentCaptureObject = resp.data,
|
|
161
196
|
service = config.service ? config.service.toLowerCase().replace('_', ' ') : config.primary_trade.toLowerCase().replace('_', ' ');
|
|
162
197
|
|
|
163
198
|
const brandedSiteIdentifiers = await axios.get(`https://${defaultSettings.nodeEnv}/quote/resources/mod-site/data/branded-site-identifiers.json`);
|
|
@@ -166,20 +201,37 @@ const getConsentCaptureLanguage = async function(config, tempConfig) {
|
|
|
166
201
|
}
|
|
167
202
|
|
|
168
203
|
if (config.isBranded) {
|
|
169
|
-
const websiteName = config.website_name
|
|
204
|
+
const websiteName = config.website_name,
|
|
205
|
+
apiDomain = 'https://form-service-hs.qnst.com/';
|
|
206
|
+
|
|
207
|
+
let apiUrl = '';
|
|
208
|
+
|
|
170
209
|
if (brandedSiteIdentifiers.data[websiteName] && brandedSiteIdentifiers.data[websiteName].vendorPublicIdentifier) {
|
|
171
|
-
const vendorPublicIdentifier = brandedSiteIdentifiers.data[websiteName].vendorPublicIdentifier
|
|
172
|
-
|
|
173
|
-
|
|
210
|
+
const vendorPublicIdentifier = brandedSiteIdentifiers.data[websiteName].vendorPublicIdentifier;
|
|
211
|
+
|
|
212
|
+
apiUrl = `${apiDomain}utils/vendor-display-name?vendorKeys=${vendorPublicIdentifier}`;
|
|
174
213
|
|
|
175
214
|
const getBrandedDisplayName = await axios.get(apiUrl);
|
|
176
215
|
if (getBrandedDisplayName.status !== 200) {
|
|
177
216
|
throw new Error(`${resp.status}: Error while getting branded display name from HS Form Service`);
|
|
178
217
|
}
|
|
179
218
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
219
|
+
await embedBrandedDisplayName(apiUrl, consentCaptureObject, vendorPublicIdentifier, service);
|
|
220
|
+
} else {
|
|
221
|
+
const vendorKey = findVendorKey(config),
|
|
222
|
+
profileApiDomain = 'https://api.modernize.com/',
|
|
223
|
+
profileApiUrl = `${profileApiDomain}v1/client-profiles/profiles?filters[matches][]=${vendorKey},QMP`;
|
|
224
|
+
|
|
225
|
+
if (vendorKey !== null) {
|
|
226
|
+
const getBrandedProfileId = await axios.get(profileApiUrl);
|
|
227
|
+
if (getBrandedProfileId.status !== 200) {
|
|
228
|
+
throw new Error(`${resp.status}: Error while getting branded display name from HS Form Service`);
|
|
229
|
+
}
|
|
230
|
+
const brandedProfileId = getBrandedProfileId.data.data[0].profileId;
|
|
231
|
+
apiUrl = `${apiDomain}utils/vendor-display-name?profileId=${brandedProfileId}`;
|
|
232
|
+
|
|
233
|
+
await embedBrandedDisplayName(apiUrl, consentCaptureObject, brandedProfileId, service);
|
|
234
|
+
}
|
|
183
235
|
}
|
|
184
236
|
}
|
|
185
237
|
|
|
@@ -284,4 +336,4 @@ export default async function(config) {
|
|
|
284
336
|
|
|
285
337
|
fs.writeFileSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}/config.json`, JSON.stringify(tempConfig, null, 2));
|
|
286
338
|
}
|
|
287
|
-
}
|
|
339
|
+
}
|