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

[HTP-0001] RichAudience Adapter: Initial pull request #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions rich-audience/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version 2.1.0 - 27/02/2020
=========================
- First version for Adapter Richaudience
132 changes: 132 additions & 0 deletions rich-audience/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# RichAudience
## General Compatibility
|Feature| |
|---|---|
| Consent | YES |
| Native Ad Support | YES |
| SafeFrame Support | YES |
| PMP Support | |

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

## Adapter Information
| Info | |
|---|---|
| Partner Id | RichAudienceHtb |
| Ad Server Responds in (Cents, Dollars, etc) | Dollars |
| Bid Type (Gross / Net) | Net |
| GAM Key (Open Market) | ix_ric_om |
| GAM Key (Private Market) | ix_ric_om |
| Ad Server URLs | https://shb.richaudience.com/hb/ |
| Slot Mapping Style (Size / Multiple Sizes / Slot) | Multiple Sizes |
| Request Architecture (MRA / SRA) | MRA |

## Currencies Supported

| |
|---|
| USD |


## Bid Request Information
### Parameters
| Key | Required | Type | Description |
|---|---|---|---|
| currencyCode | True | String | currency used |
| referer | True | String | get referer of the current page |
| adapter | False | String | Identify adapter IndexExchange |
| pid | True | String | The placement ID from Rich Audience |
| sizes | True | Array | contain two parameters that indicate width an height |
| supplyType | True | String | Define if site or app |
| tagId | True | String | name of AdUnit in the page |
| bidder | False | String | Identify bidder |
| bidId | False | String | partner ID |
| bidderRequestId | True | String | Request ID from the space |
| xSlotName | True | String | ID of Slot |
| gdprConsent | True | String | Contains GDPR consent |
| gdpr | True | Boolean | identifies if there is Consent |

### Example
```javascript
{
"currencyCode":["USD"],
"referer":"http%3A%2F%2Flocalhost%3A5837%2Fpublic%2Ftester%2Fsystem-tester.html",
"adapter":"IX",
"pid":"0wILSPtTKI",
"sizes":[{"w":728,"h":90}],
"supplyType":"site",
"tagId":"AdUnitLeaderBoardDibujos",
"bidder":"RichAudienceHtb",
"bidId":"RIC",
"bidderRequestId":"_8wybFc80",
"xSlotName":"1",
"gdprConsent":"",
"gdpr":false
}
```

## Bid Response Information
### Bid Example
```javascript
{
"requestId":"_JvfPjeOF",
"cpm":99,
"width":1,
"height":1,
"creative_id":83333345,
"netRevenue":true,
"ttl":300,
"dealId":"ramkt",
"media_type":"banner",
"adm":"<div id=\"default-creative\"></div>",
"type":"display",
"currency":"USD"
}
```
### Pass Example
```javascript
{}
```

## Configuration Information
### Configuration Keys
| Key | Required | Type | Description |
|---|---|---|---|
| adUnitName | True | String | name of AdUnit in the page |
| placementId | True | String | The placement ID from Rich Audience |
| supplyType | True | String | Define if site or app |
| sizes | True | Array | contain two parameters that indicate width an height |
### Example
```javascript
{
currencyCode: ['USD'],
xSlots: {
0: {
adUnitName: 'AdUnitMPUDibujos',
placementId: 'SIEUTMpbxj',
supplyType: 'site',
sizes: [[300, 250]]
},
1: {
adUnitName: 'AdUnitLeaderBoardDibujos',
placementId: '0wILSPtTKI',
supplyType: 'site',
sizes: [[728, 90]]
}
}
}
```
5 changes: 5 additions & 0 deletions rich-audience/rich-audience-htb-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//? if (FEATURES.GPT_LINE_ITEMS) {
shellInterface.RichAudienceHtb = {
render: SpaceCamp.services.RenderService.renderDfpAd.bind(null, 'RichAudienceHtb')
};
//? }
167 changes: 167 additions & 0 deletions rich-audience/rich-audience-htb-system-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
'use strict';

function getPartnerId() {
return 'RichAudienceHtb';
}

function getStatsId() {
return 'RIC';
}

function getCallbackType() {
return 'NONE';
}

function getArchitecture() {
return 'MRA';
}

function getConfig() {
return {
currencyCode: ['USD'],
xSlots: {
0: {
adUnitName: 'AdUnitMPUDibujos',
placementId: 'SIEUTMpbxj',
supplyType: 'site',
sizes: [[300, 250]]
},
1: {
adUnitName: 'AdUnitLeaderBoardDibujos',
placementId: '0wILSPtTKI',
supplyType: 'site',
sizes: [[728, 90]]
}
}
};
}

