-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add New Adapter dgadsBidAdapter #2429
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7a3d9a9
Add dgads adapter
r-sato edddaaa
Add dgads adapter
r-sato e816a29
Add spec file for dgads
r-sato 51aa9ff
Add spec file for dgads
r-sato 0728914
Add dgads bid adapter
r-sato 1474213
Add dgads bid adapter
r-sato 4cf408a
fix
r-sato d49fd44
fix
r-sato 1f79f30
fix email
r-sato af7e80f
remove semi-colon
r-sato 865d7ad
Add mediaType native
r-sato 5588ecf
Add import medaTypes
r-sato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,87 @@ | ||
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.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:[email protected] | ||
``` | ||
|
||
# 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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove this semi-colon? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. We corresponded. |
||
} | ||
}] | ||
}, | ||
// 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhere in here I would recommend to set the bid's mediaType to
native
.When I was testing the native ad with the .md file's test params, the bid's
mediaType
was set to the defaultbanner
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. We corresponded.