Skip to content

Commit

Permalink
add app-nexus-network adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker committed May 8, 2019
1 parent d1015b1 commit 2ae153b
Show file tree
Hide file tree
Showing 6 changed files with 728 additions and 0 deletions.
Empty file added app-nexus-network/CHANGES.md
Empty file.
69 changes: 69 additions & 0 deletions app-nexus-network/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# AppNexusNetwork
## General Compatibility
|Feature| |
|---|---|
| Consent | Yes |
| Native Ad Support | |
| SafeFrame Support | |
| PMP Support | |

## Browser Compatibility
| Browser | |
|--- |---|
| Chrome | |
| Edge | |
| Firefox | |
| Internet Explorer 9 | |
| Internet Explorer 10 | |
| Internet Explorer 11 | |
| Safari | |
| Mobile Chrome | |
| Mobile Safari | |
| UC Browser | |
| Samsung Internet | |
| Opera | |

## Adapter Information
| Info | |
|---|---|
| Partner Id | AppNexusNetworkHtb |
| Ad Server Responds in (Cents, Dollars, etc) | hundreth of a cent |
| Bid Type (Gross / Net) | Net |
| GAM Key (Open Market) | ix_apnx2_om |
| GAM Key (Private Market) | ix_apnxnet_pm |
| Ad Server URLs | secure.adnxs.com/jpt |
| Slot Mapping Style (Size / Multiple Sizes / Slot) | |
| Request Architecture (MRA / SRA) | MRA |

## Currencies Supported

## Bid Request Information
### Parameters
| Key | Required | Type | Description |
|---|---|---|---|
| | | | |

### Example
```javascript

```

## Bid Response Information
### Bid Example
```javascript

```
### Pass Example
```javascript

```

## Configuration Information
### Configuration Keys
| Key | Required | Type | Description |
|---|---|---|---|
| | | | |
### Example
```javascript

```
22 changes: 22 additions & 0 deletions app-nexus-network/app-nexus-network-htb-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* This file contains any necessary functions that need to be exposed to the outside world.
* Things like (render functions) will be exposed by adding them to the shellInterface variable, under the partners
* profile name. This function will then be accessible through the window.headertag.AppNexusNetworkHtb object.
* If necessary for backwards compatibility with old creatives, you can also add things directly to the
* window namespace here, but this is discouraged if it's not strictly needed.
*/

//? if(FEATURES.GPT_LINE_ITEMS) {
shellInterface.AppNexusNetworkHtb = {
render: SpaceCamp.services.RenderService.renderDfpAd.bind(null, 'AppNexusNetworkHtb')
};

/* Existing creatives use window.pbjs.renderApnxAd */
window.pbjs = window.pbjs || {};
window.pbjs.renderApnxAd = SpaceCamp.services.RenderService.renderDfpAd.bind(null, 'AppNexusNetworkHtb');
//? }

if (__directInterface.Layers.PartnersLayer.Partners.AppNexusNetworkHtb) {
shellInterface.AppNexusNetworkHtb = shellInterface.AppNexusNetworkHtb || {};
shellInterface.AppNexusNetworkHtb.adResponseCallback = __directInterface.Layers.PartnersLayer.Partners.AppNexusNetworkHtb.adResponseCallback;
}
112 changes: 112 additions & 0 deletions app-nexus-network/app-nexus-network-htb-system-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
'use strict';

function getPartnerId() {
return 'AppNexusNetworkHtb';
}

function getStatsId() {
return 'APNXNET';
}

function getCallbackType() {
return 'ID';
}

function getArchitecture() {
return 'SRA';
}

function getBidRequestRegex() {
return {
method: 'GET',
urlRegex: /.*secure\.adnxs\.com\/jpt*/
};
}

function getConfig() {
return {
xSlots: {
1: {
placementId: "15894224",
sizes: [[300, 250]]
},
2: {
placementId: "15901268",
sizes: [[300,250], [300, 600]]
}
},
mapping: {
"Fake Unit 1 300x250": ["1"],
"Fake Unit 2 300x250 or 300x600": ["2"]
}
};
}

function validateBidRequest(request) {
var q = request.query;
expect(q.id).toBeDefined();
expect(q.size).toBeDefined();
expect(q.psa).toBeDefined();
expect(q.callback).toBeDefined();
expect(q.callback_uid).toBeDefined();
expect(q.gdpr).toBeDefined();
expect(q.gdpr_consent).toBeDefined();
expect(q.referrer).toBeDefined();
}

function getValidResponse(request, creative) {
var q = request.query;
var adm = creative;
// console.log(adm);

var response = {
result: {
cpm: 20000,
width: 300,
height: 250,
creative_id: 100232340,
media_type_id: 1,
media_subtype_id: 1,
ad: adm,
is_bin_price_applicable: false
},
callback_uid: q.callback_uid
};
var jsonResponse = JSON.stringify(response);
// console.log(jsonResponse);
return 'headertag.AppNexusNetworkHtb.adResponseCallback(' + jsonResponse + ')';
}

function validateTargeting(targetingMap) {
expect(targetingMap).toEqual(jasmine.objectContaining({
ix_apnxnet_om: jasmine.arrayContaining(['300x250_200']),
ix_apnxnet_id: jasmine.arrayContaining([jasmine.any(String)])
}));
}

function getPassResponse(request) {
var q = request.query;

var response = {
result: {
cpm: 0.0,
ad: ""
},
callback_uid: q.callback_uid
}
return 'headertag.AppNexusNetworkHtb.adResponseCallback('+ JSON.stringify(response) +');';
}


module.exports = {
getPartnerId: getPartnerId,
getStatsId: getStatsId,
getCallbackType: getCallbackType,
getArchitecture: getArchitecture,
getConfig: getConfig,
getBidRequestRegex: getBidRequestRegex,
validateBidRequest: validateBidRequest,
getValidResponse: getValidResponse,
getPassResponse: getPassResponse,
validateTargeting: validateTargeting,
};
80 changes: 80 additions & 0 deletions app-nexus-network/app-nexus-network-htb-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @author: Partner
* @license: UNLICENSED
*
* @copyright: Copyright (c) 2017 by Index Exchange. All rights reserved.
*
* The information contained within this document is confidential, copyrighted
* and or a trade secret. No part of this document may be reproduced or
* distributed in any form or by any means, in whole or in part, without the
* prior written permission of Index Exchange.
*/

'use strict';

////////////////////////////////////////////////////////////////////////////////
// Dependencies ////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

var Inspector = require('../../../libs/external/schema-inspector.js');

////////////////////////////////////////////////////////////////////////////////
// Main ////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

var partnerValidator = function (configs) {
var result = Inspector.validate({
type: 'object',
properties: {
xSlots: {
type: 'object',
properties: {
'*': {
type: 'object',
properties: {
placementId: {
type: 'string',
minLength: 1
},
sizes: {
type: 'array',
minLength: 1,
items: {
type: 'array',
exactLength: 2,
items: {
type: 'integer'
}
}
},
keywords: {
type: 'object',
optional: true,
properties: {
'*': {
type: 'array',
minLength: 1,
items: {
type: 'string'
}
}
}
}
}
}
}
},
mapping: {
type: 'object'
}
}
}, configs);

if (!result.valid) {
return result.format();
}

return null;
};

module.exports = partnerValidator;
Loading

0 comments on commit 2ae153b

Please sign in to comment.