Skip to content

Commit

Permalink
Add apacdex bid adapter & Merge valueimpression, quantumdex to apacdex (
Browse files Browse the repository at this point in the history
  • Loading branch information
thuyhq authored Nov 2, 2020
1 parent 1a76a46 commit ae1b4d7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
12 changes: 8 additions & 4 deletions modules/quantumdexBidAdapter.js → modules/apacdexBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'quantumdex';
const BIDDER_CODE = 'apacdex';
const CONFIG = {
'apacdex': {
'ENDPOINT': 'https://useast.quantumdex.io/auction/apacdex',
'USERSYNC': 'https://sync.quantumdex.io/usersync/apacdex'
},
'quantumdex': {
'ENDPOINT': 'https://useast.quantumdex.io/auction/quantumdex',
'USERSYNC': 'https://sync.quantumdex.io/usersync/quantumdex'
Expand All @@ -12,14 +16,14 @@ const CONFIG = {
}
};

var bidderConfig = CONFIG['quantumdex'];
var bidderConfig = CONFIG[BIDDER_CODE];
var bySlotTargetKey = {};
var bySlotSizesCount = {}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: ['banner', 'video'],
aliases: ['valueimpression'],
aliases: ['quantumdex', 'valueimpression'],
isBidRequestValid: function (bid) {
if (!bid.params) {
return false;
Expand All @@ -30,7 +34,7 @@ export const spec = {
if (!utils.deepAccess(bid, 'mediaTypes.banner') && !utils.deepAccess(bid, 'mediaTypes.video')) {
return false;
}
if (utils.deepAccess(bid, 'mediaTypes.banner')) { // Quantumdex does not support multi type bids, favor banner over video
if (utils.deepAccess(bid, 'mediaTypes.banner')) { // Not support multi type bids, favor banner over video
if (!utils.deepAccess(bid, 'mediaTypes.banner.sizes')) {
// sizes at the banner is required.
return false;
Expand Down
16 changes: 8 additions & 8 deletions modules/quantumdexBidAdapter.md → modules/apacdexBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Overview

```
Module Name: Quantum Digital Exchange Bidder Adapter
Module Name: APAC Digital Exchange Bidder Adapter
Module Type: Bidder Adapter
Maintainer: ken@quantumdex.io
Maintainer: ken@apacdex.com
```

# Description

Connects to Quantum Digital Exchange for bids.
Quantumdex bid adapter supports Banner and Video (Instream and Outstream) ads.
Connects to APAC Digital Exchange for bids.
Apacdex bid adapter supports Banner and Video (Instream and Outstream) ads.

# Test Parameters
```
Expand All @@ -23,9 +23,9 @@ var adUnits = [
},
bids: [
{
bidder: 'quantumdex',
bidder: 'apacdex',
params: {
siteId: 'quantumdex-site-id', // siteId provided by Quantumdex
siteId: 'apacdex1234', // siteId provided by Apacdex
}
}
]
Expand All @@ -46,9 +46,9 @@ var videoAdUnit = {
},
bids: [
{
bidder: 'quantumdex',
bidder: 'apacdex',
params: {
siteId: 'quantumdex-site-id', // siteId provided by Quantumdex
siteId: 'apacdex1234', // siteId provided by Apacdex
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect } from 'chai'
import { spec } from 'modules/quantumdexBidAdapter.js'
import { spec } from 'modules/apacdexBidAdapter.js'
import { newBidder } from 'src/adapters/bidderFactory.js'
import { userSync } from '../../../src/userSync.js';

describe('QuantumdexBidAdapter', function () {
describe('ApacdexBidAdapter', function () {
const adapter = newBidder(spec)

describe('.code', function () {
it('should return a bidder code of quantumdex', function () {
expect(spec.code).to.equal('quantumdex')
it('should return a bidder code of apacdex', function () {
expect(spec.code).to.equal('apacdex')
})
})

Expand All @@ -21,7 +21,7 @@ describe('QuantumdexBidAdapter', function () {
describe('.isBidRequestValid', function () {
it('should return false if there are no params', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
'mediaTypes': {
banner: {
Expand All @@ -37,7 +37,7 @@ describe('QuantumdexBidAdapter', function () {

it('should return false if there is no siteId param', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
site_id: '1a2b3c4d5e6f1a2b3c4d',
Expand All @@ -56,7 +56,7 @@ describe('QuantumdexBidAdapter', function () {

it('should return false if there is no mediaTypes', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d'
Expand All @@ -72,7 +72,7 @@ describe('QuantumdexBidAdapter', function () {

it('should return true if the bid is valid', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d'
Expand All @@ -92,7 +92,7 @@ describe('QuantumdexBidAdapter', function () {
describe('banner', () => {
it('should return false if there are no banner sizes', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d'
Expand All @@ -111,7 +111,7 @@ describe('QuantumdexBidAdapter', function () {

it('should return true if there is banner sizes', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d'
Expand All @@ -132,7 +132,7 @@ describe('QuantumdexBidAdapter', function () {
describe('video', () => {
it('should return false if there is no playerSize defined in the video mediaType', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d',
Expand All @@ -152,7 +152,7 @@ describe('QuantumdexBidAdapter', function () {

it('should return true if there is playerSize defined on the video mediaType', () => {
const bid = {
'bidder': 'quantumdex',
'bidder': 'apacdex',
'adUnitCode': 'adunit-code',
params: {
siteId: '1a2b3c4d5e6f1a2b3c4d',
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('QuantumdexBidAdapter', function () {
},
]
},
'bidder': 'quantumdex',
'bidder': 'apacdex',
'params': {
'siteId': '1a2b3c4d5e6f1a2b3c4d',
},
Expand All @@ -206,7 +206,7 @@ describe('QuantumdexBidAdapter', function () {
'bidId': '30b31c1838de1f',
},
{
'bidder': 'quantumdex',
'bidder': 'apacdex',
'params': {
'ad_unit': '/7780971/sparks_prebid_LB',
'sizes': [[300, 250], [300, 600]],
Expand Down Expand Up @@ -235,14 +235,14 @@ describe('QuantumdexBidAdapter', function () {

it('should return a properly formatted request', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex')
expect(bidRequests.method).to.equal('POST')
expect(bidRequests.bidderRequests).to.eql(bidRequest);
})

it('should return a properly formatted request with GDPR applies set to true', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex')
expect(bidRequests.method).to.equal('POST')
expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
Expand All @@ -251,7 +251,7 @@ describe('QuantumdexBidAdapter', function () {
it('should return a properly formatted request with GDPR applies set to false', function () {
bidderRequests.gdprConsent.gdprApplies = false;
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex')
expect(bidRequests.method).to.equal('POST')
expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
Expand All @@ -271,7 +271,7 @@ describe('QuantumdexBidAdapter', function () {
}
};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex')
expect(bidRequests.method).to.equal('POST')
expect(bidRequests.data.gdpr.gdprApplies).to.equal(false)
expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
Expand All @@ -291,7 +291,7 @@ describe('QuantumdexBidAdapter', function () {
}
};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/quantumdex')
expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex')
expect(bidRequests.method).to.equal('POST')
expect(bidRequests.data.gdpr.gdprApplies).to.equal(true)
expect(bidRequests.data.gdpr).to.not.include.keys('consentString')
Expand All @@ -309,7 +309,7 @@ describe('QuantumdexBidAdapter', function () {
describe('.interpretResponse', function () {
const bidRequests = {
'method': 'POST',
'url': 'https://useast.quantumdex.io/auction/quantumdex',
'url': 'https://useast.quantumdex.io/auction/apacdex',
'withCredentials': true,
'data': {
'device': {
Expand All @@ -328,7 +328,7 @@ describe('QuantumdexBidAdapter', function () {
},
'bidderRequests': [
{
'bidder': 'quantumdex',
'bidder': 'apacdex',
'params': {
'siteId': '343'
},
Expand Down Expand Up @@ -363,7 +363,7 @@ describe('QuantumdexBidAdapter', function () {
}
},
{
'bidder': 'quantumdex',
'bidder': 'apacdex',
'params': {
'siteId': '343'
},
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('QuantumdexBidAdapter', function () {
}
},
{
'bidder': 'quantumdex',
'bidder': 'apacdex',
'params': {
'siteId': '343'
},
Expand Down Expand Up @@ -464,38 +464,38 @@ describe('QuantumdexBidAdapter', function () {
'cpm': 1.07,
'width': 160,
'height': 600,
'ad': `<div>Quantumdex AD</div>`,
'ad': `<div>Apacdex AD</div>`,
'ttl': 500,
'creativeId': '1234abcd',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'banner'
},
{
'requestId': '30024615be22ef66a',
'cpm': 1,
'width': 300,
'height': 250,
'ad': `<div>Quantumdex AD</div>`,
'ad': `<div>Apacdex AD</div>`,
'ttl': 500,
'creativeId': '1234abcd',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'banner'
},
{
'requestId': '1854b40107d6745c',
'cpm': 1.25,
'width': 300,
'height': 250,
'vastXml': '<VAST><Ad id="20001"><InLine><AdSystem version="4.0">quantumdex</AdSystem></InLine></Ad></VAST>',
'vastXml': '<VAST><Ad id="20001"><InLine><AdSystem version="4.0">apacdex</AdSystem></InLine></Ad></VAST>',
'ttl': 500,
'creativeId': '30292e432662bd5f86d90774b944b038',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'video'
}
],
Expand All @@ -512,38 +512,38 @@ describe('QuantumdexBidAdapter', function () {
'cpm': 1.07,
'width': 160,
'height': 600,
'ad': `<div>Quantumdex AD</div>`,
'ad': `<div>Apacdex AD</div>`,
'ttl': 500,
'creativeId': '1234abcd',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'banner'
},
{
'requestId': '30024615be22ef66a',
'cpm': 1,
'width': 300,
'height': 250,
'ad': `<div>Quantumdex AD</div>`,
'ad': `<div>Apacdex AD</div>`,
'ttl': 500,
'creativeId': '1234abcd',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'banner'
},
{
'requestId': '1854b40107d6745c',
'cpm': 1.25,
'width': 300,
'height': 250,
'vastXml': '<VAST><Ad id="20001"><InLine><AdSystem version="4.0">quantumdex</AdSystem></InLine></Ad></VAST>',
'vastXml': '<VAST><Ad id="20001"><InLine><AdSystem version="4.0">apacdex</AdSystem></InLine></Ad></VAST>',
'ttl': 500,
'creativeId': '30292e432662bd5f86d90774b944b038',
'netRevenue': true,
'currency': 'USD',
'dealId': 'quantumdex',
'dealId': 'apacdex',
'mediaType': 'video'
}
];
Expand All @@ -561,10 +561,10 @@ describe('QuantumdexBidAdapter', function () {
expect(resp.currency).to.equal(prebidResponse[i].currency);
expect(resp.dealId).to.equal(prebidResponse[i].dealId);
if (resp.mediaType === 'video') {
expect(resp.vastXml.indexOf('quantumdex')).to.be.greaterThan(0);
expect(resp.vastXml.indexOf('apacdex')).to.be.greaterThan(0);
}
if (resp.mediaType === 'banner') {
expect(resp.ad.indexOf('Quantumdex AD')).to.be.greaterThan(0);
expect(resp.ad.indexOf('Apacdex AD')).to.be.greaterThan(0);
}
});
});
Expand Down

0 comments on commit ae1b4d7

Please sign in to comment.