7
7
``` javascript
8
8
(WIAPI => {
9
9
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
10
- API .subscribe (' event-name-and-version' , function ( event ) {
10
+ API .subscribe (' event-name-and-version' , event => {
11
11
API .log (event );
12
12
});
13
13
})(window .DDC .API );
@@ -21,7 +21,7 @@ Please see the <a href="#event-subscriptions">specific event documentation</a> f
21
21
``` javascript
22
22
(WIAPI => {
23
23
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
24
- API .insertCallToAction (' button' , ' value-a-trade' , function ( meta ) {
24
+ API .insertCallToAction (' button' , ' value-a-trade' , meta => {
25
25
return {
26
26
" type" : " default" ,
27
27
" href" : " https://www.yourdomain.com/value-a-trade/?vin=" + meta .vin ,
@@ -116,20 +116,20 @@ After creating the callback object, you must then return it for the API to creat
116
116
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
117
117
118
118
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
119
- API .subscribe (' vehicle-data-updated-v1' , function ( ev ) {
119
+ API .subscribe (' vehicle-data-updated-v1' , ev => {
120
120
121
121
// Collect the VIN for each vehicle on the page in an array.
122
- API .utils .getAttributeForVehicles (' vin' ).then (function ( vins ) {
122
+ API .utils .getAttributeForVehicles (' vin' ).then (vins => {
123
123
API .log (" Calling service with these VINs: " + vins .join (' ,' ));
124
124
125
125
// Fetch data from your endpoint by supplying the list of VINs.
126
126
fetch (' https://www.yourdomain.com/api/endpoint-that-returns-json?vins=' + vins .join (' ,' ))
127
- .then (function ( response ) {
127
+ .then (response => {
128
128
return response .json ();
129
129
})
130
- .then (function ( serviceData ) {
130
+ .then (serviceData => {
131
131
// Now that you have your service data, you can determine whether or not to place a CTA for this vehicle on the page.
132
- API .insertCallToActionOnce (' button' , ' value-a-trade' , function ( meta ) {
132
+ API .insertCallToActionOnce (' button' , ' value-a-trade' , meta => {
133
133
if (serviceData .hasOwnProperty (meta .vin )) {
134
134
return {
135
135
" type" : " default" ,
@@ -208,7 +208,7 @@ Name | Description
208
208
``` javascript
209
209
(WIAPI => {
210
210
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
211
- API .insert (' location-name' , function (elem , meta ) {
211
+ API .insert (' location-name' , (elem , meta ) => {
212
212
API .log (elem); // The DOM element where markup may be inserted.
213
213
API .log (meta); // The payload object for the current insertion point.
214
214
});
@@ -231,9 +231,9 @@ If you need to execute additional code before determining if you wish to insert
231
231
(WIAPI => {
232
232
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
233
233
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
234
- API .subscribe (' vehicle-data-updated-v1' , function ( ev ) {
234
+ API .subscribe (' vehicle-data-updated-v1' , ev => {
235
235
// Insert content into each vehicle location now present on the page.
236
- API .insertOnce (' location-name' , function (elem , meta ) {
236
+ API .insertOnce (' location-name' , (elem , meta ) => {
237
237
API .log (elem); // The DOM element where markup may be inserted.
238
238
API .log (meta); // The payload object for the current insertion point.
239
239
});
@@ -250,18 +250,18 @@ If you need to execute additional code before determining if you wish to insert
250
250
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
251
251
252
252
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
253
- API .subscribe (' vehicle-data-updated-v1' , function ( ev ) {
253
+ API .subscribe (' vehicle-data-updated-v1' , ev => {
254
254
255
255
// Collect the VIN for each vehicle on the page in an array.
256
- API .utils .getAttributeForVehicles (' vin' ).then (function ( vins ) {
256
+ API .utils .getAttributeForVehicles (' vin' ).then (vins => {
257
257
API .log (" Calling service with these VINs: " + vins .join (' ,' ));
258
258
259
259
// Fetch data from your endpoint by supplying the list of VINs.
260
260
fetch (' https://www.yourdomain.com/api/endpoint-that-returns-json?vins=' + vins .join (' ,' ))
261
- .then (function ( response ) {
261
+ .then (response => {
262
262
return response .json ();
263
263
})
264
- .then (function ( serviceData ) {
264
+ .then (serviceData => {
265
265
// Now that you have your service data, you can determine whether or not to place content for this location on to the page.
266
266
API .insertOnce (' vehicle-badge' , function (elem , meta ) {
267
267
// Verify my service has data for this vehicle
@@ -322,7 +322,7 @@ Field Name | Purpose | Field Format
322
322
imgAttributes: {
323
323
' data-image-attribute' : ' image-attribute-value'
324
324
},
325
- onclick : function () {
325
+ onclick : () => {
326
326
window .MyIntegration .activateModalOverlay ();
327
327
}
328
328
});
@@ -374,7 +374,7 @@ Field Key | Example Value | Field Format | Purpose
374
374
``` javascript
375
375
(WIAPI => {
376
376
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
377
- API .insert (' target-location-name' , function (elem , meta ) {
377
+ API .insert (' target-location-name' , (elem , meta ) => {
378
378
let lowPrice = Math .round (meta .finalPrice - 1000 );
379
379
let highPrice = Math .round (meta .finalPrice + 1000 );
380
380
const button = API .create (' button' , {
@@ -402,7 +402,7 @@ When calling the insert method, the goal is to insert some markup into a locatio
402
402
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
403
403
// Loads a JavaScript file
404
404
API .loadJS (' https://www.company.com/script.js' )
405
- .then (function () {
405
+ .then (() => {
406
406
// Code to execute after your JavaScript file has loaded.
407
407
});
408
408
})(window .DDC .API );
@@ -419,7 +419,7 @@ The loadJS method is a simple way to include additional JavaScript files require
419
419
const API = new WIAPI (' test-integration' ); // Note: Replace 'test-integration' with your actual integration identifier.
420
420
// Loads a CSS stylesheet
421
421
API .loadCSS (' https://www.company.com/integration.css' )
422
- .then (function () {
422
+ .then (() => {
423
423
// Code to execute after your stylesheet has loaded.
424
424
});
425
425
})(window .DDC .API );
0 commit comments