diff --git a/adapters/tagbidder/bidder_config.go.bak b/adapters/tagbidder/bidder_config.go.bak deleted file mode 100644 index e82ba2209fd..00000000000 --- a/adapters/tagbidder/bidder_config.go.bak +++ /dev/null @@ -1,70 +0,0 @@ -package tagbidder - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "path/filepath" - "strings" - - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/golang/glog" -) - -//BidderConfig mapper json -type BidderConfig struct { - URL string `json:"url,omitempty"` - ResponseType ResponseHandlerType `json:"response,omitempty"` - Flags Flags `json:"flags,omitempty"` -} - -var bidderConfig = map[string]*BidderConfig{} - -//RegisterBidderConfig will be used by each bidder to set its respective macro Mapper -func RegisterBidderConfig(bidder string, config *BidderConfig) { - bidderConfig[bidder] = config -} - -//GetBidderConfig will return Mapper of specific bidder -func GetBidderConfig(bidder string) *BidderConfig { - return bidderConfig[bidder] -} - -//InitTagBidderConfig returns new Mapper from JSON details -func InitTagBidderConfig(schemaDirectory string, tagBidderMap map[string]openrtb_ext.BidderName) error { - fileInfos, err := ioutil.ReadDir(schemaDirectory) - if err != nil { - return fmt.Errorf("Failed to read JSON schemas from directory %s. %v", schemaDirectory, err) - } - - for _, fileInfo := range fileInfos { - - //checking for invalid tag bidder names - bidderName := strings.TrimSuffix(fileInfo.Name(), ".json") - if _, isValid := tagBidderMap[bidderName]; !isValid { - return fmt.Errorf("File %s/%s does not match a valid BidderName", schemaDirectory, fileInfo.Name()) - } - - //bidder config file absolute path - toOpen, err := filepath.Abs(filepath.Join(schemaDirectory, fileInfo.Name())) - if err != nil { - return fmt.Errorf("Failed to get an absolute representation of the path: %s, %v", toOpen, err) - } - - //reading config file contents - fileBytes, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", schemaDirectory, fileInfo.Name())) - if err != nil { - return fmt.Errorf("Failed to read file %s/%s: %v", schemaDirectory, fileInfo.Name(), err) - } - - //reading bidder config values - var bidderConfig BidderConfig - if err := json.Unmarshal(fileBytes, &bidderConfig); nil != err { - glog.Fatalf("error parsing json in file %s: %v", schemaDirectory+"/"+bidderName+".json", err) - } - - //register tag bidder configurations - RegisterBidderConfig(bidderName, &bidderConfig) - } - return nil -} diff --git a/adapters/tagbidder/bidder_macro.go b/adapters/vastbidder/bidder_macro.go similarity index 96% rename from adapters/tagbidder/bidder_macro.go rename to adapters/vastbidder/bidder_macro.go index 68f883eb243..ecede07e3e8 100644 --- a/adapters/tagbidder/bidder_macro.go +++ b/adapters/vastbidder/bidder_macro.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder import ( "encoding/json" @@ -21,17 +21,17 @@ type BidderMacro struct { //Configuration Parameters Conf *config.Adapter - //BidderConf *BidderConfig //OpenRTB Specific Parameters - Request *openrtb.BidRequest - IsApp bool - HasGeo bool - Imp *openrtb.Imp - Publisher *openrtb.Publisher - Content *openrtb.Content - UserExt *openrtb_ext.ExtUser - RegsExt *openrtb_ext.ExtRegs + Request *openrtb.BidRequest + IsApp bool + HasGeo bool + Imp *openrtb.Imp + ImpBidderExt map[string]interface{} + Publisher *openrtb.Publisher + Content *openrtb.Content + UserExt *openrtb_ext.ExtUser + RegsExt *openrtb_ext.ExtRegs } //NewBidderMacro contains definition for all openrtb macro's @@ -78,22 +78,23 @@ func (tag *BidderMacro) InitBidRequest(request *openrtb.BidRequest) { //LoadImpression will set current imp func (tag *BidderMacro) LoadImpression(imp *openrtb.Imp) error { tag.Imp = imp - return nil -} -//GetBidderKeys will set bidder level keys -func (tag *BidderMacro) GetBidderKeys() map[string]string { var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(tag.Imp.Ext, &bidderExt); err != nil { - return nil + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + return err } - ext := map[string]interface{}{} - if err := json.Unmarshal(bidderExt.Bidder, &ext); err != nil { - return nil + tag.ImpBidderExt = map[string]interface{}{} + if err := json.Unmarshal(bidderExt.Bidder, &tag.ImpBidderExt); err != nil { + return err } - return normalizeJSON(ext) + return nil +} + +//GetBidderKeys will set bidder level keys +func (tag *BidderMacro) GetBidderKeys() map[string]string { + return NormalizeJSON(tag.ImpBidderExt) } //SetAdapterConfig will set Adapter config @@ -101,23 +102,17 @@ func (tag *BidderMacro) SetAdapterConfig(conf *config.Adapter) { tag.Conf = conf } -/* -//SetBidderConfig will set Bidder config -func (tag *BidderMacro) SetBidderConfig(conf *BidderConfig) { - tag.BidderConf = conf -} -*/ - //GetURI get URL func (tag *BidderMacro) GetURI() string { - //1. check for impression level URL - //2. check for bidder config level URL - //3. check for adapter config level URL - /* - if nil != tag.BidderConf && len(tag.BidderConf.URL) > 0 { - return tag.BidderConf.URL + + //check for URI at impression level + if nil != tag.ImpBidderExt { + if value, ok := tag.ImpBidderExt["url"]; ok { + return value.(string) } - */ + } + + //check for URI at config level return tag.Conf.Endpoint } @@ -300,7 +295,7 @@ func (tag *BidderMacro) MacroVideoMaximumDuration(key string) string { func (tag *BidderMacro) MacroVideoProtocols(key string) string { if nil != tag.Imp.Video { value := tag.Imp.Video.Protocols - return objectArrayToString(len(value), comma, func(i int) string { + return ObjectArrayToString(len(value), comma, func(i int) string { return strconv.FormatInt(int64(value[i]), intBase) }) } @@ -383,7 +378,7 @@ func (tag *BidderMacro) MacroVideoSequence(key string) string { func (tag *BidderMacro) MacroVideoBlockedAttribute(key string) string { if nil != tag.Imp.Video { value := tag.Imp.Video.BAttr - return objectArrayToString(len(value), comma, func(i int) string { + return ObjectArrayToString(len(value), comma, func(i int) string { return strconv.FormatInt(int64(value[i]), intBase) }) } @@ -426,7 +421,7 @@ func (tag *BidderMacro) MacroVideoBoxing(key string) string { func (tag *BidderMacro) MacroVideoPlaybackMethod(key string) string { if nil != tag.Imp.Video { value := tag.Imp.Video.PlaybackMethod - return objectArrayToString(len(value), comma, func(i int) string { + return ObjectArrayToString(len(value), comma, func(i int) string { return strconv.FormatInt(int64(value[i]), intBase) }) } @@ -437,7 +432,7 @@ func (tag *BidderMacro) MacroVideoPlaybackMethod(key string) string { func (tag *BidderMacro) MacroVideoDelivery(key string) string { if nil != tag.Imp.Video { value := tag.Imp.Video.Delivery - return objectArrayToString(len(value), comma, func(i int) string { + return ObjectArrayToString(len(value), comma, func(i int) string { return strconv.FormatInt(int64(value[i]), intBase) }) } @@ -456,7 +451,7 @@ func (tag *BidderMacro) MacroVideoPosition(key string) string { func (tag *BidderMacro) MacroVideoAPI(key string) string { if nil != tag.Imp.Video { value := tag.Imp.Video.API - return objectArrayToString(len(value), comma, func(i int) string { + return ObjectArrayToString(len(value), comma, func(i int) string { return strconv.FormatInt(int64(value[i]), intBase) }) } diff --git a/adapters/tagbidder/constant.go b/adapters/vastbidder/constant.go similarity index 94% rename from adapters/tagbidder/constant.go rename to adapters/vastbidder/constant.go index 4cf269accb7..b5331f5cc67 100644 --- a/adapters/tagbidder/constant.go +++ b/adapters/vastbidder/constant.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder const ( intBase = 10 @@ -153,11 +153,3 @@ const ( //Additional MacroCacheBuster = `cachebuster` ) - -//ResponseHandlerType list of tag based response handlers -type ResponseHandlerType string - -const ( - OpenRTBResponseHandlerType ResponseHandlerType = `openrtb` - VASTTagResponseHandlerType ResponseHandlerType = `vasttag` -) diff --git a/adapters/tagbidder/ibidder_macro.go b/adapters/vastbidder/ibidder_macro.go similarity index 92% rename from adapters/tagbidder/ibidder_macro.go rename to adapters/vastbidder/ibidder_macro.go index baf83cdb77a..f718f3f6f14 100644 --- a/adapters/tagbidder/ibidder_macro.go +++ b/adapters/vastbidder/ibidder_macro.go @@ -1,9 +1,10 @@ -package tagbidder +package vastbidder import ( - "errors" "net/http" + "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/PubMatic-OpenWrap/openrtb" "github.com/PubMatic-OpenWrap/prebid-server/config" ) @@ -20,7 +21,6 @@ type IBidderMacro interface { LoadImpression(imp *openrtb.Imp) error GetBidderKeys() map[string]string SetAdapterConfig(*config.Adapter) - //SetBidderConfig(*BidderConfig) GetURI() string GetHeaders() http.Header @@ -171,22 +171,18 @@ type IBidderMacro interface { MacroCacheBuster(string) string } -var bidderMacroMap = map[string]func() IBidderMacro{} +var bidderMacroMap = map[openrtb_ext.BidderName]func() IBidderMacro{} //RegisterNewBidderMacro will be used by each bidder to set its respective macro IBidderMacro -func RegisterNewBidderMacro(bidder string, macro func() IBidderMacro) { +func RegisterNewBidderMacro(bidder openrtb_ext.BidderName, macro func() IBidderMacro) { bidderMacroMap[bidder] = macro } //GetNewBidderMacro will return IBidderMacro of specific bidder -func GetNewBidderMacro(bidder string) (IBidderMacro, error) { +func GetNewBidderMacro(bidder openrtb_ext.BidderName) IBidderMacro { callback, ok := bidderMacroMap[bidder] if ok { - return callback(), nil + return callback() } - return nil, errors.New(`missing bidder macro`) -} - -func init() { - RegisterNewBidderMacro(`spotx`, NewBidderMacro) + return NewBidderMacro() } diff --git a/adapters/tagbidder/itag_response_handler.go b/adapters/vastbidder/itag_response_handler.go similarity index 81% rename from adapters/tagbidder/itag_response_handler.go rename to adapters/vastbidder/itag_response_handler.go index d58cfa2a1b1..e0d2a251535 100644 --- a/adapters/tagbidder/itag_response_handler.go +++ b/adapters/vastbidder/itag_response_handler.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder import ( "errors" @@ -13,6 +13,13 @@ type ITagResponseHandler interface { MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) } +//ResponseHandlerType list of tag based response handlers +type ResponseHandlerType string + +const ( + VASTTagResponseHandlerType ResponseHandlerType = `vasttag` +) + //GetResponseHandler returns response handler func GetResponseHandler(responseType ResponseHandlerType) (ITagResponseHandler, error) { switch responseType { diff --git a/adapters/tagbidder/macro_processor.go b/adapters/vastbidder/macro_processor.go similarity index 99% rename from adapters/tagbidder/macro_processor.go rename to adapters/vastbidder/macro_processor.go index f3ee715cd5c..4f795bd6b97 100644 --- a/adapters/tagbidder/macro_processor.go +++ b/adapters/vastbidder/macro_processor.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder import ( "bytes" diff --git a/adapters/tagbidder/mapper.go b/adapters/vastbidder/mapper.go similarity index 98% rename from adapters/tagbidder/mapper.go rename to adapters/vastbidder/mapper.go index 79a5eca4708..a9590710bf0 100644 --- a/adapters/tagbidder/mapper.go +++ b/adapters/vastbidder/mapper.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder type macroCallBack struct { cached bool @@ -165,7 +165,7 @@ var _defaultMapper = Mapper{ MacroCacheBuster: ¯oCallBack{cached: false, callback: IBidderMacro.MacroCacheBuster}, } -//GetNewDefaultMapper will return clone of default Mapper function -func GetNewDefaultMapper() Mapper { +//GetDefaultMapper will return clone of default Mapper function +func GetDefaultMapper() Mapper { return _defaultMapper.clone() } diff --git a/adapters/vastbidder/sample_spotx_macro.go.bak b/adapters/vastbidder/sample_spotx_macro.go.bak new file mode 100644 index 00000000000..e84e6667b08 --- /dev/null +++ b/adapters/vastbidder/sample_spotx_macro.go.bak @@ -0,0 +1,26 @@ +package vastbidder + +import ( + "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" +) + +//SpotxMacro default implementation +type SpotxMacro struct { + *BidderMacro +} + +//NewSpotxMacro contains definition for all openrtb macro's +func NewSpotxMacro() IBidderMacro { + return &SpotxMacro{ + BidderMacro: &BidderMacro{}, + } +} + +//GetBidderKeys will set bidder level keys +func (tag *SpotxMacro) GetBidderKeys() map[string]string { + return NormalizeJSON(tag.ImpBidderExt) +} + +func init() { + RegisterNewBidderMacro(openrtb_ext.BidderSpotX, NewSpotxMacro) +} diff --git a/adapters/tagbidder/tagbidder.go b/adapters/vastbidder/tagbidder.go similarity index 70% rename from adapters/tagbidder/tagbidder.go rename to adapters/vastbidder/tagbidder.go index c12037ab4cd..df6441d598d 100644 --- a/adapters/tagbidder/tagbidder.go +++ b/adapters/vastbidder/tagbidder.go @@ -1,9 +1,6 @@ -package tagbidder +package vastbidder import ( - "errors" - "fmt" - "github.com/PubMatic-OpenWrap/openrtb" "github.com/PubMatic-OpenWrap/prebid-server/adapters" "github.com/PubMatic-OpenWrap/prebid-server/config" @@ -13,49 +10,17 @@ import ( //TagBidder is default implementation of ITagBidder type TagBidder struct { adapters.Bidder - bidderName string - //bidderConfig *BidderConfig + bidderName openrtb_ext.BidderName adapterConfig *config.Adapter } -//NewTagBidder is an constructor for TagBidder -func NewTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) (*TagBidder, error) { - obj := &TagBidder{ - bidderName: string(bidderName), - adapterConfig: &config, - //bidderConfig: GetBidderConfig(string(bidderName)), - } - /* - if nil == obj.bidderConfig { - return nil, errors.New(`missing bidder config`) - } - */ - return obj, nil -} - -//NewTestTagBidder is an constructor for TagBidder -func NewTestTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) *TagBidder { - obj, _ := NewTagBidder(bidderName, config) - return obj -} - //MakeRequests will contains default definition for processing queries func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - bidderMacro, err := GetNewBidderMacro(a.bidderName) - if nil != err { - return nil, []error{err} - } - - //bidderMapper := GetBidderMapper(a.bidderName) - bidderMapper := GetNewDefaultMapper() - if nil == bidderMapper { - return nil, []error{errors.New(`missing bidder mapper`)} - } - + bidderMacro := GetNewBidderMacro(a.bidderName) + bidderMapper := GetDefaultMapper() macroProcessor := NewMacroProcessor(bidderMacro, bidderMapper) //Setting config parameters - //bidderMacro.SetBidderConfig(a.bidderConfig) bidderMacro.SetAdapterConfig(a.adapterConfig) bidderMacro.InitBidRequest(request) @@ -68,7 +33,6 @@ func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters. //Setting Bidder Level Keys bidderKeys := bidderMacro.GetBidderKeys() macroProcessor.SetBidderKeys(bidderKeys) - fmt.Printf("\n[V2] Bidder Keys:%v", bidderKeys) //uri := macroProcessor.ProcessURL(bidderMacro.GetURI(), a.bidderConfig.Flags) uri := macroProcessor.ProcessURL(bidderMacro.GetURI(), Flags{RemoveEmptyParam: true}) @@ -95,7 +59,16 @@ func (a *TagBidder) MakeBids(internalRequest *openrtb.BidRequest, externalReques return handler.MakeBids(internalRequest, externalRequest, response) } +//NewTagBidder is an constructor for TagBidder +func NewTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) *TagBidder { + obj := &TagBidder{ + bidderName: bidderName, + adapterConfig: &config, + } + return obj +} + // Builder builds a new instance of the 33Across adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { - return NewTagBidder(bidderName, config) + return NewTagBidder(bidderName, config), nil } diff --git a/adapters/tagbidder/util.go b/adapters/vastbidder/util.go similarity index 81% rename from adapters/tagbidder/util.go rename to adapters/vastbidder/util.go index e59199d943e..87da2bc7651 100644 --- a/adapters/tagbidder/util.go +++ b/adapters/vastbidder/util.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder import ( "bytes" @@ -7,7 +7,7 @@ import ( "strconv" ) -func objectArrayToString(len int, separator string, cb func(i int) string) string { +func ObjectArrayToString(len int, separator string, cb func(i int) string) string { if 0 == len { return "" } @@ -42,12 +42,12 @@ func normalizeObject(prefix string, out map[string]string, obj map[string]interf } } -func normalizeJSON(obj map[string]interface{}) map[string]string { +func NormalizeJSON(obj map[string]interface{}) map[string]string { out := map[string]string{} normalizeObject("", out, obj) return out } -var getRandomID = func() string { +var GetRandomID = func() string { return strconv.FormatInt(rand.Int63(), intBase) } diff --git a/adapters/tagbidder/vast_tag_response_handler.go b/adapters/vastbidder/vast_tag_response_handler.go similarity index 89% rename from adapters/tagbidder/vast_tag_response_handler.go rename to adapters/vastbidder/vast_tag_response_handler.go index 34244501293..1d1494e7a7b 100644 --- a/adapters/tagbidder/vast_tag_response_handler.go +++ b/adapters/vastbidder/vast_tag_response_handler.go @@ -1,8 +1,8 @@ -package tagbidder +package vastbidder import ( + "encoding/json" "errors" - "fmt" "net/http" "regexp" "strconv" @@ -20,6 +20,7 @@ var durationRegExp = regexp.MustCompile(`^([01]?\d|2[0-3]):([0-5]?\d):([0-5]?\d) type IVASTTagResponseHandler interface { ITagResponseHandler ParseExtension(version string, tag *etree.Element, bid *adapters.TypedBid) []error + GetStaticPrice(ext json.RawMessage) float64 } //VASTTagResponseHandler to parse VAST Tag @@ -47,10 +48,32 @@ func (handler *VASTTagResponseHandler) MakeBids(internalRequest *openrtb.BidRequ } bidResponses, err := handler.vastTagToBidderResponse(internalRequest, externalRequest, response) - fmt.Printf("\n[V1] errors:[%v] bidresponse:[%v]", err, bidResponses) return bidResponses, err } +//GetStaticPrice will read pricing value from imp.ext.bidder.price +func (handler *VASTTagResponseHandler) GetStaticPrice(ext json.RawMessage) float64 { + if len(ext) > 0 { + var obj = map[string]interface{}{} + if err := json.Unmarshal(ext, &obj); nil != err { + return 0 + } + + value, ok := obj["price"] + if !ok { + return 0 + } + + price, ok := value.(float64) + if !ok { + return 0 + } + + return price + } + return 0 +} + //ParseExtension will parse VAST XML extension object func (handler *VASTTagResponseHandler) ParseExtension(version string, ad *etree.Element, bid *adapters.TypedBid) []error { return nil @@ -100,7 +123,7 @@ func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest * // generate random creative id if not present if "" == typedBid.Bid.CrID { - typedBid.Bid.CrID = "cr_" + getRandomID() + typedBid.Bid.CrID = "cr_" + GetRandomID() } bidResponse := &adapters.BidderResponse{ @@ -120,8 +143,11 @@ func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest * if typedBid.Bid.Price <= 0 { price, currency, ok := getPricingDetails(version, adElement) if !ok { - errs = append(errs, errors.New("Bid Price Not Present")) - return nil, errs[:] + price = handler.GetStaticPrice(internalRequest.Imp[externalRequest.ImpIndex].Ext) + if price <= 0 { + errs = append(errs, errors.New("Bid Price Not Present")) + return nil, errs[:] + } } typedBid.Bid.Price = price if len(currency) > 0 { @@ -131,7 +157,7 @@ func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest * //if bid.id is not set in ParseExtension if len(typedBid.Bid.ID) == 0 { - typedBid.Bid.ID = getRandomID() + typedBid.Bid.ID = GetRandomID() } //if bid.impid is not set in ParseExtension @@ -166,10 +192,10 @@ func getPricingDetails(version string, ad *etree.Element) (float64, string, bool var currency string var node *etree.Element - if `3.0` == version { - node = ad.FindElement(`./Pricing`) - } else if `2.0` == version { + if `2.0` == version { node = ad.FindElement(`./Extensions/Extension/Price`) + } else { + node = ad.FindElement(`./Pricing`) } if nil == node { diff --git a/adapters/tagbidder/vast_tag_response_handler_test.go b/adapters/vastbidder/vast_tag_response_handler_test.go similarity index 99% rename from adapters/tagbidder/vast_tag_response_handler_test.go rename to adapters/vastbidder/vast_tag_response_handler_test.go index 80d7836cd80..652da320ff2 100644 --- a/adapters/tagbidder/vast_tag_response_handler_test.go +++ b/adapters/vastbidder/vast_tag_response_handler_test.go @@ -1,4 +1,4 @@ -package tagbidder +package vastbidder import ( "errors" @@ -71,7 +71,7 @@ func TestVASTTagResponseHandler_vastTagToBidderResponse(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { handler := &VASTTagResponseHandler{} - getRandomID = func() string { + GetRandomID = func() string { return `1234` } diff --git a/config/config.go b/config/config.go index e27358b3d44..3a2ebcd16f7 100755 --- a/config/config.go +++ b/config/config.go @@ -607,6 +607,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+syncRedirectEndpoint+"bidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+syncRedirectEndpoint+"bidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. + // openrtb_ext.BidderVASTBidder doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.tremorhub.com/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+syncRedirectEndpoint+"bidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+syncRedirectEndpoint+"bidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+syncRedirectEndpoint+"bidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") @@ -817,6 +818,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.sovrn.endpoint", "http://ap.lijit.com/rtb/bid?src=prebid_server") v.SetDefault("adapters.synacormedia.endpoint", "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}") v.SetDefault("adapters.spotx.endpoint", "https://search.spotxchange.com/openrtb/2.3/dados") + v.SetDefault("adapters.vastbidder.endpoint", "https://test.com") v.SetDefault("adapters.tappx.endpoint", "https://{{.Host}}") v.SetDefault("adapters.telaria.endpoint", "https://ads.tremorhub.com/ad/rtb/prebid") v.SetDefault("adapters.triplelift_native.disabled", true) diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index a512fde736c..291a3ea472d 100755 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -67,7 +67,6 @@ import ( "github.com/PubMatic-OpenWrap/prebid-server/adapters/sonobi" "github.com/PubMatic-OpenWrap/prebid-server/adapters/sovrn" "github.com/PubMatic-OpenWrap/prebid-server/adapters/synacormedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/tagbidder" "github.com/PubMatic-OpenWrap/prebid-server/adapters/tappx" "github.com/PubMatic-OpenWrap/prebid-server/adapters/telaria" "github.com/PubMatic-OpenWrap/prebid-server/adapters/triplelift" @@ -75,6 +74,7 @@ import ( "github.com/PubMatic-OpenWrap/prebid-server/adapters/ucfunnel" "github.com/PubMatic-OpenWrap/prebid-server/adapters/unruly" "github.com/PubMatic-OpenWrap/prebid-server/adapters/valueimpression" + "github.com/PubMatic-OpenWrap/prebid-server/adapters/vastbidder" "github.com/PubMatic-OpenWrap/prebid-server/adapters/verizonmedia" "github.com/PubMatic-OpenWrap/prebid-server/adapters/visx" "github.com/PubMatic-OpenWrap/prebid-server/adapters/vrtcal" @@ -157,7 +157,8 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderSovrn: sovrn.NewSovrnBidder(client, cfg.Adapters[string(openrtb_ext.BidderSovrn)].Endpoint), openrtb_ext.BidderSynacormedia: synacormedia.NewSynacorMediaBidder(cfg.Adapters[string(openrtb_ext.BidderSynacormedia)].Endpoint), //openrtb_ext.BidderSpotX: spotx.NewSpotxBidder(cfg.Adapters[string(openrtb_ext.BidderSpotX)].Endpoint), - openrtb_ext.BidderSpotX: tagbidder.NewTestTagBidder(openrtb_ext.BidderSpotX, cfg.Adapters[string(openrtb_ext.BidderSpotX)]), + openrtb_ext.BidderSpotX: vastbidder.NewTagBidder(openrtb_ext.BidderSpotX, cfg.Adapters[string(openrtb_ext.BidderSpotX)]), + openrtb_ext.BidderVASTBidder: vastbidder.NewTagBidder(openrtb_ext.BidderVASTBidder, cfg.Adapters[string(openrtb_ext.BidderVASTBidder)]), openrtb_ext.BidderTappx: tappx.NewTappxBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTappx))].Endpoint), openrtb_ext.BidderTelaria: telaria.NewTelariaBidder(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTelaria))].Endpoint), openrtb_ext.BidderTriplelift: triplelift.NewTripleliftBidder(client, cfg.Adapters[string(openrtb_ext.BidderTriplelift)].Endpoint), diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 80a29859284..016015954a7 100755 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -84,6 +84,7 @@ const ( BidderSovrn BidderName = "sovrn" BidderSpotX BidderName = "spotx" BidderSynacormedia BidderName = "synacormedia" + BidderVASTBidder BidderName = "vastbidder" BidderTappx BidderName = "tappx" BidderTelaria BidderName = "telaria" BidderTriplelift BidderName = "triplelift" @@ -164,6 +165,7 @@ var BidderMap = map[string]BidderName{ "sovrn": BidderSovrn, "spotx": BidderSpotX, "synacormedia": BidderSynacormedia, + "vastbidder": BidderVASTBidder, "tappx": BidderTappx, "telaria": BidderTelaria, "triplelift": BidderTriplelift, @@ -181,13 +183,6 @@ var BidderMap = map[string]BidderName{ "zeroclickfraud": BidderZeroClickFraud, } -/* -//TagBidderMap contains list of tag based bidders -var TagBidderMap = map[string]BidderName{ - "spotx": BidderSpotX, -} -*/ - // BidderList returns the values of the BidderMap func BidderList() []BidderName { bidders := make([]BidderName, 0, len(BidderMap)) diff --git a/privacy/enforcement_test.go b/privacy/enforcement_test.go index 90af24b27ea..3cb13525647 100644 --- a/privacy/enforcement_test.go +++ b/privacy/enforcement_test.go @@ -247,8 +247,8 @@ func TestApply(t *testing.T) { test.enforcement.apply(req, test.ampGDPRException, m) m.AssertExpectations(t) - assert.Same(t, replacedDevice, req.Device, "Device") - assert.Same(t, replacedUser, req.User, "User") + assert.Equal(t, replacedDevice, req.Device, "Device") + assert.Equal(t, replacedUser, req.User, "User") } } diff --git a/router/router.go b/router/router.go index eac37cbb26e..755c18a452b 100644 --- a/router/router.go +++ b/router/router.go @@ -191,7 +191,6 @@ func New(cfg *config.Configuration, rateConvertor *currencies.RateConverter) (r const schemaDirectory = "/home/http/GO_SERVER/dmhbserver/static/bidder-params" const infoDirectory = "/home/http/GO_SERVER/dmhbserver/static/bidder-info" - const tagBidderSchemaDirectory = "/home/http/GO_SERVER/dmhbserver/static/tagbidder-params" r = &Router{ Router: httprouter.New(), @@ -245,12 +244,7 @@ func New(cfg *config.Configuration, rateConvertor *currencies.RateConverter) (r if err != nil { glog.Fatalf("Failed to create the bidder params validator. %v", err) } - /* - err = tagbidder.InitTagBidderConfig(tagBidderSchemaDirectory, openrtb_ext.TagBidderMap) - if err != nil { - glog.Fatalf("Failed to create the tag bidder config. %v", err) - } - */ + p, _ := filepath.Abs(infoDirectory) bidderInfos := adapters.ParseBidderInfos(cfg.Adapters, p, openrtb_ext.BidderList()) diff --git a/router/router_test.go b/router/router_test.go index 866b93de980..32aec6cc9d3 100644 --- a/router/router_test.go +++ b/router/router_test.go @@ -53,7 +53,7 @@ func TestNewJsonDirectoryServer(t *testing.T) { } for _, adapterFile := range adapterFiles { - if adapterFile.IsDir() && adapterFile.Name() != "adapterstest" && adapterFile.Name() != "tagbidder" { + if adapterFile.IsDir() && adapterFile.Name() != "adapterstest" { ensureHasKey(t, data, adapterFile.Name()) } } diff --git a/static/bidder-info/vastbidder.yaml b/static/bidder-info/vastbidder.yaml new file mode 100644 index 00000000000..b8eb41d4e49 --- /dev/null +++ b/static/bidder-info/vastbidder.yaml @@ -0,0 +1,9 @@ +maintainer: + email: "UOEDev@pubmatic.com" +capabilities: + app: + mediaTypes: + - video + site: + mediaTypes: + - video diff --git a/static/bidder-params/vastbidder.json b/static/bidder-params/vastbidder.json new file mode 100644 index 00000000000..35e6af7951d --- /dev/null +++ b/static/bidder-params/vastbidder.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Tag Bidder Base Adapter", + "description": "A schema which validates params accepted by the VAST tag bidders", + + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "price": { + "type": "integer" + }, + "parser": { + "type": "string" + } + }, + "required": ["url"] +} \ No newline at end of file diff --git a/static/tagbidder-params/spotx.json b/static/tagbidder-params/spotx.json deleted file mode 100644 index d8f8fcf5d51..00000000000 --- a/static/tagbidder-params/spotx.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "url": "https://search.spotxchange.com/vast/2.00/{{channel_id}}?VPI=MP4&app[bundle]={{bundle}}&app[name]={{appname}}&app[cat]={{cat}}&app[domain]={{domain}}&app[privacypolicy]={{privacypolicy}}&app[storeurl]={{storeurl_ESC}}&app[ver]={{appver}}&cb={{cachebuster}}&device[devicetype]={{devicetype}}&device[ifa]={{ifa}}&device[make]={{make}}&device[model]={{model}}&device[dnt]={{dnt}}&player_height={{playerheight}}&player_width={{playerwidth}}&ip_addr={{ip}}&device[ua]={{useragent_ESC}}", - "response": "vasttag", - "flags": { - "remove_empty": true - } -} \ No newline at end of file diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 0bc2f6a458d..4da718b54cc 100755 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -92,6 +92,7 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderPubnative: true, openrtb_ext.BidderSpotX: true, openrtb_ext.BidderTappx: true, + openrtb_ext.BidderVASTBidder: true, openrtb_ext.BidderYeahmobi: true, }