-
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
New adapter: Colombia #5158
Merged
Merged
New adapter: Colombia #5158
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9b32475
Add colombia adapter
ColombiaOnline d4c49dd
Add https in the url
ColombiaOnline 6da9cb5
update files
ColombiaOnline cb026ea
resolve marge file
ColombiaOnline 2213e1b
Resolved conflict
ColombiaOnline d8f3ff1
add test cases and update md file
ColombiaOnline 8071c03
remove native from package.json and update colombia test cases
ColombiaOnline 8642bf9
Use conditions for the size
ColombiaOnline 9466e8b
Use conditions for the size and remove test warnings
ColombiaOnline f87587a
remove package.json
ColombiaOnline 4ac3eef
Merged from upstream
ColombiaOnline de95bc1
Resolved import related errors
ColombiaOnline 8c32ee6
update referrer method
ColombiaOnline d514523
Merge branch 'master' of https://github.com/prebid/Prebid.js
ColombiaOnline b13d344
remove package json and update referer path
ColombiaOnline ea41a16
Merge branch 'master' of https://github.com/prebid/Prebid.js
ColombiaOnline 1beff3d
revert package json
ColombiaOnline 29be11f
Resolved all changes
ColombiaOnline 618318b
update version package json
ColombiaOnline c22f94c
Resolved conflicts
ColombiaOnline 5dae91d
Resolved test cases issues
ColombiaOnline 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,82 @@ | ||
import * as utils from '../src/utils.js'; | ||
import {config} from '../src/config.js'; | ||
import {registerBidder} from '../src/adapters/bidderFactory.js'; | ||
import { BANNER } from '../src/mediaTypes.js'; | ||
const BIDDER_CODE = 'colombia'; | ||
const ENDPOINT_URL = 'https://ade.clmbtech.com/cde/prebid.htm'; | ||
const HOST_NAME = document.location.protocol + '//' + window.location.host; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
aliases: ['clmb'], | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid: function(bid) { | ||
return !!(bid.params.placementId); | ||
}, | ||
buildRequests: function(validBidRequests, bidderRequest) { | ||
return validBidRequests.map(bidRequest => { | ||
const params = bidRequest.params; | ||
const sizes = utils.parseSizesInput(bidRequest.sizes)[0]; | ||
const width = sizes.split('x')[0]; | ||
const height = sizes.split('x')[1]; | ||
const placementId = params.placementId; | ||
const cb = Math.floor(Math.random() * 99999999999); | ||
const bidId = bidRequest.bidId; | ||
const referrer = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : ''; | ||
const payload = { | ||
v: 'hb1', | ||
p: placementId, | ||
w: width, | ||
h: height, | ||
cb: cb, | ||
r: referrer, | ||
uid: bidId, | ||
t: 'i', | ||
d: HOST_NAME, | ||
}; | ||
return { | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
data: payload, | ||
} | ||
}); | ||
}, | ||
interpretResponse: function(serverResponse, bidRequest) { | ||
const bidResponses = []; | ||
const response = serverResponse.body; | ||
const crid = response.creativeId || 0; | ||
const width = response.width || 0; | ||
const height = response.height || 0; | ||
let cpm = response.cpm || 0; | ||
if (width == 300 && height == 250) { | ||
cpm = cpm * 0.2; | ||
} | ||
if (width == 320 && height == 50) { | ||
cpm = cpm * 0.55; | ||
} | ||
if (cpm < 1) { | ||
return bidResponses; | ||
} | ||
if (width !== 0 && height !== 0 && cpm !== 0 && crid !== 0) { | ||
const dealId = response.dealid || ''; | ||
const currency = response.currency || 'USD'; | ||
const netRevenue = (response.netRevenue === undefined) ? true : response.netRevenue; | ||
const bidResponse = { | ||
requestId: bidRequest.data.uid, | ||
cpm: cpm, | ||
width: response.width, | ||
height: response.height, | ||
creativeId: crid, | ||
dealId: dealId, | ||
currency: currency, | ||
netRevenue: netRevenue, | ||
ttl: config.getConfig('_bidderTimeout'), | ||
referrer: bidRequest.data.r, | ||
ad: response.ad | ||
}; | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,152 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/colombiaBidAdapter'; | ||
import { newBidder } from 'src/adapters/bidderFactory'; | ||
|
||
const HOST_NAME = document.location.protocol + '//' + window.location.host; | ||
const ENDPOINT = 'https://ade.clmbtech.com/cde/prebid.htm'; | ||
|
||
describe('colombiaBidAdapter', function() { | ||
const adapter = newBidder(spec); | ||
|
||
describe('isBidRequestValid', function () { | ||
let bid = { | ||
'bidder': 'colombia', | ||
'params': { | ||
placementId: '307466' | ||
}, | ||
'adUnitCode': 'adunit-code', | ||
'sizes': [ | ||
[300, 250] | ||
], | ||
'bidId': '23beaa6af6cdde', | ||
'bidderRequestId': '19c0c1efdf37e7', | ||
'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', | ||
}; | ||
|
||
it('should return true when required params found', function () { | ||
expect(spec.isBidRequestValid(bid)).to.equal(true); | ||
}); | ||
|
||
it('should return false when placementId not passed correctly', function () { | ||
bid.params.placementId = ''; | ||
expect(spec.isBidRequestValid(bid)).to.equal(false); | ||
}); | ||
|
||
it('should return false when require params are not passed', function () { | ||
let bid = Object.assign({}, bid); | ||
bid.params = {}; | ||
expect(spec.isBidRequestValid(bid)).to.equal(false); | ||
}); | ||
}); | ||
|
||
describe('buildRequests', function () { | ||
let bidRequests = [ | ||
{ | ||
'bidder': 'colombia', | ||
'params': { | ||
placementId: '307466' | ||
}, | ||
'adUnitCode': 'adunit-code1', | ||
'sizes': [ | ||
[300, 250] | ||
], | ||
'bidId': '23beaa6af6cdde', | ||
'bidderRequestId': '19c0c1efdf37e7', | ||
'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', | ||
}, | ||
{ | ||
'bidder': 'colombia', | ||
'params': { | ||
placementId: '307466' | ||
}, | ||
'adUnitCode': 'adunit-code2', | ||
'sizes': [ | ||
[300, 250] | ||
], | ||
'bidId': '382091349b149f"', | ||
'bidderRequestId': '"1f9c98192de251"', | ||
'auctionId': '61466567-d482-4a16-96f0-fe5f25ffbdf1', | ||
} | ||
]; | ||
|
||
const request = spec.buildRequests(bidRequests); | ||
|
||
it('sends bid request to our endpoint via POST', function () { | ||
expect(request[0].method).to.equal('POST'); | ||
expect(request[1].method).to.equal('POST'); | ||
}); | ||
|
||
it('attaches source and version to endpoint URL as query params', function () { | ||
expect(request[0].url).to.equal(ENDPOINT); | ||
expect(request[1].url).to.equal(ENDPOINT); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', function () { | ||
let bidRequest = [ | ||
{ | ||
'method': 'POST', | ||
'url': 'https://ade.clmbtech.com/cde/prebid.htm', | ||
'data': { | ||
'v': 'hb1', | ||
'p': '307466', | ||
'w': '300', | ||
'h': '250', | ||
'cb': 12892917383, | ||
'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', | ||
'uid': '23beaa6af6cdde', | ||
't': 'i', | ||
} | ||
} | ||
]; | ||
|
||
let serverResponse = { | ||
body: { | ||
'ad': '<div>This is test case for colombia adapter</div> ', | ||
'cpm': 3.14, | ||
'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', | ||
'currency': 'USD', | ||
'uid': '23beaa6af6cdde', | ||
'width': 728, | ||
'height': 90, | ||
'netRevenue': true, | ||
'ttl': 600, | ||
'dealid': '', | ||
'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836' | ||
} | ||
}; | ||
|
||
it('should get the correct bid response', function () { | ||
let expectedResponse = [{ | ||
'requestId': '23beaa6af6cdde', | ||
'cpm': 3.14, | ||
'width': 728, | ||
'height': 90, | ||
'creativeId': '6b958110-612c-4b03-b6a9-7436c9f746dc-1sk24', | ||
'dealId': '', | ||
'currency': 'USD', | ||
'netRevenue': true, | ||
'ttl': 300, | ||
'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', | ||
'ad': '<div>This is test case for colombia adapter</div>' | ||
}]; | ||
let result = spec.interpretResponse(serverResponse, bidRequest[0]); | ||
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); | ||
}); | ||
|
||
it('handles empty bid response', function () { | ||
let response = { | ||
body: { | ||
'uid': '23beaa6af6cdde', | ||
'height': 0, | ||
'creativeId': '', | ||
'statusMessage': 'Bid returned empty or error response', | ||
'width': 0, | ||
'cpm': 0 | ||
} | ||
}; | ||
let result = spec.interpretResponse(response, bidRequest[0]); | ||
expect(result.length).to.equal(0); | ||
}); | ||
}); | ||
}); |
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.
When running
npx gulp test
, I get this other error: