-
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
Adding Edge Query X Adapter (with right md file) #5266
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c57685b
Add files via upload
5041c78
Bug fixed
37f7257
Remove some new lines
e3139a9
Correction Circle
c497f15
Test Unit
4fc2a5f
Indent
64c2924
Indent 2 space
a99148b
Single quote
58d2388
test unit
012791c
requestID
9652a2a
Rename mb to md
42b7e3d
add md
b964189
Correcting md file
e0981f1
Improving gulp test to get more than 80%
3ff36fb
Correcting double lines
16f89fb
Update package-lock.json
d312272
Back to original lock version
82aa860
Back to original package-lock.json version
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,98 @@ | ||
import * as utils from '../src/utils.js'; | ||
import { config } from '../src/config.js'; | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { BANNER, VIDEO } from '../src/mediaTypes.js'; | ||
|
||
const BIDDER_CODE = 'edgequeryx'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
aliases: ['eqx'], // short code | ||
supportedMediaTypes: [BANNER, VIDEO], | ||
/** | ||
* Determines whether or not the given bid request is valid. | ||
* | ||
* @param {BidRequest} bid The bid params to validate. | ||
* @return boolean True if this is a valid bid, and false otherwise. | ||
*/ | ||
isBidRequestValid: function (bid) { | ||
return !!(bid.params && bid.params.accountId && bid.params.widgetId); | ||
}, | ||
|
||
/** | ||
* Make a server request from the list of BidRequests. | ||
* | ||
* @param {BidRequest[]} validBidRequests an array of bids | ||
* @param {BidderRequest} bidderRequest bidder request object | ||
* @return {ServerRequest[]} Info describing the request to the server. | ||
*/ | ||
buildRequests: function (validBidRequests, bidderRequest) { | ||
// use bidderRequest.bids[] to get bidder-dependent request info | ||
// if your bidder supports multiple currencies, use config.getConfig(currency) | ||
// to find which one the ad server needs | ||
|
||
// pull requested transaction ID from bidderRequest.bids[].transactionId | ||
return validBidRequests.map(bid => { | ||
// Common bid request attributes for banner, outstream and instream. | ||
let payload = { | ||
accountId: bid.params.accountId, | ||
widgetId: bid.params.widgetId, | ||
currencyCode: 'EUR', | ||
tagId: bid.adUnitCode, | ||
transactionId: bid.transactionId, | ||
timeout: config.getConfig('bidderTimeout'), | ||
bidId: bid.bidId, | ||
prebidVersion: '$prebid.version$' | ||
}; | ||
|
||
const bannerMediaType = utils.deepAccess(bid, 'mediaTypes.banner'); | ||
payload.sizes = bannerMediaType.sizes.map(size => ({ | ||
w: size[0], | ||
h: size[1] | ||
})); | ||
|
||
var payloadString = JSON.stringify(payload); | ||
|
||
return { | ||
method: 'POST', | ||
url: (bid.params.domain !== undefined ? bid.params.domain : 'https://deep.edgequery.io') + '/prebid/x', | ||
data: payloadString, | ||
}; | ||
}); | ||
}, | ||
|
||
/** | ||
* Unpack the response from the server into a list of bids. | ||
* | ||
* @param {*} serverResponse A successful response from the server. | ||
* @param {*} bidRequestString | ||
* @return {Bid[]} An array of bids which were nested inside the server. | ||
*/ | ||
interpretResponse: function (serverResponse, bidRequestString) { | ||
const bidResponses = []; | ||
let response = serverResponse.body; | ||
try { | ||
if (response) { | ||
let bidResponse = { | ||
requestId: response.requestId, | ||
cpm: response.cpm, | ||
currency: response.currency, | ||
width: response.width, | ||
height: response.height, | ||
ad: response.ad, | ||
ttl: response.ttl, | ||
creativeId: response.creativeId, | ||
netRevenue: response.netRevenue | ||
}; | ||
|
||
bidResponses.push(bidResponse); | ||
} | ||
} catch (error) { | ||
utils.logError('Error while parsing Edge Query X response', error); | ||
} | ||
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,39 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Edge Query X Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: contact@edgequery.com | ||
``` | ||
|
||
# Description | ||
|
||
Connect to Edge Query X for bids. | ||
|
||
The Edge Query X adapter requires setup and approval from the Edge Query team. | ||
Please reach out to your Technical account manager for more information. | ||
|
||
# Test Parameters | ||
|
||
## Web | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: 'test-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[1, 1]] | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "edgequeryx", | ||
params: { | ||
accountId: "test", | ||
widgetId: "test" | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { | ||
expect | ||
} from 'chai'; | ||
import { | ||
spec | ||
} from 'modules/edgequeryxBidAdapter.js'; | ||
import { | ||
newBidder | ||
} from 'src/adapters/bidderFactory.js'; | ||
import { | ||
config | ||
} from 'src/config.js'; | ||
import * as utils from 'src/utils.js'; | ||
import { requestBidsHook } from 'modules/consentManagement.js'; | ||
|
||
// Default params with optional ones | ||
describe('Edge Query X bid adapter tests', function () { | ||
var DEFAULT_PARAMS = [{ | ||
bidId: 'abcd1234', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [ | ||
[1, 1] | ||
] | ||
} | ||
}, | ||
bidder: 'edgequeryx', | ||
params: { | ||
accountId: 'test', | ||
widgetId: 'test' | ||
}, | ||
requestId: 'efgh5678', | ||
transactionId: 'zsfgzzg' | ||
}]; | ||
var BID_RESPONSE = { | ||
body: { | ||
requestId: 'abcd1234', | ||
cpm: 22, | ||
width: 1, | ||
height: 1, | ||
creativeId: 'EQXTest', | ||
currency: 'EUR', | ||
netRevenue: true, | ||
ttl: 360, | ||
ad: '< --- awesome script --- >' | ||
} | ||
}; | ||
|
||
it('Verify build request', function () { | ||
config.setConfig({ | ||
'currency': { | ||
'adServerCurrency': 'EUR' | ||
} | ||
}); | ||
const request = spec.buildRequests(DEFAULT_PARAMS); | ||
expect(request[0]).to.have.property('url').and.to.equal('https://deep.edgequery.io/prebid/x'); | ||
expect(request[0]).to.have.property('method').and.to.equal('POST'); | ||
const requestContent = JSON.parse(request[0].data); | ||
|
||
expect(requestContent).to.have.property('accountId').and.to.equal('test'); | ||
expect(requestContent).to.have.property('widgetId').and.to.equal('test'); | ||
expect(requestContent).to.have.property('sizes'); | ||
expect(requestContent.sizes[0]).to.have.property('w').and.to.equal(1); | ||
expect(requestContent.sizes[0]).to.have.property('h').and.to.equal(1); | ||
}); | ||
|
||
it('Verify parse response', function () { | ||
const request = spec.buildRequests(DEFAULT_PARAMS); | ||
const bids = spec.interpretResponse(BID_RESPONSE, request[0]); | ||
expect(bids).to.have.lengthOf(1); | ||
const bid = bids[0]; | ||
expect(bid.cpm).to.equal(22); | ||
expect(bid.ad).to.equal('< --- awesome script --- >'); | ||
expect(bid.width).to.equal(1); | ||
expect(bid.height).to.equal(1); | ||
expect(bid.creativeId).to.equal('EQXTest'); | ||
expect(bid.currency).to.equal('EUR'); | ||
expect(bid.netRevenue).to.equal(true); | ||
expect(bid.ttl).to.equal(360); | ||
expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId); | ||
|
||
expect(function () { | ||
spec.interpretResponse(BID_RESPONSE, { | ||
data: 'invalid Json' | ||
}) | ||
}).to.not.throw(); | ||
}); | ||
|
||
it('Verifies bidder code', function () { | ||
expect(spec.code).to.equal('edgequeryx'); | ||
}); | ||
|
||
it('Verifies bidder aliases', function () { | ||
expect(spec.aliases).to.have.lengthOf(1); | ||
expect(spec.aliases[0]).to.equal('eqx'); | ||
}); | ||
|
||
it('Verifies if bid request valid', function () { | ||
expect(spec.isBidRequestValid(DEFAULT_PARAMS[0])).to.equal(true); | ||
expect(spec.isBidRequestValid({})).to.equal(false); | ||
expect(spec.isBidRequestValid({ | ||
params: {} | ||
})).to.equal(false); | ||
expect(spec.isBidRequestValid({ | ||
params: { | ||
widgetyId: 'abcdef' | ||
} | ||
})).to.equal(false); | ||
expect(spec.isBidRequestValid({ | ||
params: { | ||
widgetId: 'test', | ||
accountId: 'test' | ||
} | ||
})).to.equal(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.
any specific reason why you use this multi-line format for imports here, while on lines 13 and 14 you're inlining them?