-
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
topRTBBidAdapter #3817
Merged
Merged
topRTBBidAdapter #3817
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
befda7e
toprtbBidAdapter
djaxtechgit 478fbc7
topRTB adapter hbid queryparam added
djaxtechgit 8d7fe98
toprtbBidAdapter-ssp aws url
djaxtechgit cc620a4
topRTBBidAdapter
djaxtechgit 024b10a
Video format topRTBBidAdapter
djaxtechgit a82e0a0
Video format topRTBBidAdapter
djaxtechgit 8e48efa
deviceType added
djaxtechgit be63d8a
tracking new added
Unnamalai57 b8392d2
impression event added
Unnamalai57 227bb38
fix test failed
Unnamalai57 8e12dc6
fix testing failed
Unnamalai57 306b0aa
removed debug logs
Unnamalai57 a5832e8
added single quotes in adUnitId
Unnamalai57 c89ab55
remove console log
Unnamalai57 99134d9
code committed to add SSL
Unnamalai57 5c36ada
adunitId changes for valid response
Unnamalai57 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,65 @@ | ||
import * as utils from '../src/utils'; | ||
import {registerBidder} from '../src/adapters/bidderFactory'; | ||
import {BANNER, VIDEO} from '../src/mediaTypes'; | ||
|
||
const BIDDER_CODE = 'topRTB'; | ||
const ENDPOINT_URL = 'https://ssp.toprtb.com/ssp/rest/ReqAd?ref=www.google.com&hbid=0&adUnitId='; | ||
var adName = ''; | ||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER, VIDEO], | ||
isBidRequestValid: function (bid) { | ||
if (utils.deepAccess(bid, 'mediaTypes.banner')) { | ||
adName = 'banner'; | ||
return bid.params && !!bid.params.adUnitId; | ||
} | ||
if (utils.deepAccess(bid, 'mediaTypes.video')) { | ||
adName = 'video'; | ||
return bid.params && !!bid.params.adUnitId; | ||
} | ||
}, | ||
|
||
buildRequests: function (validBidRequests, bidderRequest) { | ||
let adunitid = []; | ||
utils._each(validBidRequests, function (bid) { | ||
adunitid.push(bid.params.adUnitId + '_' + bid.bidId); | ||
}); | ||
|
||
return { | ||
method: 'GET', | ||
url: ENDPOINT_URL + adunitid.toString() | ||
}; | ||
}, | ||
|
||
interpretResponse: function(serverResponses, request) { | ||
const bidResponses = []; | ||
utils._each(serverResponses.body, function(response) { | ||
if (response.cpm > 0) { | ||
const bidResponse = { | ||
requestId: response.bidId, | ||
cpm: response.cpm, | ||
width: response.width, | ||
height: response.height, | ||
ad: response.mediadata, | ||
ttl: response.ttl, | ||
creativeId: response.id, | ||
netRevenue: true, | ||
currency: response.currency, | ||
tracking: response.tracking, | ||
impression: response.impression | ||
}; | ||
if (adName == 'video') { | ||
bidResponse.vastXml = response.mediadata; | ||
bidResponse.mediaType = 'video'; | ||
} else { | ||
bidResponse.ad = response.mediadata; | ||
bidResponse.mediaType = 'banner'; | ||
Unnamalai57 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
bidResponses.push(bidResponse); | ||
} | ||
}); | ||
return bidResponses; | ||
} | ||
}; | ||
|
||
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: topRTB Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: [email protected] | ||
``` | ||
|
||
# Description | ||
|
||
topRTB Bidder Adapter for Prebid.js. | ||
Only Banner & video format is supported. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'test-div-0', | ||
sizes: [[728, 90]], // a display size | ||
bids: [ | ||
{ | ||
bidder: 'topRTB', | ||
params: { | ||
adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
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,67 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/topRTBBidAdapter'; | ||
|
||
describe('topRTBBidAdapterTests', function () { | ||
it('validate_pub_params', function () { | ||
expect(spec.isBidRequestValid({ | ||
bidder: 'topRTB', | ||
params: { | ||
adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' | ||
}, | ||
adName: 'banner' | ||
})); | ||
}); | ||
|
||
it('validate_generated_params', function () { | ||
let bidRequestData = [{ | ||
bidId: 'bid12345', | ||
bidder: 'topRTB', | ||
adName: 'banner', | ||
adType: '{"banner":{"sizes":[[]]}}', | ||
params: { | ||
adUnitId: 'c5c06f77430c4c33814a0577cb4cc978' | ||
}, | ||
sizes: [[728, 90]] | ||
}]; | ||
|
||
let request = spec.buildRequests(bidRequestData); | ||
const current_url = request.url; | ||
const search_params = current_url.searchParams; | ||
}); | ||
|
||
it('validate_response_params', function () { | ||
let bidRequestData = { | ||
data: { | ||
bidId: 'bid12345' | ||
} | ||
}; | ||
|
||
let serverResponse = { | ||
body: [{ | ||
'cpm': 1, | ||
'mediadata': "<a href='http://13.125.21.204:8080/bidder/click?url=xaCQyxrEJsY7XQj4dRGD2RVQiVaLJ%2Bar%2BVDhwhlpnR%2FSQG%2B9%2FtSmvV4X45AM9mMl%2BOSaJzKXTKN82WHc1li3gCzibhr%2ByfcqPIl%2FQHJjBKS7bznHEwRh1kZShVVnSpp3DBjS5I5WSmSD4Qbyo61IJq3LFc9OpHKmJeMgATc4bHK00MqW7atQStUWWSTuhlGO&details=l5G4hDG5UmRmJ%2BB9AdG7v2OpwH%2Bio9Y2oIETI6KooMoo7lJ4Yo7pTbfVGhA5Vn%2BaPCoBX4779c1Jqok45%2FL2ZUP0nc7F0IDfRpLdtoX%2B7Hr2tqmK2Suide0LIsB0woVDXBiq62%2BfneGrTnCi6Nq6GDIBFpmFH8CFinYL%2F%2BB33V8%3D' target='_blank'><img src='http://www.toprtb.com/uploads/d037c2d94369417ab9aea6e712723235/728-90_1546872001356_728x90.gif' alt='Banner 728x90' width='728' height='90' /></a><img src='http://13.125.21.204:8080/bidder/impression?id=e1fb1fbdb97643189827b1b4d2b51acc&impid=1' width='1' height='1' alt=''/></a><img src='http://13.124.144.40:8080/ssp/impression?id=e1fb1fbdb97643189827b1b4d2b51acc&impid=1' width='1' height='1' alt=''/>", | ||
'width': 728, | ||
'currency': 'USD', | ||
'id': 'cd95dffec6b645afbc4e5aa9f68f2ff3', | ||
'type': 'RICHMEDIA', | ||
'ttl': 4000, | ||
'bidId': 'bid12345', | ||
'status': 'success', | ||
'height': 90}], | ||
'adName': 'banner', | ||
'vastXml': '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><VAST version="2.0"></VAST>', | ||
'mediaType': 'banner', | ||
'tracking': 'https://ssp.toprtb.com/ssp/tracking?F0cloTiKIw%2BjZ2UNDvlKGn5%2FWoAO9cnlAUDm6gFBM8bImY2fKo%2BMTvI0XvXzFTZSb5v8o4EUbPId9hckptTqA4QPaWvpVYCRKRZceXNa4kjtvfm4j2e%2FcRKgkns2goHXi7IZC0sBIbE77WWg%2BPBYv%2BCu84H%2FSH69mi%2FDaWcQlfaEOdkaJdstJEkaZtkgWnFnS7aagte%2BfdEbOqcTxq5hzj%2BZ4NZbwgReuWTQZbfrMWjkXFbn%2B35vZuI319o6XH9n9fKLS4xp8zstXfQT2oSgjw1NmrwqRKf1efB1UaWlS1TbkSqxZ7Kcy7nJvAZrDk0tzcSeIxe4VfHpwgPPs%2BueUeGwz3o7OCh7H1sCmogSrmJFB9JTeXudFjC13iANAtu4SvG9bGIbiJxS%2BNfkjy2mLFm8kSIcIobjNkMEcUAwmoqJNRndwb66a3Iovk2NTo0Ly%2FV7Y5ECPcS5%2FPBrIEOuQXS5SNUPRWKoklX5nexHtOc%3D', | ||
'impression': 'https://ssp.toprtb.com/ssp/impression?id=64f29f7b226249f19925a680a506b32d' | ||
}; | ||
|
||
let bids = spec.interpretResponse(serverResponse, bidRequestData); | ||
expect(bids).to.have.lengthOf(1); | ||
let bid = bids[0]; | ||
expect(bid.cpm).to.equal(1); | ||
expect(bid.currency).to.equal('USD'); | ||
expect(bid.width).to.equal(728); | ||
expect(bid.height).to.equal(90); | ||
expect(bid.requestId).to.equal('bid12345'); | ||
}); | ||
}); |
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.
Your test coverage is just barely at 80%
Would love to see those numbers jump up more soon. Will not reject PR for this, but please try to increase coverage on future PR's!
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.
@robertrmartinez could you please tell me how can I enhance the testing to achieve 100%