Skip to content

Commit

Permalink
kimberliteBidAdapter: video media type support (#11981)
Browse files Browse the repository at this point in the history
* Kimberlite bid adapter (#1)

* initial: bid adapter

* styling

* Fix: lint (#2)

* Fix: lint (#4)

* review fixes (#6)

* Change: filling request.ext.prebid section (#7)

* Video support

* Fix: tests

* Adapter's version update

* No video defaults
  • Loading branch information
os-solta authored Jul 17, 2024
1 parent cdd3b5a commit 40b906d
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 73 deletions.
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

0 comments on commit 40b906d

Please sign in to comment.