Skip to content

Commit

Permalink
remove bidderCode and parse response
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Pan committed Nov 3, 2017
1 parent 540745a commit 580181a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
13 changes: 6 additions & 7 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ export const sharethroughAdapterSpec = {
};
})
},
interpretResponse: (resp, req) => {
if (!Object.keys(resp).length) return [];
interpretResponse: ({ body }, req) => {
if (!Object.keys(body).length) return [];

const creative = resp.creatives[0];
const creative = body.creatives[0];

return [{
requestId: req.data.bidId,
bidderCode: BIDDER_CODE,
width: 0,
height: 0,
cpm: creative.cpm,
Expand All @@ -38,18 +37,18 @@ export const sharethroughAdapterSpec = {
currency: 'USD',
netRevenue: true,
ttl: 360,
ad: generateAd(resp, req)
ad: generateAd(body, req)
}];
}
}

function generateAd(resp, req) {
function generateAd(body, req) {
const strRespId = `str_response_${req.data.bidId}`;

return `
<div data-str-native-key="${req.data.placement_key}" data-stx-response-name="${strRespId}">
</div>
<script>var ${strRespId} = "${btoa(JSON.stringify(resp))}"</script>
<script>var ${strRespId} = "${btoa(JSON.stringify(body))}"</script>
<script src="//native.sharethrough.com/assets/sfp-set-targeting.js"></script>
<script>
(function() {
Expand Down
28 changes: 15 additions & 13 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ const prebidRequest = [{
}
}];
const bidderResponse = {
'adserverRequestId': '40b6afd5-6134-4fbb-850a-bb8972a46994',
'bidId': 'bidId1',
'version': 1,
'creatives': [{
'auctionWinId': 'b2882d5e-bf8b-44da-a91c-0c11287b8051',
'cpm': 12.34,
'creative': {
'deal_id': 'aDealId',
'creative_key': 'aCreativeId'
}
}],
'stxUserId': ''
body: {
'adserverRequestId': '40b6afd5-6134-4fbb-850a-bb8972a46994',
'bidId': 'bidId1',
'version': 1,
'creatives': [{
'auctionWinId': 'b2882d5e-bf8b-44da-a91c-0c11287b8051',
'cpm': 12.34,
'creative': {
'deal_id': 'aDealId',
'creative_key': 'aCreativeId'
}
}],
'stxUserId': ''
},
header: { get: (header) => header }
};

describe('sharethrough adapter spec', () => {
Expand Down Expand Up @@ -95,7 +98,6 @@ describe('sharethrough adapter spec', () => {
it('returns a correctly parsed out response', () => {
expect(spec.interpretResponse(bidderResponse, prebidRequest[0])[0]).to.include(
{
bidderCode: 'sharethrough',
width: 0,
height: 0,
cpm: 12.34,
Expand Down

0 comments on commit 580181a

Please sign in to comment.