Skip to content

Commit

Permalink
change smartyads ad unit parameters (prebid#7380)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartyAdsSSP authored and Chris Pabst committed Jan 10, 2022
1 parent e6133e7 commit 1779c19
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
33 changes: 23 additions & 10 deletions modules/smartyadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { config } from '../src/config.js';
import * as utils from '../src/utils.js';

const BIDDER_CODE = 'smartyads';
const AD_URL = 'https://ssp-nj.webtradehub.com/?c=o&m=multi';
const URL_SYNC = 'https://ssp-nj.webtradehub.com/?c=o&m=cookie';
const AD_URL = 'https://n1.smartyads.com/?c=o&m=prebid&secret_key=prebid_js';
const URL_SYNC = 'https://as.ck-ie.com/prebidjs?p=7c47322e527cf8bdeb7facc1bb03387a';

function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
Expand All @@ -29,7 +29,7 @@ export const spec = {
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: (bid) => {
return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placementId));
return Boolean(bid.bidId && bid.params && !isNaN(bid.params.sourceid) && !isNaN(bid.params.accountid) && bid.params.host == 'prebid');
},

buildRequests: (validBidRequests = [], bidderRequest) => {
Expand Down Expand Up @@ -68,10 +68,11 @@ export const spec = {
let bid = validBidRequests[i];
let traff = bid.params.traffic || BANNER
placements.push({
placementId: bid.params.placementId,
placementId: bid.params.sourceid,
bidId: bid.bidId,
sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [],
traffic: traff
traffic: traff,
publisherId: bid.params.accountid
});
if (bid.schain) {
placements.schain = bid.schain;
Expand All @@ -96,11 +97,23 @@ export const spec = {
return response;
},

getUserSyncs: (syncOptions, serverResponses) => {
return [{
type: 'image',
url: URL_SYNC
}];
getUserSyncs: (syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '') => {
let syncs = [];
let { gdprApplies, consentString = '' } = gdprConsent;

if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=iframe&us_privacy=${uspConsent}`
});
} else {
syncs.push({
type: 'image',
url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=image&us_privacy=${uspConsent}`
});
}

return syncs
}

};
Expand Down
12 changes: 9 additions & 3 deletions modules/smartyadsBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Module that connects to SmartyAds' demand sources
{
bidder: 'smartyads',
params: {
placementId: 0,
host: 'prebid',
sourceid: '0',
accountid: '0',
traffic: 'native'
}
}
Expand All @@ -41,7 +43,9 @@ Module that connects to SmartyAds' demand sources
{
bidder: 'smartyads',
params: {
placementId: 0,
host: 'prebid',
sourceid: '0',
accountid: '0',
traffic: 'banner'
}
}
Expand All @@ -60,7 +64,9 @@ Module that connects to SmartyAds' demand sources
{
bidder: 'smartyads',
params: {
placementId: 0,
host: 'prebid',
sourceid: '0',
accountid: '0',
traffic: 'video'
}
}
Expand Down
25 changes: 16 additions & 9 deletions test/spec/modules/smartyadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ describe('SmartyadsAdapter', function () {
bidId: '23fhj33i987f',
bidder: 'smartyads',
params: {
placementId: 0,
host: 'prebid',
sourceid: '0',
accountid: '0',
traffic: 'banner'
}
};

describe('isBidRequestValid', function () {
it('Should return true if there are bidId, params and placementId parameters present', function () {
it('Should return true if there are bidId, params and sourceid parameters present', function () {
expect(spec.isBidRequestValid(bid)).to.be.true;
});
it('Should return false if at least one of parameters is not present', function () {
delete bid.params.placementId;
delete bid.params.sourceid;
expect(spec.isBidRequestValid(bid)).to.be.false;
});
});
Expand All @@ -34,7 +36,7 @@ describe('SmartyadsAdapter', function () {
expect(serverRequest.method).to.equal('POST');
});
it('Returns valid URL', function () {
expect(serverRequest.url).to.equal('https://ssp-nj.webtradehub.com/?c=o&m=multi');
expect(serverRequest.url).to.equal('https://n1.smartyads.com/?c=o&m=prebid&secret_key=prebid_js');
});
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
Expand All @@ -48,8 +50,8 @@ describe('SmartyadsAdapter', function () {
expect(data.host).to.be.a('string');
expect(data.page).to.be.a('string');
let placement = data['placements'][0];
expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes');
expect(placement.placementId).to.equal(0);
expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'publisherId');
expect(placement.placementId).to.equal('0');
expect(placement.bidId).to.equal('23fhj33i987f');
expect(placement.traffic).to.equal('banner');
});
Expand Down Expand Up @@ -241,13 +243,18 @@ describe('SmartyadsAdapter', function () {
});
});
describe('getUserSyncs', function () {
let userSync = spec.getUserSyncs();
const syncUrl = 'https://as.ck-ie.com/prebidjs?p=7c47322e527cf8bdeb7facc1bb03387a&gdpr=0&gdpr_consent=&type=iframe&us_privacy=';
const syncOptions = {
iframeEnabled: true
};
let userSync = spec.getUserSyncs(syncOptions);
it('Returns valid URL and type', function () {
expect(userSync).to.be.an('array').with.lengthOf(1);
expect(userSync[0].type).to.exist;
expect(userSync[0].url).to.exist;
expect(userSync[0].type).to.be.equal('image');
expect(userSync[0].url).to.be.equal('https://ssp-nj.webtradehub.com/?c=o&m=cookie');
expect(userSync).to.deep.equal([
{ type: 'iframe', url: syncUrl }
]);
});
});
});

0 comments on commit 1779c19

Please sign in to comment.