Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GumGum Bid Adapter: adds meta field to bidresponse #6478

Merged
merged 2 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ function interpretResponse (serverResponse, bidRequest) {
},
pag: {
pvid: 0
},
meta: {
adomain: [],
mediaType: ''
}
}
const {
Expand All @@ -401,14 +405,22 @@ function interpretResponse (serverResponse, bidRequest) {
pag: {
pvid
},
jcsi
jcsi,
meta: {
adomain: advertiserDomains,
mediaType: type
}
} = Object.assign(defaultResponse, serverResponseBody)
let data = bidRequest.data || {}
let product = data.pi
let mediaType = (product === 6 || product === 7) ? VIDEO : BANNER
let isTestUnit = (product === 3 && data.si === 9)
let sizes = utils.parseSizesInput(bidRequest.sizes)
let [width, height] = sizes[0].split('x')
let metaData = {
advertiserDomains: advertiserDomains || [],
mediaType: type || mediaType
}

// return 1x1 when breakout expected
if ((product === 2 || product === 5) && includes(sizes, '1x1')) {
Expand Down Expand Up @@ -437,7 +449,8 @@ function interpretResponse (serverResponse, bidRequest) {
netRevenue: true,
requestId: bidRequest.id,
ttl: TIME_TO_LIVE,
width
width,
meta: metaData
})
}
return bidResponses
Expand Down
76 changes: 51 additions & 25 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,37 +461,40 @@ describe('gumgumAdapter', function () {
})

describe('interpretResponse', function () {
let serverResponse = {
'ad': {
'id': 29593,
'width': 300,
'height': 250,
'ipd': 2000,
'markup': '<html><h3>I am an ad</h3></html>',
'ii': true,
'du': null,
'price': 0,
'zi': 0,
'impurl': 'http://g2.gumgum.com/ad/view',
'clsurl': 'http://g2.gumgum.com/ad/close'
const metaData = { adomain: ['advertiser.com'], mediaType: BANNER }
const serverResponse = {
ad: {
id: 29593,
width: 300,
height: 250,
ipd: 2000,
markup: '<html><h3>I am an ad</h3></html>',
ii: true,
du: null,
price: 0,
zi: 0,
impurl: 'http://g2.gumgum.com/ad/view',
clsurl: 'http://g2.gumgum.com/ad/close'
},
'pag': {
't': 'ggumtest',
'pvid': 'aa8bbb65-427f-4689-8cee-e3eed0b89eec',
'css': 'html { overflow-y: auto }',
'js': 'console.log("environment", env);'
pag: {
t: 'ggumtest',
pvid: 'aa8bbb65-427f-4689-8cee-e3eed0b89eec',
css: 'html { overflow-y: auto }',
js: 'console.log("environment", env);'
},
'jcsi': { t: 0, rq: 8 },
'thms': 10000
jcsi: { t: 0, rq: 8 },
thms: 10000,
meta: metaData
}
let bidRequest = {
const bidRequest = {
id: 12345,
sizes: [[300, 250], [1, 1]],
url: ENDPOINT,
method: 'GET',
pi: 3
}
let expectedResponse = {
const expectedMetaData = { advertiserDomains: ['advertiser.com'], mediaType: BANNER };
const expectedResponse = {
ad: '<html><h3>I am an ad</h3></html>',
cpm: 0,
creativeId: 29593,
Expand All @@ -501,19 +504,42 @@ describe('gumgumAdapter', function () {
requestId: 12345,
width: '300',
mediaType: BANNER,
ttl: 60
ttl: 60,
meta: expectedMetaData
};

it('should get correct bid response', function () {
expect(spec.interpretResponse({ body: serverResponse }, bidRequest)).to.deep.equal([expectedResponse]);
});

it('should set a default value for advertiserDomains if adomain is not found', function () {
const meta = { ...metaData };
delete meta.adomain;

const response = { ...serverResponse, meta };
const expectedMeta = { ...expectedMetaData, advertiserDomains: [] };
const expected = { ...expectedResponse, meta: expectedMeta };

expect(spec.interpretResponse({ body: response }, bidRequest)).to.deep.equal([expected]);
});

it('should set a default value for meta.mediaType if mediaType is not found in the response', function () {
const meta = { ...metaData };
delete meta.mediaType;
const response = { ...serverResponse, meta };
const expected = { ...expectedResponse };

expect(spec.interpretResponse({ body: response }, bidRequest)).to.deep.equal([expected]);
});

it('should pass correct currency if found in bid response', function () {
const cur = 'EURO';
let response = Object.assign({}, serverResponse);
let expected = Object.assign({}, expectedResponse);
const response = { ...serverResponse };
response.ad.cur = cur;

const expected = { ...expectedResponse };
expected.currency = cur;

expect(spec.interpretResponse({ body: response }, bidRequest)).to.deep.equal([expected]);
});

Expand Down