forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request prebid#15 from pm-harshad-mane/native_refactor
Native refactor
- Loading branch information
Showing
25 changed files
with
1,436 additions
and
383 deletions.
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
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 was deleted.
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,79 @@ | ||
import {registerBidder} from '../src/adapters/bidderFactory'; | ||
import * as utils from '../src/utils'; | ||
|
||
const BIDDER_CODE = 'adman'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: ['video', 'banner'], | ||
isBidRequestValid: function(bid) { | ||
const isValid = _validateId(utils.deepAccess(bid, 'params.id')); | ||
if (!isValid) { | ||
utils.logError('Adman id parameter is required. Bid aborted.'); | ||
} | ||
return isValid; | ||
}, | ||
buildRequests: function(validBidRequests, bidderRequest) { | ||
const ENDPOINT_URL = '//bidtor.admanmedia.com/prebid'; | ||
const bids = validBidRequests.map(buildRequestObject); | ||
const payload = { | ||
referrer: utils.getTopWindowUrl(), | ||
bids, | ||
deviceWidth: screen.width | ||
}; | ||
|
||
if (bidderRequest && bidderRequest.gdprConsent) { | ||
payload.gdpr = { | ||
consent: bidderRequest.gdprConsent.consentString, | ||
applies: bidderRequest.gdprConsent.gdprApplies | ||
}; | ||
} else { | ||
payload.gdpr = { | ||
consent: '' | ||
} | ||
} | ||
|
||
const payloadString = JSON.stringify(payload); | ||
return { | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
data: payloadString, | ||
}; | ||
}, | ||
interpretResponse: function(serverResponse) { | ||
serverResponse = serverResponse.body; | ||
if (serverResponse && typeof serverResponse.bids === 'object') { | ||
return serverResponse.bids; | ||
} | ||
return []; | ||
}, | ||
getUserSyncs: function(syncOptions) { | ||
if (syncOptions.iframeEnabled) { | ||
return [{ | ||
type: 'iframe', | ||
url: '//cs.admanmedia.com/sync_tag/html' | ||
}]; | ||
} | ||
} | ||
}; | ||
|
||
function buildRequestObject(bid) { | ||
return { | ||
params: { | ||
id: utils.getValue(bid.params, 'id'), | ||
bidId: bid.bidId | ||
}, | ||
sizes: bid.sizes, | ||
bidId: utils.getBidIdParameter('bidId', bid), | ||
bidderRequestId: utils.getBidIdParameter('bidderRequestId', bid), | ||
adUnitCode: utils.getBidIdParameter('adUnitCode', bid), | ||
auctionId: utils.getBidIdParameter('auctionId', bid), | ||
transactionId: utils.getBidIdParameter('transactionId', bid) | ||
}; | ||
} | ||
|
||
function _validateId(id = '') { | ||
return (id.length === 8); | ||
} | ||
|
||
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,35 @@ | ||
# Overview | ||
|
||
**Module Name**: Adman Bidder Adapter | ||
**Module Type**: Bidder Adapter | ||
**Maintainer**: prebid@admanmedia.com | ||
|
||
# Description | ||
|
||
Use `adman` as bidder. | ||
|
||
`id` is required and must be 8 alphanumeric characters. | ||
|
||
## AdUnits configuration example | ||
``` | ||
var adUnits = [{ | ||
code: 'test-div', | ||
sizes: [[300, 250]], | ||
bids: [{ | ||
bidder: 'adman', | ||
params: { | ||
id: 1234asdf | ||
} | ||
}] | ||
},{ | ||
code: 'test-div, | ||
sizes: [[600, 338]], | ||
bids: [{ | ||
bidder: 'adman', | ||
params: { | ||
id: asdf1234 | ||
} | ||
}] | ||
}]; | ||
``` | ||
|
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,66 @@ | ||
import {BANNER} from '../src/mediaTypes'; | ||
import {registerBidder} from '../src/adapters/bidderFactory'; | ||
|
||
const ADPONE_CODE = 'adpone'; | ||
const ADPONE_ENDPOINT = 'https://rtb.adpone.com/bid-request'; | ||
const ADPONE_REQUEST_METHOD = 'POST'; | ||
const ADPONE_CURRENCY = 'EUR'; | ||
|
||
export const spec = { | ||
code: ADPONE_CODE, | ||
supportedMediaTypes: [BANNER], | ||
|
||
isBidRequestValid: bid => { | ||
return !!bid.params.placementId && !!bid.bidId; | ||
}, | ||
|
||
buildRequests: bidRequests => { | ||
return bidRequests.map(bid => { | ||
const url = ADPONE_ENDPOINT + '?pid=' + bid.params.placementId; | ||
const data = { | ||
at: 1, | ||
id: bid.bidId, | ||
imp: bid.sizes.map((size, index) => ( | ||
{ | ||
id: bid.bidId + '_' + index, | ||
banner: { | ||
w: size[0], | ||
h: size[1] | ||
} | ||
})) | ||
}; | ||
|
||
return { method: ADPONE_REQUEST_METHOD, url, data } | ||
}); | ||
}, | ||
|
||
interpretResponse: (serverResponse, bidRequest) => { | ||
if (!serverResponse || !serverResponse.body) { | ||
return []; | ||
} | ||
|
||
let answer = []; | ||
|
||
serverResponse.body.seatbid.forEach(seatbid => { | ||
if (seatbid.bid.length) { | ||
answer = [...answer, ...seatbid.bid.filter(bid => bid.price > 0).map(bid => ({ | ||
id: bid.id, | ||
requestId: bidRequest.data.id, | ||
cpm: bid.price, | ||
ad: bid.adm, | ||
width: bid.w || 0, | ||
height: bid.h || 0, | ||
currency: serverResponse.body.cur || ADPONE_CURRENCY, | ||
netRevenue: true, | ||
ttl: 300, | ||
creativeId: bid.crid || 0 | ||
}))]; | ||
} | ||
}); | ||
|
||
return answer; | ||
} | ||
|
||
}; | ||
|
||
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,32 @@ | ||
# Overview | ||
|
||
Module Name: Adpone Bidder Adapter | ||
|
||
Module Type: Bidder Adapter | ||
|
||
Maintainer: tech@adpone.com | ||
|
||
# Description | ||
|
||
You can use this adapter to get a bid from adpone.com. | ||
|
||
About us : https://www.adpone.com | ||
|
||
|
||
# Test Parameters | ||
```javascript | ||
var adUnits = [ | ||
{ | ||
code: 'div-adpone-example', | ||
sizes: [[300, 250]], | ||
bids: [ | ||
{ | ||
bidder: "adpone", | ||
params: { | ||
placementId: "1234" | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
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
Oops, something went wrong.