-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Vrtcal Markets Inc. Bid Adapter Addition #4259
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import {registerBidder} from '../src/adapters/bidderFactory'; | ||
import { BANNER } from '../src/mediaTypes'; | ||
import {ajax} from '../src/ajax'; | ||
|
||
export const spec = { | ||
code: 'vrtcal', | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid: function (bid) { | ||
return true;// No extras params required | ||
}, | ||
buildRequests: function (bidRequests) { | ||
const requests = bidRequests.map(function (bid) { | ||
const params = { | ||
|
||
prebidJS: 1, | ||
prebidAdUnitCode: bid.adUnitCode, | ||
id: bid.bidId, | ||
imp: [{ | ||
id: '1', | ||
banner: { | ||
w: bid.sizes[0][0], | ||
h: bid.sizes[0][1], | ||
}, | ||
bidfloor: 0.75 | ||
}], | ||
site: { | ||
id: 'VRTCAL_FILLED', | ||
name: 'VRTCAL_FILLED', | ||
cat: ['VRTCAL_FILLED'], | ||
domain: decodeURIComponent(window.location.href).replace('https://', '').replace('http://', '').split('/')[0] | ||
|
||
}, | ||
device: { | ||
ua: 'VRTCAL_FILLED', | ||
ip: 'VRTCAL_FILLED' | ||
} | ||
}; | ||
|
||
return {method: 'POST', url: 'https://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804', data: JSON.stringify(params), options: {withCredentials: false, crossOrigin: true}} | ||
}); | ||
|
||
return requests; | ||
}, | ||
interpretResponse: function (serverResponse, bidRequest) { | ||
if (!serverResponse || !serverResponse.body) { | ||
return []; | ||
} | ||
|
||
const bidResponses = []; | ||
|
||
var response = serverResponse.body; | ||
|
||
if (response) { | ||
const bidResponse = { | ||
requestId: response.id, | ||
cpm: response.seatbid[0].bid[0].price, | ||
width: response.seatbid[0].bid[0].w, | ||
height: response.seatbid[0].bid[0].h, | ||
creativeId: response.seatbid[0].bid[0].crid, | ||
currency: 'USD', | ||
netRevenue: true, | ||
ttl: 900, | ||
ad: response.seatbid[0].bid[0].adm, | ||
nurl: response.seatbid[0].bid[0].nurl | ||
}; | ||
|
||
bidResponses.push(bidResponse); | ||
} | ||
return bidResponses; | ||
}, | ||
getUserSyncs: function(syncOptions, serverResponses) { | ||
return []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can remove this function if you're not going to be doing any usersyncing. |
||
}, | ||
onBidWon: function(bid) { | ||
if (!bid.nurl) { return; } | ||
const winUrl = bid.nurl.replace( | ||
/\$\{AUCTION_PRICE\}/, | ||
bid.cpm | ||
); | ||
ajax(winUrl, null); | ||
} | ||
}; | ||
|
||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Overview | ||
|
||
Module Name: Vrtcal Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: [email protected] | ||
|
||
# Description | ||
|
||
You can use this adapter to get a bid from vrtcal.com. | ||
|
||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: "vrtcal-test-adunit", | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]] | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "vrtcal" | ||
} | ||
] | ||
} | ||
]; | ||
``` | ||
#Vrtcal requires no extra params passed, thus no params struct included |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { expect } from 'chai' | ||
import { spec } from 'modules/vrtcalBidAdapter' | ||
import { newBidder } from 'src/adapters/bidderFactory' | ||
|
||
describe('vrtcalBidAdapter', function () { | ||
const adapter = newBidder(spec) | ||
|
||
let bidRequest = { | ||
bidId: 'bidID0001', | ||
transactionId: 'transID0001', | ||
sizes: [[ 300, 250 ]] | ||
} | ||
|
||
describe('isBidRequestValid', function () { | ||
it('should return true 100% of time as no special additional params are required, thus no additional validation needed', function () { | ||
expect(spec.isBidRequestValid(bidRequest)).to.be.true | ||
}) | ||
}) | ||
|
||
describe('buildRequests', function () { | ||
let bidRequests = [ | ||
{ | ||
'bidder': 'vrtcal', | ||
'adUnitCode': 'adunit0001', | ||
'sizes': [[300, 250]], | ||
'bidId': 'bidID0001', | ||
'bidderRequestId': 'br0001', | ||
'auctionId': 'auction0001', | ||
} | ||
]; | ||
|
||
const request = spec.buildRequests(bidRequests); | ||
|
||
it('sends bid request to our endpoint via POST', function () { | ||
expect(request[0].method).to.equal('POST'); | ||
}); | ||
|
||
it('adUnitCode should be sent as prebidAdUnitCode parameters on any requests', function () { | ||
expect(request[0].data).to.match(/"prebidAdUnitCode":"adunit0001"/); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', function () { | ||
it('should form compliant bid object response', function () { | ||
let res = { | ||
body: { | ||
id: 'bidID0001', | ||
seatbid: [{ | ||
bid: [{ | ||
id: 'VRTB_240d3c8a3c12b68_1', | ||
impid: '1', | ||
price: 0.7554, | ||
adm: 'TEST AD', | ||
nurl: 'https://exchange.vrtcal.com/wintracker', | ||
w: 300, | ||
h: 250, | ||
crid: 'v2_1064_vrt_vrtcaltestdisplay2_300_250', | ||
adomain: ['vrtcal.com'] | ||
}], | ||
seat: '16' | ||
}], | ||
cur: 'USD' | ||
} | ||
} | ||
|
||
let ir = spec.interpretResponse(res, bidRequest) | ||
|
||
expect(ir.length).to.equal(1) | ||
|
||
let en = ir[0] | ||
|
||
expect(en.requestId != null && | ||
en.cpm != null && typeof en.cpm === 'number' && | ||
en.width != null && typeof en.width === 'number' && | ||
en.height != null && typeof en.height === 'number' && | ||
en.ad != null && | ||
en.creativeId != null | ||
).to.be.true | ||
}) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to look at the
mediaTypes.banner.sizes
field instead of thebid.sizes
field, as that generic field may be deprecated in the future.