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

BLIINK Bid Adapter : Add new format, outstream, banner #7529

Merged
merged 24 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 16 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
84 changes: 53 additions & 31 deletions modules/bliinkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export const META_KEYWORDS = 'keywords'
export const META_DESCRIPTION = 'description'

const VIDEO = 'video'
const NATIVE = 'native'
const BANNER = 'banner'

const supportedMediaTypes = [BANNER, VIDEO, NATIVE]
const supportedMediaTypes = [BANNER, VIDEO]
const aliasBidderCode = ['bk']

export function getMetaList(name) {
Expand Down Expand Up @@ -104,19 +103,19 @@ export const parseXML = (content) => {
/**
* @param bidRequest
* @param bliinkCreative
* @return {{cpm, netRevenue: boolean, ad: string, requestId, width: number, currency: string, mediaType: string, vastXml, ttl: number, height: number}|null}
* @return {{cpm, netRevenue: boolean, requestId, width: (*|number), currency, ttl: number, creativeId, height: (*|number)} & {mediaType: string, vastXml}}
*/
export const buildBid = (bidRequest, bliinkCreative) => {
if (!bidRequest && !bliinkCreative) return null

const body = {
requestId: bidRequest.bidId,
currency: bliinkCreative.currency,
cpm: bliinkCreative.price,
creativeId: bliinkCreative.creativeId,
currency: 'EUR',
width: (bidRequest.sizes && bidRequest.sizes[0][0]) || 1,
height: (bidRequest.sizes && bidRequest.sizes[0][1]) || 1,
netRevenue: false,
width: 1,
height: 1,
ttl: 3600,
}

Expand All @@ -131,14 +130,20 @@ export const buildBid = (bidRequest, bliinkCreative) => {

delete bidRequest['bids']

return Object.assign(body, {
currency: bliinkCreative.currency,
width: 1,
height: 1,
mediaType: VIDEO,
ad: '<html lang="en"></html>',
vastXml: bliinkCreative.content,
})
switch (bliinkCreative.media_type) {
case VIDEO:
return Object.assign(body, {
mediaType: VIDEO,
vastXml: bliinkCreative.content,
})
case BANNER:
return Object.assign(body, {
mediaType: BANNER,
ad: (bliinkCreative && bliinkCreative.content && bliinkCreative.content.creative && bliinkCreative.content.creative.adm) || '',
})
default:
break;
}
}

/**
Expand Down Expand Up @@ -209,7 +214,7 @@ export const buildRequests = (_, bidderRequest) => {
* @return
*/
const interpretResponse = (serverResponse, request) => {
if ((serverResponse && serverResponse.mode === 'no-ad') && (!request.params)) {
if ((serverResponse && serverResponse.mode === 'no-ad')) {
return []
}

Expand All @@ -218,23 +223,40 @@ const interpretResponse = (serverResponse, request) => {

const xml = parseXML(body)

if (xml) {
const price = xml.getElementsByTagName('Price') && xml.getElementsByTagName('Price')[0]
const currency = xml.getElementsByTagName('Currency') && xml.getElementsByTagName('Currency')[0]
const creativeId = xml.getElementsByTagName('CreativeId') && xml.getElementsByTagName('CreativeId')[0]

const creative = {
content: body,
price: (price && price.textContent) || 0,
currency: (currency && currency.textContent) || 'EUR',
creativeId: creativeId || 0,
media_type: 'video',
}

return buildBid(serverBody.bids[0], creative);
let creative;

switch (serverBody.bids[0].params.placement) {
case xml && VIDEO:
aleksatr marked this conversation as resolved.
Show resolved Hide resolved
const price = xml.getElementsByTagName('Price') && xml.getElementsByTagName('Price')[0]
const currency = xml.getElementsByTagName('Currency') && xml.getElementsByTagName('Currency')[0]
const creativeId = xml.getElementsByTagName('CreativeId') && xml.getElementsByTagName('CreativeId')[0]

creative = {
content: body,
price: (price && price.textContent) || 0,
currency: (currency && currency.textContent) || 'EUR',
creativeId: creativeId || 0,
media_type: 'video',
}

return buildBid(serverBody.bids[0], creative)
case BANNER:
if (body) {
creative = {
content: body,
price: body.price,
currency: body.currency,
creativeId: 0,
media_type: 'banner',
}

return buildBid(serverBody.bids[0], creative)
}

break
default:
break
}

return []
}

/**
Expand Down
35 changes: 29 additions & 6 deletions modules/bliinkBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const adUnits = [
bidder: 'bliink',
params: {
placement: 'banner',
tagId: '14f30eca-85d2-11e8-9eed-0242ac120007'
tagId: '41'
}
}
]
Expand All @@ -50,11 +50,34 @@ const adUnits = [
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480],
mimes: ['video/mp4'],
protocols: [1, 2, 3, 4, 5, 6, 7, 8],
playbackmethod: [2],
skip: 1
playerSize: [[640,480]],
}
},
bids: [
{
bidder: 'bliink',
params: {
tagId: '41',
placement: 'video',
}
}
]
}
]
```

## Sample outstream Video Ad Unit

```js
const adUnits = [
{
code: '/19968336/prebid_cache_video_adunit',
sizes: [[640,480]],
mediaType: 'video',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [[640,480]],
}
},
bids: [
Expand Down
Loading