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

Add triplelift adapter #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ just-premium/
kargo/
rtk/
share-through/
triple-lift/
4 changes: 4 additions & 0 deletions triple-lift/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 2.1.2
- Added tmax support
- Added CCPA support
- Hardcoded HTTPS protocol for API endpoint
85 changes: 85 additions & 0 deletions triple-lift/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# TripleLift
## General Compatibility
|Feature| |
|---|---|
| Consent | yes |
| Native Ad Support | no |
| SafeFrame Support | no |
| PMP Support | yes |

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

## Adapter Information
| Info | |
|---|---|
| Partner Id | TripleLiftHtb |
| Ad Server Responds in (Cents, Dollars, etc) | cents |
| Bid Type (Gross / Net) | net |
| GAM Key (Open Market) | ix_tpl_cpm |
| GAM Key (Private Market) | ix_tpl_cpm |
| Ad Server URLs | https://tlx.3lift.com/header/auction |
| Slot Mapping Style (Size / Multiple Sizes / Slot) | slot |
| Request Architecture (MRA / SRA) | MRA |

## Currencies Supported

## Bid Request Information
### Parameters
| Key | Required | Type | Description |
|---|---|---|---|
| inv_code | true | string | supply inventory code |
| lib | true | string | supply source ("ix") |
| size | true | string | supply dimensions (e.g. "300x250") |
| referrer | true | string | document referrer URL |
| v | true | number | adapter version number |

### Example
```
HTTP GET https://tlx.3lift.com/header/auction?inv_code=DailyBeast_ROS_Desktop_728x90&lib=ix&fe=0&size=728x90&referrer=https%3A%2F%2Fwww.thedailybeast.com%2Fukrainian-plane-crash-in-iran-raises-issue-of-flaw-in-another-boeing-737-model%3Fref%3Dwrap&v=2.1
```

## Bid Response Information
### Bid Example
```javascript
{
"ad": "[HTML AD MARKUP]",
"cpm": 3.651,
"crid": "3335_18160_T4915441",
"height": 250,
"imp_id": "1",
"tl_source": "tlx",
"width": 300
}
```
### Pass Example
```javascript
{"status":"no_bid"}
```

## Configuration Information
### Configuration Keys
| Key | Required | Type | Description |
|---|---|---|---|
| inventoryCode | yes | string | placement identifier |
| sizes | yes | array | ad slot dimensions |
### Example
```javascript
{
"inventoryCode": "DailyBeast_ROS_Desktop_300x250",
"sizes": [[300, 250]]
}
```
9 changes: 9 additions & 0 deletions triple-lift/triple-lift-htb-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//? if(FEATURES.GPT_LINE_ITEMS) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the ix system uses all these?

shellInterface.TripleLiftHtb = {
render: SpaceCamp.services.RenderService.renderDfpAd.bind(null, 'TripleLiftHtb')
};

shellInterface.TPL = {
render: SpaceCamp.services.RenderService.renderDfpAd.bind(null, 'TripleLiftHtb')
};
//? }
121 changes: 121 additions & 0 deletions triple-lift/triple-lift-htb-system-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
'use strict';

function getPartnerId() {
return 'TripleLiftHtb';
}

function getStatsId() {
return 'TPL';
}

function getCallbackType() {
return 'NONE';
}

function getArchitecture() {
return 'MRA';
}

function getConfig() {
return {
xSlots: {
1: {
inventoryCode: 'test',
sizes: [[300, 250]]
}
}
};
}

function getBidRequestRegex() {
return {
method: 'GET',
urlRegex: /https:\/\/tlx\.3lift\.com\/header\/auction/
};
}

function validateBidRequest(request) {
var r = request.query;
expect(r.v).toBe('2.1.2');
expect(r.lib).toBe('ix');
expect(r.inv_code).toBe('test');
expect(r.size).toBe('300x250');
expect(r.cmp_cs).toBe('');
expect(r.gdpr).toBe('false');
expect(r.referrer).toBe(document.URL);
expect(r.tmax).toBe('100000');
}

function validateBidRequestWithPrivacy(request) {
var r = request.query;
expect(r.v).toBe('2.1.2');
expect(r.lib).toBe('ix');
expect(r.inv_code).toBe('test');
expect(r.size).toBe('300x250');
expect(r.gdpr).toBe('true');
expect(r.cmp_cs).toBe('TEST_GDPR_CONSENT_STRING');
expect(r.referrer).toBe(document.URL);
expect(r.tmax).toBe('100000');
}

function getValidResponse(request, creative) {
return JSON.stringify({
ad: creative,
cpm: 2.00,
crid: '3898_17463_747551',
width: 300,
height: 250,
imp_id: '1',
tl_source: 'hdx'
});
}

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

function getPassResponse() {
return JSON.stringify({
status: 'no_bid'
});
}

function getValidResponseWithDeal(request, creative) {
return JSON.stringify({
ad: creative,
cpm: 2.00,
crid: '3898_17463_747551',
width: 300,
height: 250,
imp_id: '1',
deal_id: 'TEST_DEAL_ID',
tl_source: 'hdx'
});
}

function validateTargetingWithDeal(targetingMap) {
expect(targetingMap).toEqual(jasmine.objectContaining({
ix_tpl_cpm: jasmine.arrayContaining(['300x250_200']),
ix_tpl_dealid: jasmine.arrayContaining(['TEST_DEAL_ID']),
ix_tpl_id: jasmine.arrayContaining([jasmine.any(String)])
}));
}

module.exports = {
getPartnerId: getPartnerId,
getStatsId: getStatsId,
getCallbackType: getCallbackType,
getArchitecture: getArchitecture,
getConfig: getConfig,
getBidRequestRegex: getBidRequestRegex,
validateBidRequest: validateBidRequest,
validateBidRequestWithPrivacy: validateBidRequestWithPrivacy,
getValidResponse: getValidResponse,
validateTargeting: validateTargeting,
getPassResponse: getPassResponse,
getValidResponseWithDeal: getValidResponseWithDeal,
validateTargetingWithDeal: validateTargetingWithDeal
};
78 changes: 78 additions & 0 deletions triple-lift/triple-lift-htb-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* @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 ////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

/* =============================================================================
* STEP 0 | Config Validation
* -----------------------------------------------------------------------------
* This file contains the necessary validation for the partner configuration.
* This validation will be performed on the partner specific configuration object
* that is passed into the wrapper. The wrapper uses an outside library called
* schema-insepctor to perform the validation. Information about it can be found here:
* https://atinux.fr/schema-inspector/.
*/

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

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

return null;
}

module.exports = partnerValidator;
Loading