Skip to content

Commit

Permalink
Updated changes requested
Browse files Browse the repository at this point in the history
Brand Name
Vender list id
Consent string
email corrected
  • Loading branch information
Chandra Prakash committed Apr 23, 2020
1 parent 0cacb22 commit dac000a
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 43 deletions.
42 changes: 21 additions & 21 deletions adapters/ninthdecimal/ninthdecimal.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

type NinthdecimalAdapter struct {
type NinthDecimalAdapter struct {
EndpointTemplate template.Template
}

//MakeRequests prepares request information for prebid-server core
func (adapter *NinthdecimalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
func (adapter *NinthDecimalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
errs := make([]error, 0, len(request.Imp))
if len(request.Imp) == 0 {
errs = append(errs, &errortypes.BadInput{Message: "No impression in the bid request"})
Expand Down Expand Up @@ -48,10 +48,10 @@ func (adapter *NinthdecimalAdapter) MakeRequests(request *openrtb.BidRequest, re
}

// getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts
func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthdecimal][]openrtb.Imp, []openrtb.Imp, []error) {
func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthDecimal][]openrtb.Imp, []openrtb.Imp, []error) {
errors := make([]error, 0, len(imps))
resImps := make([]openrtb.Imp, 0, len(imps))
res := make(map[openrtb_ext.ExtImpNinthdecimal][]openrtb.Imp)
res := make(map[openrtb_ext.ExtImpNinthDecimal][]openrtb.Imp)

for _, imp := range imps {
impExt, err := getImpressionExt(&imp)
Expand All @@ -64,7 +64,7 @@ func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthdecimal]
continue
}
//dispatchImpressions
//Group impressions by ninthdecimal-specific parameters `pubid
//Group impressions by NinthDecimal-specific parameters `pubid
if err := compatImpression(&imp); err != nil {
errors = append(errors, err)
continue
Expand All @@ -78,16 +78,16 @@ func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthdecimal]
return res, resImps, errors
}

