Skip to content

Commit

Permalink
Nativo Bid Adapter : changed request method to POST and added OpenRTB…
Browse files Browse the repository at this point in the history
… payload (prebid#10323)

* Initial nativoBidAdapter document creation (js, md and spec)

* Fulling working prebid using nativoBidAdapter. Support for GDPR and CCPA in user syncs.

* Added defult size settings based on the largest ad unit. Added response body validation. Added consent to request url qs params.

* Changed bidder endpoint url

* Changed double quotes to single quotes.

* Reverted package-json.lock to remove modifications from PR

* Added optional bidder param 'url' so the ad server can force- match an existing placement

* Lint fix. Added space after if.

* Added new QS param to send various adUnit data to adapter endpopint

* Updated unit test for new QS param

* Added qs param to keep track of ad unit refreshes

* Updated bidMap key default value

* Updated refresh increment logic

* Refactored spread operator for IE11 support

* Updated isBidRequestValid check

* Refactored Object.enties to use Object.keys to fix CircleCI testing errors

* Updated bid mapping key creation to prioritize ad unit code over placementId

* Added filtering by ad, advertiser and campaign.

* Merged master

* Added more robust bidDataMap with multiple key access

* Deduped filer values

* Rolled back package.json

* Duped upstream/master's package.lock file ... not sure how it got changed in the first place

* Small refactor of filterData length check. Removed comparison with 0 since a length value of 0 is already falsy.

* Added bid sizes to request

* Fixed function name in spec. Added unit tests.

* Added priceFloor module support

* Added protection agains empty url parameter

* Changed ntv_url QS param to use referrer.location instead of referrer.page

* Removed testing 'only' flag

* Added ntv_url QS param value validation

* Added userId support

* Added unit tests, refactored for bugs

* Wrapped ajax in try/catch

* Added more unit testing

* Updated eid check for duplicate values. Removed error logging as we no longer need it.

* Removed spec test .only. Fixed unit tests that were breaking.

* Added Prebid version to nativo exchange request

* Removed unused bidder methods

* Added OpenRTB payload response. Changes requerst type to POST.

* Removed debug log

* Added/fixed tests
  • Loading branch information
jsfledd authored and Santiago Carabone committed Aug 22, 2023
1 parent 7f9531f commit 6dffc62
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
24 changes: 21 additions & 3 deletions modules/nativoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import { deepAccess, isEmpty } from '../src/utils.js'
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { BANNER } from '../src/mediaTypes.js'
import { getGlobal } from '../src/prebidGlobal.js'
// import { config } from 'src/config'
import { ortbConverter } from '../libraries/ortbConverter/converter.js'

const converter = ortbConverter({
context: {
// `netRevenue` and `ttl` are required properties of bid responses - provide a default for them
netRevenue: true, // or false if your adapter should set bidResponse.netRevenue = false
ttl: 30 // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp)
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
imp.tagid = bidRequest.adUnitCode
return imp;
}
});

const BIDDER_CODE = 'nativo'
const BIDDER_ENDPOINT = 'https://exchange.postrelease.com/prebid'
Expand Down Expand Up @@ -136,6 +149,10 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
// Get OpenRTB Data
const openRTBData = converter.toORTB({bidRequests: validBidRequests, bidderRequest})
const openRTBDataString = JSON.stringify(openRTBData)

const requestData = new RequestData()
requestData.addBidRequestDataSource(new UserEIDs())

Expand Down Expand Up @@ -271,8 +288,9 @@ export const spec = {
const requestUrl = buildRequestUrl(BIDDER_ENDPOINT, qsParamStrings)

let serverRequest = {
method: 'GET',
url: requestUrl
method: 'POST',
url: requestUrl,
data: openRTBDataString,
}

return serverRequest
Expand Down
7 changes: 6 additions & 1 deletion test/spec/modules/nativoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,19 @@ describe('nativoBidAdapterTests', function () {
bidRequests = [JSON.parse(bidRequestString)]
})

it('url should contain query string parameters', function () {
it('Request should be POST, with JSON string payload and QS params should be added to the url', function () {
const request = spec.buildRequests(bidRequests, {
bidderRequestId: 123456,
refererInfo: {
referer: 'https://www.test.com',
},
})

expect(request.method).to.equal('POST')

expect(request.data).to.exist
expect(request.data).to.be.a('string')

expect(request.url).to.exist
expect(request.url).to.be.a('string')

Expand Down

0 comments on commit 6dffc62

Please sign in to comment.