Skip to content
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

ImproveDigitalBidAdapter - Added support for ad server currency #2001

Merged
merged 1 commit into from
Jan 31, 2018
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
12 changes: 10 additions & 2 deletions modules/improvedigitalBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import { config } from 'src/config';
import { userSync } from 'src/userSync';

const BIDDER_CODE = 'improvedigital';

export const spec = {
version: '4.0.0',
version: '4.1.0',
code: BIDDER_CODE,
aliases: ['id'],

Expand Down Expand Up @@ -113,6 +114,7 @@ function getNormalizedBidRequest(bid) {
let localSize = utils.getBidIdParameter('size', bid.params) || null;
let bidId = utils.getBidIdParameter('bidId', bid);
let transactionId = utils.getBidIdParameter('transactionId', bid);
const currency = config.getConfig('currency.adServerCurrency');

let normalizedBidRequest = {};
if (placementId) {
Expand Down Expand Up @@ -143,6 +145,9 @@ function getNormalizedBidRequest(bid) {
if (transactionId) {
normalizedBidRequest.transactionId = transactionId;
}
if (currency) {
normalizedBidRequest.currency = currency;
}
return normalizedBidRequest;
}
registerBidder(spec);
Expand All @@ -160,7 +165,7 @@ function ImproveDigitalAdServerJSClient(endPoint) {
AD_SERVER_BASE_URL: 'ad.360yield.com',
END_POINT: endPoint || 'hb',
AD_SERVER_URL_PARAM: 'jsonp=',
CLIENT_VERSION: 'JS-4.2.0',
CLIENT_VERSION: 'JS-4.3.3',
MAX_URL_LENGTH: 2083,
ERROR_CODES: {
BAD_HTTP_REQUEST_TYPE_PARAM: 1,
Expand Down Expand Up @@ -337,6 +342,9 @@ function ImproveDigitalAdServerJSClient(endPoint) {
if (placementObject.adUnitId) {
outputObject.adUnitId = placementObject.adUnitId;
}
if (placementObject.currency) {
impressionObject.currency = placementObject.currency.toUpperCase();
}
if (placementObject.placementId) {
impressionObject.pid = placementObject.placementId;
}
Expand Down
3 changes: 3 additions & 0 deletions modules/improvedigitalBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Module that connects to Improve Digital's demand sources
```
var adUnits = [{
code: 'div-gpt-ad-1499748733608-0',
sizes: [[600, 290]],
bids: [
{
bidder: 'improvedigital',
Expand All @@ -22,6 +23,7 @@ Module that connects to Improve Digital's demand sources
]
}, {
code: 'div-gpt-ad-1499748833901-0',
sizes: [[250, 250]],
bids: [{
bidder: 'improvedigital',
params: {
Expand All @@ -33,6 +35,7 @@ Module that connects to Improve Digital's demand sources
}]
}, {
code: 'div-gpt-ad-1499748913322-0',
sizes: [[300, 300]],
bids: [{
bidder: 'improvedigital',
params: {
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { ImproveDigitalAdServerJSClient, spec } from 'modules/improvedigitalBidAdapter';
import { config } from 'src/config';
import { userSync } from 'src/userSync';

describe('Improve Digital Adapter Tests', function () {
Expand Down Expand Up @@ -129,6 +130,15 @@ describe('Improve Digital Adapter Tests', function () {
expect(params.bid_request.imp[0].banner).to.deep.equal(size);
});

it('should add currency', () => {
const bidRequest = Object.assign({}, simpleBidRequest);
const getConfigStub = sinon.stub(config, 'getConfig').returns('JPY');
const request = spec.buildRequests([bidRequest])[0];
const params = JSON.parse(request.data.substring(PARAM_PREFIX.length));
expect(params.bid_request.imp[0].currency).to.equal('JPY');
getConfigStub.restore();
});

it('should return 2 requests', () => {
const requests = spec.buildRequests([
simpleBidRequest,
Expand Down