Skip to content

Commit

Permalink
SilverMob adapter initial commit (prebid#10896)
Browse files Browse the repository at this point in the history
  • Loading branch information
freemmy authored and Kevin Siow committed Mar 1, 2024
1 parent eb56e38 commit a7925c5
Show file tree
Hide file tree
Showing 3 changed files with 447 additions and 0 deletions.
76 changes: 76 additions & 0 deletions modules/silvermobBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// import { logMessage } from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';

import {ortbConverter} from '../libraries/ortbConverter/converter.js'
import { config } from '../src/config.js';

const BIDDER_CODE = 'silvermob';
const AD_URL = 'https://{HOST}.silvermob.com/marketplace/api/dsp/prebidjs/{ZONEID}';
const GVLID = 1058;

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.ext = {
[BIDDER_CODE]: {
zoneid: bidRequest.params.zoneid,
host: bidRequest.params.host || 'us',
}
}
return imp;
},
request(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);
const bid = context.bidRequests[0];
request.test = config.getConfig('debug') ? 1 : 0;
if (!request.cur) request.cur = [bid.params.currency || 'USD'];
return request;
},
bidResponse(buildBidResponse, bid, context) {
const bidResponse = buildBidResponse(bid, context);
bidResponse.cur = bid.cur || 'USD';
return bidResponse;
}
});

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

isBidRequestValid: (bid) => {
return Boolean(bid.bidId && bid.params && !isNaN(bid.params.zoneid));
},

buildRequests: (validBidRequests, bidderRequest) => {
if (validBidRequests && validBidRequests.length === 0) return [];

const host = validBidRequests[0].params.host || 'us';
const zoneid = validBidRequests[0].params.zoneid;

const data = converter.toORTB({ bidRequests: validBidRequests, bidderRequest });

return {
method: 'POST',
url: AD_URL.replace('{HOST}', host).replace('{ZONEID}', zoneid),
data: data
};
},

interpretResponse: (response, request) => {
if (response?.body) {
const bids = converter.fromORTB({ response: response.body, request: request.data }).bids;
return bids;
}
return [];
}

};

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

```
Module Name: SilverMob Bidder Adapter
Module Type: Bidder Adapter
Maintainer: prebid@silvermob.com
```

# Description

Module that connects to SilverMob platform

# Test Parameters
```
var adUnits = [
// Will return static native ad. Assets are stored through user UI for each placement separetly
{
code: 'placementId_0',
mediaTypes: {
native: {}
},
bids: [
{
bidder: 'silvermob',
params: {
host: 'us',
zoneid: '0'
}
}
]
},
// Will return static test banner
{
code: 'placementId_0',
mediaTypes: {
banner: {
sizes: [[300, 250]],
}
},
bids: [
{
bidder: 'silvermob',
params: {
host: 'us',
zoneid: '0'
}
}
]
},
// Will return test vast xml. All video params are stored under placement in publishers UI
{
code: 'placementId_0',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [
{
bidder: 'silvermob',
params: {
host: 'us',
zoneid: '0'
}
}
]
}
];
```
Loading

0 comments on commit a7925c5

Please sign in to comment.