func validateImpression(impExt *openrtb_ext.ExtImpNinthdecimal) error {
func validateImpression(impExt *openrtb_ext.ExtImpNinthDecimal) error {
if impExt.PublisherID == "" {
return &errortypes.BadInput{Message: "No pubid value provided"}
}
return nil
}

//Alter impression info to comply with ninthdecimal platform requirements
//Alter impression info to comply with NinthDecimal platform requirements
func compatImpression(imp *openrtb.Imp) error {
imp.Ext = nil //do not forward ext to ninthdecimal platform
imp.Ext = nil //do not forward ext to NinthDecimal platform
if imp.Banner != nil {
return compatBannerImpression(imp)
}
Expand All @@ -99,7 +99,7 @@ func compatBannerImpression(imp *openrtb.Imp) error {

bannerCopy := *imp.Banner
banner := &bannerCopy
//As banner.w/h are required fields for ninthdecimalAdn platform - take the first format entry
//As banner.w/h are required fields for NinthDecimal platform - take the first format entry
if banner.W == nil || banner.H == nil {
if len(banner.Format) == 0 {
return &errortypes.BadInput{Message: "Expected at least one banner.format entry or explicit w/h"}
Expand All @@ -113,23 +113,23 @@ func compatBannerImpression(imp *openrtb.Imp) error {
return nil
}

func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpNinthdecimal, error) {
func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpNinthDecimal, error) {
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
Message: err.Error(),
}
}
var ninthdecimalExt openrtb_ext.ExtImpNinthdecimal
if err := json.Unmarshal(bidderExt.Bidder, &ninthdecimalExt); err != nil {
var NinthDecimalExt openrtb_ext.ExtImpNinthDecimal
if err := json.Unmarshal(bidderExt.Bidder, &NinthDecimalExt); err != nil {
return nil, &errortypes.BadInput{
Message: err.Error(),
}
}
return &ninthdecimalExt, nil
return &NinthDecimalExt, nil
}

func (adapter *NinthdecimalAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthdecimal, imps []openrtb.Imp) (*adapters.RequestData, error) {
func (adapter *NinthDecimalAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb.Imp) (*adapters.RequestData, error) {
newBidRequest := createBidRequest(prebidBidRequest, params, imps)
reqJSON, err := json.Marshal(newBidRequest)
if err != nil {
Expand All @@ -153,7 +153,7 @@ func (adapter *NinthdecimalAdapter) buildAdapterRequest(prebidBidRequest *openrt
Headers: headers}, nil
}

func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthdecimal, imps []openrtb.Imp) *openrtb.BidRequest {
func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb.Imp) *openrtb.BidRequest {
bidRequest := *prebidBidRequest
bidRequest.Imp = imps
for idx := range bidRequest.Imp {
Expand All @@ -177,13 +177,13 @@ func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.
}

// Builds enpoint url based on adapter-specific pub settings from imp.ext
func (adapter *NinthdecimalAdapter) buildEndpointURL(params *openrtb_ext.ExtImpNinthdecimal) (string, error) {
func (adapter *NinthDecimalAdapter) buildEndpointURL(params *openrtb_ext.ExtImpNinthDecimal) (string, error) {
endpointParams := macros.EndpointTemplateParams{PublisherID: params.PublisherID}
return macros.ResolveMacros(adapter.EndpointTemplate, endpointParams)
}

//MakeBids translates ninthdecimal bid response to prebid-server specific format
func (adapter *NinthdecimalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
//MakeBids translates NinthDecimal bid response to prebid-server specific format
func (adapter *NinthDecimalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
var msg = ""
if response.StatusCode == http.StatusNoContent {
return nil, nil
Expand Down Expand Up @@ -226,11 +226,11 @@ func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType
return openrtb_ext.BidTypeBanner
}

// NewNinthdecimalAdapter to be called in prebid-server core to create ninthdecimal adapter instance
func NewNinthdecimalBidder(endpointTemplate string) adapters.Bidder {
// NewNinthDecimalAdapter to be called in prebid-server core to create NinthDecimal adapter instance
func NewNinthDecimalBidder(endpointTemplate string) adapters.Bidder {
template, err := template.New("endpointTemplate").Parse(endpointTemplate)
if err != nil {
return nil
}
return &NinthdecimalAdapter{EndpointTemplate: *template}
return &NinthDecimalAdapter{EndpointTemplate: *template}
}
2 changes: 1 addition & 1 deletion adapters/ninthdecimal/ninthdecimal_test.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import (
)

func TestJsonSamples(t *testing.T) {
adapterstest.RunJSONBidderTest(t, "ninthdecimaltest", NewNinthdecimalBidder("http://rtb.ninthdecimal.com/xp/get?pubid={{.PublisherID}}"))
adapterstest.RunJSONBidderTest(t, "ninthdecimaltest", NewNinthDecimalBidder("http://rtb.ninthdecimal.com/xp/get?pubid={{.PublisherID}}"))
}
6 changes: 3 additions & 3 deletions adapters/ninthdecimal/params_test.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestValidParams(t *testing.T) {
}

for _, validParam := range validParams {
if err := validator.Validate(openrtb_ext.BidderNinthdecimal, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected Ninthdecimal params: %s", validParam)
if err := validator.Validate(openrtb_ext.BidderNinthDecimal, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected NinthDecimal params: %s", validParam)
}
}
}
Expand All @@ -26,7 +26,7 @@ func TestInvalidParams(t *testing.T) {
}

for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderNinthdecimal, json.RawMessage(invalidParam)); err == nil {
if err := validator.Validate(openrtb_ext.BidderNinthDecimal, json.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
}
}
Expand Down
4 changes: 2 additions & 2 deletions adapters/ninthdecimal/usersync.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (
"github.com/prebid/prebid-server/usersync"
)

func NewNinthdecimalSyncer(temp *template.Template) usersync.Usersyncer {
return adapters.NewSyncer("ninthdecimal", 61, temp, adapters.SyncTypeIframe)
func NewNinthDecimalSyncer(temp *template.Template) usersync.Usersyncer {
return adapters.NewSyncer("ninthdecimal", 0, temp, adapters.SyncTypeIframe)
}
10 changes: 5 additions & 5 deletions adapters/ninthdecimal/usersync_test.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import (
"github.com/stretchr/testify/assert"
)

func TestNinthdecimalSyncer(t *testing.T) {
func TestNinthDecimalSyncer(t *testing.T) {
syncURL := "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=ninthdecimal&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&uid=$UID"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)

syncer := NewNinthdecimalSyncer(syncURLTemplate)
syncer := NewNinthDecimalSyncer(syncURLTemplate)
syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{
GDPR: gdpr.Policy{
Signal: "1",
Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA",
Consent: "A",
},
})

assert.NoError(t, err)
assert.Equal(t, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=ninthdecimal&gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&uid=$UID", syncInfo.URL)
assert.Equal(t, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=ninthdecimal&gdpr=1&gdpr_consent=A&uid=$UID", syncInfo.URL)
assert.Equal(t, "iframe", syncInfo.Type)
assert.EqualValues(t, 61, syncer.GDPRVendorID())
assert.EqualValues(t, 0, syncer.GDPRVendorID())
assert.Equal(t, false, syncInfo.SupportCORS)
}
2 changes: 1 addition & 1 deletion config/config.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (cfg *Configuration) setDerivedDefaults() {
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderMarsmedia, "https://dmp.rtbsrv.com/dmp/profiles/cm?p_id=179&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dmarsmedia%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderMgid, "https://cm.mgid.com/m?cdsp=363893&adu="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Bmuidn%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNanoInteractive, "https://ad.audiencemanager.de/hbs/cookie_sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirectUri="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dnanointeractive%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNinthdecimal, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dninthdecimal%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNinthDecimal, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dninthdecimal%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderOpenx, "https://rtb.openx.net/sync/prebid?r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPubmatic, "https://ads.pubmatic.com/AdServer/js/user_sync.html?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&predirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPulsepoint, "https://bh.contextweb.com/rtset?pid=561205&ev=1&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25VGUID%25%25")
Expand Down
2 changes: 1 addition & 1 deletion exchange/adapter_map.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter
openrtb_ext.BidderMarsmedia: marsmedia.NewMarsmediaBidder(cfg.Adapters[string(openrtb_ext.BidderMarsmedia)].Endpoint),
openrtb_ext.BidderMgid: mgid.NewMgidBidder(cfg.Adapters[string(openrtb_ext.BidderMgid)].Endpoint),
openrtb_ext.BidderNanoInteractive: nanointeractive.NewNanoIneractiveBidder(cfg.Adapters[string(openrtb_ext.BidderNanoInteractive)].Endpoint),
openrtb_ext.BidderNinthdecimal: ninthdecimal.NewNinthdecimalBidder(cfg.Adapters[string(openrtb_ext.BidderNinthdecimal)].Endpoint),
openrtb_ext.BidderNinthDecimal: ninthdecimal.NewNinthDecimalBidder(cfg.Adapters[string(openrtb_ext.BidderNinthDecimal)].Endpoint),
openrtb_ext.BidderOpenx: openx.NewOpenxBidder(cfg.Adapters[string(openrtb_ext.BidderOpenx)].Endpoint),
openrtb_ext.BidderPubmatic: pubmatic.NewPubmaticBidder(client, cfg.Adapters[string(openrtb_ext.BidderPubmatic)].Endpoint),
openrtb_ext.BidderPubnative: pubnative.NewPubnativeBidder(cfg.Adapters[string(openrtb_ext.BidderPubnative)].Endpoint),
Expand Down
4 changes: 2 additions & 2 deletions openrtb_ext/bidders.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const (
BidderMarsmedia BidderName = "marsmedia"
BidderMgid BidderName = "mgid"
BidderNanoInteractive BidderName = "nanointeractive"
BidderNinthdecimal BidderName = "ninthdecimal"
BidderNinthDecimal BidderName = "ninthdecimal"
BidderOpenx BidderName = "openx"
BidderPubmatic BidderName = "pubmatic"
BidderPubnative BidderName = "pubnative"
Expand Down Expand Up @@ -122,7 +122,7 @@ var BidderMap = map[string]BidderName{
"marsmedia": BidderMarsmedia,
"mgid": BidderMgid,
"nanointeractive": BidderNanoInteractive,
"ninthdecimal": BidderNinthdecimal,
"ninthdecimal": BidderNinthDecimal,
"openx": BidderOpenx,
"pubmatic": BidderPubmatic,
"pubnative": BidderPubnative,
Expand Down
2 changes: 1 addition & 1 deletion openrtb_ext/imp_ninthdecimal.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package openrtb_ext

type ExtImpNinthdecimal struct {
type ExtImpNinthDecimal struct {
PublisherID string `json:"pubid"`
Placement string `json:"placement,omitempty"`
}
2 changes: 1 addition & 1 deletion static/bidder-info/ninthdecimal.yaml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
maintainer:
email: "lokesh@advangelists.com"
email: "abudig@ninthdecimal.com"
capabilities:
site:
mediaTypes:
Expand Down
6 changes: 3 additions & 3 deletions static/bidder-params/ninthdecimal.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Ninthdecimal Adapter Params",
"description": "A schema which validates params accepted by the Ninthdecimal adapter",
"title": "NinthDecimal Adapter Params",
"description": "A schema which validates params accepted by the NinthDecimal adapter",
"type": "object",
"properties": {
"pubid": {
"type": "string",
"description": "An id used to identify Ninthdecimal publisher.",
"description": "An id used to identify NinthDecimal publisher.",
"minLength": 8
},
"placement": {
Expand Down
2 changes: 1 addition & 1 deletion usersync/usersyncers/syncer.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync
insertIntoMap(cfg, syncers, openrtb_ext.BidderMarsmedia, marsmedia.NewMarsmediaSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderMgid, mgid.NewMgidSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderNanoInteractive, nanointeractive.NewNanoInteractiveSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderNinthdecimal, ninthdecimal.NewNinthdecimalSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderNinthDecimal, ninthdecimal.NewNinthDecimalSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderOpenx, openx.NewOpenxSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderPubmatic, pubmatic.NewPubmaticSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderPulsepoint, pulsepoint.NewPulsepointSyncer)
Expand Down
2 changes: 1 addition & 1 deletion usersync/usersyncers/syncer_test.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestNewSyncerMap(t *testing.T) {
string(openrtb_ext.BidderMarsmedia): syncConfig,
string(openrtb_ext.BidderMgid): syncConfig,
string(openrtb_ext.BidderNanoInteractive): syncConfig,
string(openrtb_ext.BidderNinthdecimal): syncConfig,
string(openrtb_ext.BidderNinthDecimal): syncConfig,
string(openrtb_ext.BidderOpenx): syncConfig,
string(openrtb_ext.BidderPubmatic): syncConfig,
string(openrtb_ext.BidderPulsepoint): syncConfig,
Expand Down

0 comments on commit dac000a

Please sign in to comment.