8000 Adpone Bid Adapter by seergiioo6 · Pull Request #3663 · prebid/Prebid.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adpone Bid Adapter # 8000 3663

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

Merged
merged 1 commit into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
]
}
];
```
102 changes: 102 additions & 0 deletions test/spec/modules/adponeBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { expect } from 'chai';
import { spec } from 'modules/adponeBidAdapter';

describe('adponeBidAdapter', function () {
let bid = {
bidder: 'adpone',
adUnitCode: 'adunit-code',
sizes: [[300, 250]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
params: {
placementId: '1',
}
};

describe('isBidRequestValid', function () {
it('should return true when necessary information is found', function () {
expect(spec.isBidRequestValid(bid)).to.be.true;
});

it('should return false when necessary information is not found', function () {
// empty bid
expect(spec.isBidRequestValid({bidId: '', params: {}})).to.be.false;

// empty bidId
bid.bidId = '';
expect(spec.isBidRequestValid(bid)).to.be.false;

// empty placementId
bid.bidId = '30b31c1838de1e';
bid.params.placementId = '';
expect(spec.isBidRequestValid(bid)).to.be.false;

bid.adUnitCode = 'adunit-code';
});
});
});

describe('interpretResponse', function () {
let serverResponse;
let bidRequest = { data: {id: '1234'} };

beforeEach(function () {
serverResponse = {
body: {
id: '2579e20c0bb89',
seatbid: [
{
bid: [
{
id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D',
impid: '2579e20c0bb89_0',
price: 1,
adm: '<html><a href="http://www.adpone.com" target="_blank"><img src ="https://placehold.it/300x250" /></a></html>',
adomain: [
'www.addomain.com'
],
iurl: 'http://localhost11',
crid: 'creative111',
h: 250,
w: 300,
ext: {
dspid: 6
}
}
],
seat: 'adpone'
}
],
cur: 'USD'
},
};
});

it('should correctly reorder the server response', function () {
const newResponse = spec.interpretResponse(serverResponse, bidRequest);
expect(newResponse.length).to.be.equal(1);
expect(newResponse[0]).to.deep.equal({
id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D',
requestId: '1234',
cpm: 1,
width: 300,
height: 250,
creativeId: 'creative111',
currency: 'USD',
netRevenue: true,
ttl: 300,
ad: '<html><a href="http://www.adpone.com" target="_blank"><img src ="https://placehold.it/300x250" /></a></html>'
});
});

it('should not add responses if the cpm is 0 or null', function () {
serverResponse.body.seatbid[0].bid[0].price = 0;
let response = spec.interpretResponse(serverResponse, bidRequest);
expect(response).to.deep.equal([]);

serverResponse.body.seatbid[0].bid[0].price = null;
response = spec.interpretResponse(serverResponse, bidRequest);
expect(response).to.deep.equal([])
});
});
0