Skip to content

Commit

Permalink
Fix astraoneBidAdapter (#6230)
Browse files Browse the repository at this point in the history
* Fix astraoneBidAdapter

* Fix examples; update astraoneBidAdapter description

* Fix astraoneBidAdapter_spec

* Remove integration examples

* Rename gbt to gpt
  • Loading branch information
lizakobrazova authored Jan 27, 2021
1 parent 6896e53 commit 438b0b0
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 170 deletions.
17 changes: 7 additions & 10 deletions modules/astraoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ function buildBid(bidData) {
creativeId: bidData.content.seanceId,
currency: bidData.currency,
netRevenue: true,
mediaType: BANNER,
meta: {
mediaType: BANNER,
},
ttl: TTL,
content: bidData.content
};
Expand Down Expand Up @@ -62,7 +64,7 @@ function wrapAd(bid, bidData) {
parentDocument.style.height = "100%";
parentDocument.style.width = "100%";
}
var _html = "${encodeURIComponent(JSON.stringify(bid))}";
var _html = "${encodeURIComponent(JSON.stringify({...bid, content: bidData.content}))}";
window._ao_ssp.registerInImage(JSON.parse(decodeURIComponent(_html)));
</script>
</body>
Expand Down Expand Up @@ -126,14 +128,9 @@ export const spec = {
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function(serverResponse) {
const serverBody = serverResponse.body;
if (serverBody && utils.isArray(serverBody)) {
return utils._map(serverBody, function(bid) {
return buildBid(bid);
});
} else {
return [];
}
const bids = serverResponse.body && serverResponse.body.bids;

return Array.isArray(bids) ? bids.map(bid => buildBid(bid)) : []
}

}
Expand Down
292 changes: 148 additions & 144 deletions modules/astraoneBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ About us: https://astraone.io
var adUnits = [{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [1, 1]
}
banner: {
sizes: [1, 1],
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
```
Expand All @@ -39,66 +39,69 @@ var adUnits = [{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script async src="prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script src="../../../build/dev/prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
</style>
<script>
var adUnits = [{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [1, 1],
}
</style>
<script>
var adUnits = [{
code: 'test-div',
sizes: [1, 1],
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function (e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
var params = pbjs.getAdserverTargetingForAdUnitCode("test-div");
var iframe = document.getElementById('test-div');
if (params && params['hb_adid']) {
iframe.parentElement.style.position = "relative";
iframe.style.display = "block";
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}
}
});
});
</script>
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: function (e) {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
var params = pbjs.getAdserverTargetingForAdUnitCode("test-div");
var iframe = document.getElementById('test-div');
if (params && params['hb_adid']) {
iframe.parentElement.style.position = "relative";
iframe.style.display = "block";
pbjs.renderAd(iframe.contentDocument, params['hb_adid']);
}
}
});
});
</script>
</head>

<body>
<h2>Prebid.js InImage Banner Test</h2>
<h2>Prebid.js InImage Banner Test</h2>

<div style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />
<iframe id='test-div' class="banner-block" style="display: none;"></iframe>
</div>
<div style="width: 600px;">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" width="100%" />
<iframe id='test-div' class="banner-block" style="display: none;"></iframe>
</div>
</body>

</html>
Expand All @@ -109,90 +112,91 @@ var adUnits = [{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<script async src="prebid.js"></script>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
.banner-block div {
width: 100%;
height: 100%;
}
</style>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var adUnits = [{
code: 'div-gpt-ad-1574864639578-0',
mediaTypes: {
banner: {
sizes: [1, 1]
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5af45ad34d506ee7acad0c26",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad();
});
pbjs.que.push(() => {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});
function sendAdServerRequest() {
googletag.cmd.push(() => {
pbjs.que.push(() => {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-0');
googletag.pubads().refresh();
});
});
}
googletag.cmd.push(() => {
googletag
.defineSlot('/21877108735/rtb-pbjs', [1, 1], 'div-gpt-ad-1574864639578-0')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<meta charset="UTF-8">
<title>Prebid.js Banner gpt Example</title>
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="../../../build/dev/prebid.js"></script>
<style>
.banner-block {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border: none;
overflow: hidden;
}
.banner-block div {
width: 100%;
height: 100%;
}
</style>
<script>
var sizes = [1, 1];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var adUnits = [{
code: 'div-gpt-ad-1574864639578-0',
mediaTypes: {
banner: {
sizes: sizes,
}
},
bids: [{
bidder: "astraone",
params: {
placement: "inImage",
placeId: "5f477bf94d506ebe2c4240f3",
imageUrl: "https://creative.astraone.io/files/default_image-1-600x400.jpg"
}
}]
}];
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad();
});
pbjs.que.push(() => {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});
function sendAdServerRequest() {
googletag.cmd.push(() => {
pbjs.que.push(() => {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1574864639578-0');
googletag.pubads().refresh();
});
});
}
googletag.cmd.push(() => {
googletag
.defineSlot('/21877108735/rtb-pbjs', sizes, 'div-gpt-ad-1574864639578-0')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<h2>Prebid.js Banner Ad Unit Test</h2>
<h2>Prebid.js InImage Banner gpt Test</h2>

<div style="width: 600px; position: relative">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />
<div style="width: 600px; position: relative">
<img src="https://creative.astraone.io/files/default_image-1-600x400.jpg" />

<div id='div-gpt-ad-1574864639578-0' class="banner-block">
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1574864639578-0'); });
</script>
</div>
</div>
<div id='div-gpt-ad-1574864639578-0' class="banner-block">
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1574864639578-0'); });
</script>
</div>
</div>
</body>
</html>
```
Loading

0 comments on commit 438b0b0

Please sign in to comment.