function getBidRequestRegex() {
return {
method: 'POST',
urlRegex: /shb\.richaudience\.com\/hb/
};
}

function validateBidRequest(request) {
var config = getConfig();
var data = JSON.parse(request.body);

expect(data.currencyCode).toBeDefined();
expect(data.currencyCode).toEqual(config.currencyCode);
expect(data.referer).toBeDefined();
expect(data.referer).toEqual(encodeURIComponent(document.location.href));
expect(data.sizes[0].w).toEqual(config.xSlots[1].sizes[0][0]);
expect(data.sizes[0].h).toEqual(config.xSlots[1].sizes[0][1]);
expect(data.supplyType).toBeDefined();
expect(data.supplyType).toEqual(config.xSlots[1].supplyType);
expect(data.tagId).toBeDefined();
expect(data.tagId).toEqual(config.xSlots[1].adUnitName);
expect(data.bidder).toBeDefined();
expect(data.bidder).toEqual(getPartnerId());
expect(data.bidId).toBeDefined();
expect(data.bidId).toEqual(getStatsId());
expect(data.gdprConsent).toEqual('');
expect(data.gdpr).toEqual(false);
}

function getValidResponse(request, creative) {
var data = JSON.parse(request.body);
var adm = creative || '<h1>Creative Test!</h2>';

// Creative RA adm = '<a target="_blank" href="http://richaudience.com"><img src="https://cdn3.richaudience.com/demo/728x90.jpeg" width="728" height="90"></a>'
var response = {
requestId: data.bidderRequestId,
cpm: 2,
width: data.sizes[0].w,
height: data.sizes[0].h,
creative_id: 83333345,
netRevenue: true,
ttl: 300,
dealId: null,
media_type: 'banner',
adm: adm,
type: 'display',
currency: data.currencyCode[0]
};

return JSON.stringify(response);
}

function validateTargeting(targetingMap) {
expect(targetingMap).toEqual({
ix_ric_om: ['728x90_200'],
ix_ric_id: [jasmine.any(String)]
});
}

function validateBidRequestWithPrivacy(request) {
var data = JSON.parse(request.body);

expect(data.gdprConsent).toEqual('TEST_GDPR_CONSENT_STRING');
expect(data.gdpr).toEqual(true);
}

function getValidResponseWithDeal(request, creative) {
var data = JSON.parse(request.body);
var response = {
requestId: data.bidderRequestId,
cpm: 99,
width: 1,
height: 1,
creative_id: 83333345,
netRevenue: true,
ttl: 300,
dealId: 'ramkt',
media_type: 'banner',
adm: creative,
type: 'display',
currency: 'USD'
};

return JSON.stringify(response);
}

function validateTargetingWithDeal(targetingMap) {
expect(targetingMap).toEqual({
ix_ric_dealid: ['1x1_ramkt'],
ix_ric_om: ['1x1_5000'],
ix_ric_id: [jasmine.any(String)]
});
}

function getPassResponse(request) {
var data = JSON.parse(request.body);
var response = {
requestId: data.bidderRequestId,
cpm: 0,
width: data.sizes[0].w,
height: data.sizes[0].h,
creative_id: 83333345,
netRevenue: true,
ttl: 300,
dealId: '',
media_type: 'banner',
adm: '',
type: 'display',
currency: data.currencyCode[0]
};

return JSON.stringify(response);
}

module.exports = {
getPartnerId: getPartnerId,
getCallbackType: getCallbackType,
getStatsId: getStatsId,
getArchitecture: getArchitecture,
getConfig: getConfig,
getBidRequestRegex: getBidRequestRegex,
validateBidRequest: validateBidRequest,
getValidResponse: getValidResponse,
validateTargeting: validateTargeting,
validateBidRequestWithPrivacy: validateBidRequestWithPrivacy,
getValidResponseWithDeal: getValidResponseWithDeal,
validateTargetingWithDeal: validateTargetingWithDeal,
getPassResponse: getPassResponse
};
76 changes: 76 additions & 0 deletions rich-audience/rich-audience-htb-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
'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: {
currencyCode: {
type: 'array',
items: {
type: 'string',
minLength: 3
}
},
xSlots: {
type: 'object',
properties: {
'*': {
type: 'object',
properties: {
adUnitName: {
type: 'string'
},
placementId: {
type: 'string',
minLength: 1
},
supplyType: {
type: 'string',
minLength: 3
},
sizes: {
type: 'array',
minLength: 1,
items: {
type: 'array'
}
}
}
}
}
},
mapping: {
'*': {
type: 'array'
}
}
}
}, configs);

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

return null;
}

module.exports = partnerValidator;
Loading