forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SilverMob adapter initial commit (prebid#10896)
- Loading branch information
Showing
3 changed files
with
447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.