-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add New Adapter dgadsBidAdapter (#2429)
* Add dgads adapter * Add dgads adapter * Add spec file for dgads * Add spec file for dgads * Add dgads bid adapter * Add dgads bid adapter * fix * fix * fix email * remove semi-colon * Add mediaType native * Add import medaTypes
- Loading branch information
1 parent
204daae
commit 372899b
Showing
3 changed files
with
444 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,88 @@ | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
import * as utils from 'src/utils'; | ||
import { BANNER, NATIVE } from 'src/mediaTypes'; | ||
|
||
const BIDDER_CODE = 'dgads'; | ||
const ENDPOINT = 'https://ads-tr.bigmining.com/ad/p/bid'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [ BANNER, NATIVE ], | ||
isBidRequestValid: function(bid) { | ||
const params = bid.params; | ||
if (!/^\d+$/.test(params.location_id)) { | ||
return false; | ||
} | ||
if (!/^\d+$/.test(params.site_id)) { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
buildRequests: function(bidRequests) { | ||
if (bidRequests.length === 0) { | ||
return {}; | ||
} | ||
|
||
return bidRequests.map(bidRequest => { | ||
const params = bidRequest.params; | ||
const data = {}; | ||
|
||
data['location_id'] = params.location_id; | ||
data['site_id'] = params.site_id; | ||
data['transaction_id'] = bidRequest.transactionId; | ||
data['bid_id'] = bidRequest.bidId; | ||
|
||
return { | ||
method: 'POST', | ||
url: ENDPOINT, | ||
data, | ||
}; | ||
}); | ||
}, | ||
interpretResponse: function(serverResponse, bidRequest) { | ||
const bidResponses = []; | ||
const responseObj = serverResponse.body; | ||
const ads = responseObj.bids; | ||
let bidResponse = {}; | ||
if (utils.isEmpty(ads)) { | ||
return []; | ||
} | ||
utils._each(ads, function(ad) { | ||
bidResponse.requestId = ad.bidId; | ||
bidResponse.bidderCode = BIDDER_CODE; | ||
bidResponse.cpm = ad.cpm; | ||
bidResponse.creativeId = ad.creativeId; | ||
bidResponse.currency = 'JPY'; | ||
bidResponse.netRevenue = true; | ||
bidResponse.ttl = ad.ttl; | ||
bidResponse.referrer = utils.getTopWindowUrl(); | ||
if (ad.isNative == 1) { | ||
bidResponse.mediaType = NATIVE; | ||
bidResponse.native = setNativeResponse(ad); | ||
} else { | ||
bidResponse.width = parseInt(ad.w); | ||
bidResponse.height = parseInt(ad.h); | ||
bidResponse.ad = ad.ad; | ||
} | ||
bidResponses.push(bidResponse); | ||
}); | ||
return bidResponses; | ||
} | ||
}; | ||
function setNativeResponse(ad) { | ||
let nativeResponce = {}; | ||
nativeResponce.image = { | ||
url: ad.image, | ||
width: parseInt(ad.w), | ||
height: parseInt(ad.h) | ||
} | ||
nativeResponce.title = ad.title; | ||
nativeResponce.body = ad.desc; | ||
nativeResponce.sponsoredBy = ad.sponsoredBy; | ||
nativeResponce.clickUrl = ad.clickUrl; | ||
nativeResponce.clickTrackers = ad.clickTrackers || []; | ||
nativeResponce.impressionTrackers = ad.impressionTrackers || []; | ||
return nativeResponce; | ||
} | ||
|
||
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,65 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Digital Garage Ads Platform Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer:dgads-support@garage.co.jp | ||
``` | ||
|
||
# Description | ||
|
||
Connect to Digital Garage Ads Platform for bids. | ||
This adapter supports Banner and Native. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
// Banner | ||
{ | ||
code: 'banner-div', | ||
sizes: [[300, 250]], | ||
bids: [{ | ||
bidder: 'dgads', | ||
mediaTypes: 'banner', | ||
params: { | ||
location_id: '1', | ||
site_id: '1' | ||
} | ||
}] | ||
}, | ||
// Native | ||
{ | ||
code: 'native-div', | ||
sizes: [[300, 250]], | ||
mediaTypes: { | ||
native: { | ||
title: { | ||
required: true, | ||
len: 25 | ||
}, | ||
body: { | ||
required: true, | ||
len: 140 | ||
}, | ||
sponsoredBy: { | ||
required: true, | ||
len: 40 | ||
}, | ||
image: { | ||
required: true | ||
}, | ||
clickUrl: { | ||
required: true | ||
}, | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'dgads', | ||
params: { | ||
location_id: '10', | ||
site_id: '1' | ||
} | ||
}] | ||
}, | ||
]; | ||
``` |
Oops, something went wrong.