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

A1Media Bid Adapter : initial release #10424

Merged
merged 1 commit into from
Sep 18, 2023
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
89 changes: 89 additions & 0 deletions modules/a1MediaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';

const BIDDER_CODE = 'a1media';
const END_POINT = 'https://d11.contentsfeed.com/dsp/breq/a1';
const DEFAULT_CURRENCY = 'JPY';

const converter = ortbConverter({
context: {
netRevenue: true,
ttl: 30,
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
if (!imp.bidfloor) {
imp.bidfloor = bidRequest.params.bidfloor || 0;
imp.bidfloorcur = bidRequest.params.currency || DEFAULT_CURRENCY;
}
if (bidRequest.params.battr) {
Object.keys(bidRequest.mediaTypes).forEach(mType => {
imp[mType].battr = bidRequest.params.battr;
})
}
return imp;
},
request(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);
const bid = context.bidRequests[0];
if (!request.cur) {
request.cur = [bid.params.currency || DEFAULT_CURRENCY];
}
if (bid.params.bcat) {
request.bcat = bid.params.bcat;
}
return request;
},
bidResponse(buildBidResponse, bid, context) {
const { bidRequest } = context;

let resMediaType;
const reqMediaTypes = Object.keys(bidRequest.mediaTypes);
if (reqMediaTypes.length === 1) {
resMediaType = reqMediaTypes[0];
} else {
if (bid.adm.search(/^(<\?xml|<vast)/i) !== -1) {
resMediaType = VIDEO;
} else if (bid.adm[0] === '{') {
resMediaType = NATIVE;
} else {
resMediaType = BANNER;
}
}

context.mediaType = resMediaType;
context.cpm = bid.price;

const bidResponse = buildBidResponse(bid, context);
return bidResponse;
}
});

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

isBidRequestValid: function (bid) {
return true;
},

buildRequests: function (validBidRequests, bidderRequest) {
const data = converter.toORTB({ validBidRequests, bidderRequest });
return {
method: 'POST',
url: END_POINT,
data: data,
options: {
withCredentials: false,
}
};
},

interpretResponse: function (serverResponse, bidRequest) {
const bids = converter.fromORTB({response: serverResponse.body, request: bidRequest.data}).bids;
return bids;
},

};
registerBidder(spec);
93 changes: 93 additions & 0 deletions modules/a1MediaBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Overview

```markdown
Module Name: A1Media Bid Adapter
Module Type: Bidder Adapter
Maintainer: dev@a1mediagroup.co.kr
```

# Description

Connects to A1Media exchange for bids.

# Test Parameters

## Sample Banner Ad Unit

```javascript
var adUnits = [
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[320, 100]],
}
},
bids: [
{
bidder: "a1media",
params: {
bidfloor: 0.9, //optional
currency: 'JPY' //optional
battr: [ 13 ], //optional
bcat: ['IAB1-1'] //optional
}
}
]
}
]
```

## Sample Video Ad Unit

```javascript
var adUnits = [
{
code: 'test-div',
mediaTypes: {
video: {
mimes: ['video/mp4'],
}
},
bids: [
{
bidder: "a1media",
params: {
bidfloor: 0.9, //optional
currency: 'JPY' //optional
battr: [ 13 ], //optional
bcat: ['IAB1-1'] //optional
}
}
]
}
]
```

## Sample Native Ad Unit

```javascript
var adUnits = [
{
code: 'test-div',
mediaTypes: {
native: {
title: {
len: 140
},
}
},
bids: [
{
bidder: "a1media",
params: {
bidfloor: 0.9, //optional
currency: 'JPY' //optional
battr: [ 13 ], //optional
bcat: ['IAB1-1'] //optional
}
}
]
}
]
```
Loading