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

kimberliteBidAdapter: video media type support #11981

Merged
merged 11 commits into from
Jul 17, 2024
31 changes: 24 additions & 7 deletions modules/kimberliteBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js'
import { deepSetValue } from '../src/utils.js';
import {ORTB_MTYPES} from '../libraries/ortbConverter/processors/mediaType.js';

const VERSION = '1.0.0';
const VERSION = '1.1.0';

const BIDDER_CODE = 'kimberlite';
const METHOD = 'POST';
const ENDPOINT_URL = 'https://kimberlite.io/rtb/bid/pbjs';
export const ENDPOINT_URL = 'https://kimberlite.io/rtb/bid/pbjs';

const VERSION_INFO = {
ver: '$prebid.version$',
Expand All @@ -16,7 +17,6 @@ const VERSION_INFO = {

const converter = ortbConverter({
context: {
mediaType: BANNER,
netRevenue: true,
ttl: 300
},
Expand All @@ -35,18 +35,32 @@ const converter = ortbConverter({
const imp = buildImp(bidRequest, context);
imp.tagid = bidRequest.params.placementId;
return imp;
}
},

bidResponse: function (buildBidResponse, bid, context) {
if (!bid.price) return;

const [type] = Object.keys(context.bidRequest.mediaTypes);
if (Object.values(ORTB_MTYPES).includes(type)) {
context.mediaType = type;
}

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

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

isBidRequestValid: (bidRequest = {}) => {
const { params, mediaTypes } = bidRequest;
let isValid = Boolean(params && params.placementId);
if (mediaTypes && mediaTypes[BANNER]) {
isValid = isValid && Boolean(mediaTypes[BANNER].sizes);
} else if (mediaTypes && mediaTypes[VIDEO]) {
isValid = isValid && Boolean(mediaTypes[VIDEO].mimes);
} else {
isValid = false;
}
Expand All @@ -58,7 +72,10 @@ export const spec = {
return {
method: METHOD,
url: ENDPOINT_URL,
data: converter.toORTB({ bidderRequest, bidRequests })
data: converter.toORTB({
bidRequests,
bidderRequest
})
}
},

Expand Down
31 changes: 30 additions & 1 deletion modules/kimberliteBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var adUnits = [
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[320, 250], [640, 480]],
sizes: [[320, 250], [640, 480]], // Required.
}
},
bids: [
Expand All @@ -34,3 +34,32 @@ var adUnits = [
}
]
```

## Video AdUnit

```javascript
var adUnits = [
{
code: 'test-div',
mediaTypes: {
video: {
// ORTB 2.5 options.
mimes: ['video/mp4'], // Required.
// Other options are optional.
placement: 1,
protocols: [3, 6],
linearity: 1,
startdelay: 0
}
},
bids: [
{
bidder: "kimberlite",
params: {
placementId: 'testVideo'
}
}
]
}
]
```
Loading