Skip to content

Commit 3b82f53

Browse files
tmielcarzTomasz Mielcarz
and
Tomasz Mielcarz
authored
Multiple bids in one request to Adrino Adserver (#9742)
Co-authored-by: Tomasz Mielcarz <[email protected]>
1 parent 4f45f15 commit 3b82f53

File tree

2 files changed

+89
-50
lines changed

2 files changed

+89
-50
lines changed

modules/adrinoBidAdapter.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ export const spec = {
3131
buildRequests: function (validBidRequests, bidderRequest) {
3232
// convert Native ORTB definition to old-style prebid native definition
3333
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
34-
const bidRequests = [];
3534

35+
let bids = [];
3636
for (let i = 0; i < validBidRequests.length; i++) {
37-
let host = this.getBidderConfig('host') || BIDDER_HOST;
38-
3937
let requestData = {
4038
bidId: validBidRequests[i].bidId,
4139
nativeParams: validBidRequests[i].nativeParams,
@@ -52,27 +50,37 @@ export const spec = {
5250
}
5351
}
5452

55-
bidRequests.push({
56-
method: REQUEST_METHOD,
57-
url: host + '/bidder/bid/',
58-
data: requestData,
59-
options: {
60-
contentType: 'application/json',
61-
withCredentials: false,
62-
}
63-
});
53+
bids.push(requestData);
6454
}
6555

56+
let host = this.getBidderConfig('host') || BIDDER_HOST;
57+
let bidRequests = [];
58+
bidRequests.push({
59+
method: REQUEST_METHOD,
60+
url: host + '/bidder/bids/',
61+
data: bids,
62+
options: {
63+
contentType: 'application/json',
64+
withCredentials: false,
65+
}
66+
});
67+
6668
return bidRequests;
6769
},
6870

6971
interpretResponse: function (serverResponse, bidRequest) {
7072
const response = serverResponse.body;
71-
const bidResponses = [];
72-
if (!response.noAd) {
73-
bidResponses.push(response);
73+
const output = [];
74+
75+
if (response.bidResponses) {
76+
for (const bidResponse of response.bidResponses) {
77+
if (!bidResponse.noAd) {
78+
output.push(bidResponse);
79+
}
80+
}
7481
}
75-
return bidResponses;
82+
83+
return output;
7684
},
7785

7886
onBidWon: function (bid) {

test/spec/modules/adrinoBidAdapter_spec.js

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ describe('adrinoBidAdapter', function () {
8686
);
8787
expect(result.length).to.equal(1);
8888
expect(result[0].method).to.equal('POST');
89-
expect(result[0].url).to.equal('https://stg-prebid-bidder.adrino.io/bidder/bid/');
90-
expect(result[0].data.bidId).to.equal('12345678901234');
91-
expect(result[0].data.placementHash).to.equal('abcdef123456');
92-
expect(result[0].data.referer).to.equal('http://example.com/');
93-
expect(result[0].data.userAgent).to.equal(navigator.userAgent);
94-
expect(result[0].data).to.have.property('nativeParams');
95-
expect(result[0].data).not.to.have.property('gdprConsent');
96-
expect(result[0].data).to.have.property('userId');
97-
expect(result[0].data.userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
98-
expect(result[0].data.userId.pubcid).to.equal('3ec0b202-7697');
89+
expect(result[0].url).to.equal('https://stg-prebid-bidder.adrino.io/bidder/bids/');
90+
expect(result[0].data[0].bidId).to.equal('12345678901234');
91+
expect(result[0].data[0].placementHash).to.equal('abcdef123456');
92+
expect(result[0].data[0].referer).to.equal('http://example.com/');
93+
expect(result[0].data[0].userAgent).to.equal(navigator.userAgent);
94+
expect(result[0].data[0]).to.have.property('nativeParams');
95+
expect(result[0].data[0]).not.to.have.property('gdprConsent');
96+
expect(result[0].data[0]).to.have.property('userId');
97+
expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
98+
expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697');
9999
});
100100

101101
it('should build the request correctly with gdpr', function () {
@@ -105,16 +105,16 @@ describe('adrinoBidAdapter', function () {
105105
);
106106
expect(result.length).to.equal(1);
107107
expect(result[0].method).to.equal('POST');
108-
expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bid/');
109-
expect(result[0].data.bidId).to.equal('12345678901234');
110-
expect(result[0].data.placementHash).to.equal('abcdef123456');
111-
expect(result[0].data.referer).to.equal('http://example.com/');
112-
expect(result[0].data.userAgent).to.equal(navigator.userAgent);
113-
expect(result[0].data).to.have.property('nativeParams');
114-
expect(result[0].data).to.have.property('gdprConsent');
115-
expect(result[0].data).to.have.property('userId');
116-
expect(result[0].data.userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
117-
expect(result[0].data.userId.pubcid).to.equal('3ec0b202-7697');
108+
expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/');
109+
expect(result[0].data[0].bidId).to.equal('12345678901234');
110+
expect(result[0].data[0].placementHash).to.equal('abcdef123456');
111+
expect(result[0].data[0].referer).to.equal('http://example.com/');
112+
expect(result[0].data[0].userAgent).to.equal(navigator.userAgent);
113+
expect(result[0].data[0]).to.have.property('nativeParams');
114+
expect(result[0].data[0]).to.have.property('gdprConsent');
115+
expect(result[0].data[0]).to.have.property('userId');
116+
expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
117+
expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697');
118118
});
119119

120120
it('should build the request correctly without gdpr', function () {
@@ -124,22 +124,22 @@ describe('adrinoBidAdapter', function () {
124124
);
125125
expect(result.length).to.equal(1);
126126
expect(result[0].method).to.equal('POST');
127-
expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bid/');
128-
expect(result[0].data.bidId).to.equal('12345678901234');
129-
expect(result[0].data.placementHash).to.equal('abcdef123456');
130-
expect(result[0].data.referer).to.equal('http://example.com/');
131-
expect(result[0].data.userAgent).to.equal(navigator.userAgent);
132-
expect(result[0].data).to.have.property('nativeParams');
133-
expect(result[0].data).not.to.have.property('gdprConsent');
134-
expect(result[0].data).to.have.property('userId');
135-
expect(result[0].data.userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
136-
expect(result[0].data.userId.pubcid).to.equal('3ec0b202-7697');
127+
expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/');
128+
expect(result[0].data[0].bidId).to.equal('12345678901234');
129+
expect(result[0].data[0].placementHash).to.equal('abcdef123456');
130+
expect(result[0].data[0].referer).to.equal('http://example.com/');
131+
expect(result[0].data[0].userAgent).to.equal(navigator.userAgent);
132+
expect(result[0].data[0]).to.have.property('nativeParams');
133+
expect(result[0].data[0]).not.to.have.property('gdprConsent');
134+
expect(result[0].data[0]).to.have.property('userId');
135+
expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3');
136+
expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697');
137137
});
138138
});
139139

140140
describe('interpretResponse', function () {
141141
it('should interpret the response correctly', function () {
142-
const response = {
142+
const response1 = {
143143
requestId: '31662c69728811',
144144
mediaType: 'native',
145145
cpm: 0.53,
@@ -167,13 +167,44 @@ describe('adrinoBidAdapter', function () {
167167
}
168168
};
169169

170+
const response2 = {
171+
requestId: '31662c69728812',
172+
mediaType: 'native',
173+
cpm: 0.77,
174+
currency: 'PLN',
175+
creativeId: '859120',
176+
netRevenue: true,
177+
ttl: 600,
178+
width: 1,
179+
height: 1,
180+
noAd: false,
181+
testAd: false,
182+
native: {
183+
title: 'Ad Title',
184+
body: 'Ad Body',
185+
image: {
186+
url: 'http://emisja.contentstream.pl/_/getImageII/?vid=17180728299&typ=cs_300_150&element=IMAGE&scale=1&prefix=adart&nc=1643878278955',
187+
height: 150,
188+
width: 300
189+
},
190+
clickUrl: 'http://emisja.contentstream.pl/_/ctr2/?u=https%3A%2F%2Fonline.efortuna.pl%2Fpage%3Fkey%3Dej0xMzUzMTM1NiZsPTE1Mjc1MzY1JnA9NTMyOTA%253D&e=znU3tABN8K4N391dmUxYfte5G9tBaDXELJVo1_-kvaTJH2XwWRw77fmfL2YjcEmrbqRQ3M0GcJ0vPWcLtZlsrf8dWrAEHNoZKAC6JMnZF_65IYhTPbQIJ-zn3ac9TU7gEZftFKksH1al7rMuieleVv9r6_DtrOk_oZcYAe4rMRQM-TiWvivJRPBchAAblE0cqyG7rCunJFpal43sxlYm4GvcBJaYHzErn5PXjEzNbd3xHjkdiap-xU9y6BbfkUZ1xIMS8QZLvwNrTXMFCSfSRN2tgVfEj7KyGdLCITHSaFtuIKT2iW2pxC7f2RtPHnzsEPXH0SgAfhA3OxZ5jkQjOZy0PsO7MiCv3sJai5ezUAOjFgayU91ZhI0Y9r2YpB1tTGIjnO23wot8PvRENlThHQ%3D%3D&ref=https%3A%2F%2Fbox.adrino.cloud%2Ftmielcarz%2Fadrino_prebid%2Ftest_page3.html%3Fpbjs_debug%3Dtrue',
191+
privacyLink: 'https://adrino.pl/wp-content/uploads/2021/01/POLITYKA-PRYWATNOS%CC%81CI-Adrino-Mobile.pdf',
192+
impressionTrackers: [
193+
'https://prd-impression-tracker-producer.adrino.io/impression/eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJpbXByZXNzaW9uSWRcIjpcIjMxNjYyYzY5NzI4ODExXCIsXCJkYXRlXCI6WzIwMjIsMiwzXSxcInBsYWNlbWVudEhhc2hcIjpcIjk0NTVjMDQxYzlkMTI1ZmIwNDE4MWVhMGVlZTJmMmFlXCIsXCJjYW1wYWlnbklkXCI6MTc5MjUsXCJhZHZlcnRpc2VtZW50SWRcIjo5MjA3OSxcInZpc3VhbGlzYXRpb25JZFwiOjg1OTExNSxcImNwbVwiOjUzLjB9IiwiZXhwIjoxNjQzOTE2MjUxLCJpYXQiOjE2NDM5MTU2NTF9.0Y_HvInGl6Xo5xP6rDLC8lzQRGvy-wKe0blk1o8ebWyVRFiUY1JGLUeE0k3sCsPNxgdHAv-o6EcbogpUuqlMJA'
194+
]
195+
}
196+
};
197+
170198
const serverResponse = {
171-
body: response
199+
body: { bidResponses: [response1, response2] }
172200
};
173201

174202
const result = spec.interpretResponse(serverResponse, {});
175-
expect(result.length).to.equal(1);
176-
expect(result[0]).to.equal(response);
203+
expect(result.length).to.equal(2);
204+
expect(result[0]).to.equal(response1);
205+
expect(result[0].requestId).to.equal('31662c69728811');
206+
expect(result[1]).to.equal(response2);
207+
expect(result[1].requestId).to.equal('31662c69728812');
177208
});
178209

179210
it('should return empty array of responses', function () {

0 commit comments

Comments
 (0)