Skip to content

Commit

Permalink
Merge pull request prebid#15 from pm-harshad-mane/native_refactor
Browse files Browse the repository at this point in the history
Native refactor
  • Loading branch information
pm-manasi-moghe authored Mar 26, 2019
2 parents 7da2a32 + 9b75199 commit ec67b85
Show file tree
Hide file tree
Showing 25 changed files with 1,436 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
}
},
bids: [{
bidder: 'adikteev',
params: {
placementId: 13144370,
stagingEnvironment: true,
bidFloorPrice: 0.1,
}
bidder: 'emoteev',
params: {
adSpaceId: 5084,
}
}]
}];

Expand Down
8 changes: 3 additions & 5 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,10 @@
height: '250',
}
},
{
bidder: 'adikteev',
{
bidder: 'emoteev',
params: {
placementId: 12345,
currency: 'EUR',
bidFloorPrice: 0.1,
adSpaceId: 5084,
}
},
]
Expand Down
94 changes: 0 additions & 94 deletions modules/adikteevBidAdapter.js

This file was deleted.

79 changes: 79 additions & 0 deletions modules/admanBidAdapter.js
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);
35 changes: 35 additions & 0 deletions modules/admanBidAdapter.md
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
}
}]
}];
```

66 changes: 66 additions & 0 deletions modules/adponeBidAdapter.js
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);
32 changes: 32 additions & 0 deletions modules/adponeBidAdapter.md
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"
}
}
]
}
];
```
13 changes: 6 additions & 7 deletions modules/adikteevBidAdapter.md → modules/emokteevBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Overview

```
Module Name: Adikteev Bidder Adapter
Module Name: Emoteev Bidder Adapter
Module Type: Bidder Adapter
Maintainer: adnetwork@adikteev.com
Maintainer: engineering@emoteev.io
```

# Description

Module that connects to Adikteev's demand sources
Module that connects to Emoteev's demand sources

# Test Parameters

Expand All @@ -18,15 +18,14 @@ Module that connects to Adikteev's demand sources
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[750, 200]], // a display size
sizes: [[300, 250]],
}
},
bids: [
{
bidder: 'adikteev',
bidder: 'emoteev',
params: {
placementId: 12345,
bidFloorPrice: 0.1,
adSpaceId: 5084
}
}
]
Expand Down
Loading

0 comments on commit ec67b85

Please sign in to comment.