Skip to content

Commit

Permalink
Michao Bid Adapter: Support for rewarded advertising
Browse files Browse the repository at this point in the history
  • Loading branch information
hogekai committed Nov 27, 2024
1 parent ae817a3 commit 27d6259
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
11 changes: 8 additions & 3 deletions modules/michaoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ export function hasParamsObject(bid) {
}

export function validateMichaoParams(params) {
const michaoParams = ['site', 'placement'];
return michaoParams.every((michaoParam) =>
let valid = true;

const michaoAdUnitInfoParams = ['site', 'placement'];

valid = michaoAdUnitInfoParams.every((michaoParam) =>
Number.isFinite(params[michaoParam])
);

return valid
}

export function billBid(bid) {
Expand Down Expand Up @@ -178,8 +183,8 @@ const converter = ortbConverter({

imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
// imp.id = bidRequest.adUnitCode;
deepSetValue(imp, 'ext.placement', bidRequest.params.placement.toString());
deepSetValue(imp, 'rwdd', bidRequest.params?.reward ? 1 : false);

return imp;
},
Expand Down
47 changes: 39 additions & 8 deletions test/spec/modules/michaoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,41 @@ describe('the michao bidder adapter', () => {
'data.test': 1,
});
});

it('Specifying a reward builds a bid request for the reward.', () => {
const bidRequest = {
adUnitCode: 'test-div',
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
bidId: '22c4871113f461',
bidder: 'michao',
bidderRequestId: '15246a574e859f',
bidRequestsCount: 1,
bidderRequestsCount: 1,
bidderWinsCount: 0,
mediaTypes: { banner: [[300, 250]] },
params: {
site: 123,
placement: 456,
reward: true,
},
};
const bidderRequest = {
auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917',
auctionStart: 1579746300522,
bidderCode: 'michao',
bidderRequestId: '15246a574e859f',
bids: [bidRequest],
};
config.setConfig({
debug: true,
});

const result = buildRequest(bidRequest, bidderRequest, 'banner');

expect(result).to.nested.include({
'data.imp[0].rwdd': 1,
});
});
});

describe('interpret response', () => {
Expand Down Expand Up @@ -427,17 +462,13 @@ describe('the michao bidder adapter', () => {
},
{
adUnitCode: 'test-div',
auctionId: 'auction-1',
auctionId: 'auction-2',
bidId: 'bid-2',
bidder: 'michao',
bidderRequestId: 'bidder-request-1',
bidderRequestId: 'bidder-request-2',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480],
mimes: ['video/mp4'],
minduration: 0,
maxduration: 30,
banner: {
sizes: [[300, 250]],
},
},
params: {
Expand Down

0 comments on commit 27d6259

Please sign in to comment.