Skip to content
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

Wap 4485 adaptor #2

Open
wants to merge 13 commits into
base: spotx_bid_adaptor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
451 changes: 451 additions & 0 deletions adapters/spotx/spotx.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions adapters/spotx/spotx_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package spotx

import (
"net/http"
"testing"

"github.com/prebid/prebid-server/adapters/adapterstest"
)

func TestJsonSamples(t *testing.T) {
adapterstest.RunJSONBidderTest(t, "spotxtests", NewBidder(new(http.Client), "http://search.spotxchange.com/openrtb"))
}
202 changes: 202 additions & 0 deletions adapters/spotx/spotxtests/exemplary/ortb_2.3_video.json

Large diffs are not rendered by default.

202 changes: 202 additions & 0 deletions adapters/spotx/spotxtests/exemplary/ortb_2.5_video.json

Large diffs are not rendered by default.

198 changes: 198 additions & 0 deletions adapters/spotx/spotxtests/exemplary/ortb_default_video.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions adapters/spotx/spotxtests/template/tmplt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"mockBidRequest": {

},
"httpCalls": [
{
"expectedRequest": {

},
"mockResponse": {

}
}
],
"expectedBidResponses": [
{

}
]
}
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ func SetupViper(v *viper.Viper, filename string) {
v.SetDefault("adapters.sonobi.endpoint", "https://apex.go.sonobi.com/prebid?partnerid=71d9d3d8af")
v.SetDefault("adapters.unruly.endpoint", "http://targeting.unrulymedia.com/openrtb/2.2")
v.SetDefault("adapters.vrtcal.endpoint", "http://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804")
v.SetDefault("adapters.spotx.endpoint", "http://search.spotxchange.com/openrtb")
v.SetDefault("adapters.yieldmo.endpoint", "http://ads.yieldmo.com/exchange/prebid-server")
v.SetDefault("adapters.gamoshi.endpoint", "https://rtb.gamoshi.io")
v.SetDefault("adapters.mgid.endpoint", "https://prebid.mgid.com/prebid/")
Expand Down
2 changes: 1 addition & 1 deletion endpoints/cookie_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestCookieSyncNoBidders(t *testing.T) {
rr := doPost("{}", nil, true, syncersForTest())
assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8")
assert.Equal(t, http.StatusOK, rr.Code)
assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork", "lifestreet", "pubmatic"}, parseSyncs(t, rr.Body.Bytes()))
assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork", "lifestreet", "pubmatic", "spotx"}, parseSyncs(t, rr.Body.Bytes()))
assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes()))
}

Expand Down
3 changes: 3 additions & 0 deletions exchange/adapter_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/prebid/prebid-server/adapters/somoaudience"
"github.com/prebid/prebid-server/adapters/sonobi"
"github.com/prebid/prebid-server/adapters/sovrn"
"github.com/prebid/prebid-server/adapters/spotx"
"github.com/prebid/prebid-server/adapters/tappx"
"github.com/prebid/prebid-server/adapters/triplelift"
"github.com/prebid/prebid-server/adapters/unruly"
Expand Down Expand Up @@ -82,9 +83,11 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter
openrtb_ext.Bidder33Across: ttx.New33AcrossBidder(cfg.Adapters[string(openrtb_ext.Bidder33Across)].Endpoint),
openrtb_ext.BidderGrid: grid.NewGridBidder(cfg.Adapters[string(openrtb_ext.BidderGrid)].Endpoint),
openrtb_ext.BidderSonobi: sonobi.NewSonobiBidder(client, cfg.Adapters[string(openrtb_ext.BidderSonobi)].Endpoint),
openrtb_ext.BidderSpotx: spotx.NewBidder(client, cfg.Adapters[string(openrtb_ext.BidderSpotx)].Endpoint),
openrtb_ext.BidderTriplelift: triplelift.NewTripleliftBidder(client, cfg.Adapters[string(openrtb_ext.BidderTriplelift)].Endpoint),
openrtb_ext.BidderUnruly: unruly.NewUnrulyBidder(client, cfg.Adapters[string(openrtb_ext.BidderUnruly)].Endpoint),
openrtb_ext.BidderVrtcal: vrtcal.NewVrtcalBidder(cfg.Adapters[string(openrtb_ext.BidderVrtcal)].Endpoint),
openrtb_ext.BidderSpotx: spotx.NewBidder(client, cfg.Adapters[string(openrtb_ext.BidderSonobi)].Endpoint),
openrtb_ext.BidderYieldmo: yieldmo.NewYieldmoBidder(cfg.Adapters[string(openrtb_ext.BidderYieldmo)].Endpoint),
openrtb_ext.BidderVisx: visx.NewVisxBidder(cfg.Adapters[string(openrtb_ext.BidderVisx)].Endpoint),
openrtb_ext.BidderGamoshi: gamoshi.NewGamoshiBidder(cfg.Adapters[string(openrtb_ext.BidderGamoshi)].Endpoint),
Expand Down
10 changes: 2 additions & 8 deletions openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ const (
BidderSomoaudience BidderName = "somoaudience"
BidderSovrn BidderName = "sovrn"
BidderSonobi BidderName = "sonobi"
<<<<<<< HEAD
BidderTriplelift BidderName = "triplelift"
BidderUnruly BidderName = "unruly"
BidderVerizonMedia BidderName = "verizonmedia"
BidderVrtcal BidderName = "vrtcal"
BidderSpotx BidderName = "spotxchange"
=======
BidderSpotx BidderName = "spotx"
>>>>>>> Updated package and branding name
BidderYieldmo BidderName = "yieldmo"
BidderVisx BidderName = "visx"
BidderTappx BidderName = "tappx"
Expand Down Expand Up @@ -98,10 +90,12 @@ var BidderMap = map[string]BidderName{
"somoaudience": BidderSomoaudience,
"sovrn": BidderSovrn,
"sonobi": BidderSonobi,
"spotx": BidderSpotx,
"triplelift": BidderTriplelift,
"unruly": BidderUnruly,
"verizonmedia": BidderVerizonMedia,
"vrtcal": BidderVrtcal,
"spotx": BidderSpotx,
"yieldmo": BidderYieldmo,
"visx": BidderVisx,
"tappx": BidderTappx,
Expand Down
78 changes: 78 additions & 0 deletions openrtb_ext/imp_spotx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package openrtb_ext

import (
"encoding/json"
"fmt"
"reflect"
)

// ExtImpSpotX defines the contract for bidrequest.imp[i].ext.spotx
// ORTBVersion refers the Open RTB contract version and is optional, but will default to 2.3
// ChannelID refers to the publisher channel and is required
type ExtImpSpotX struct {
Boxing ExtImpSpotXNullBool `json:"boxing"`
ORTBVersion string `json:"ortb_version"`
ChannelID uint32 `json:"channel_id"`
WhiteList ExtImpSpotXWhiteList `json:"white_list,omitempty"`
BlackList ExtImpSpotXBlackList `json:"black_list,omitempty"`
PriceFloor float64 `json:"price_floor"`
Currency string `json:"currency"`
KVP []ExtImpSpotXKeyVal `json:"kvp,omitempty"`
}

type ExtImpSpotXWhiteList struct {
Language []string `json:"lang,omitempty"`
Seat []string `json:"seat,omitempty"`
}

type ExtImpSpotXBlackList struct {
Advertiser []string `json:"advertiser,omitempty"`
Category []string `json:"cat,omitempty"`
Seat []string `json:"seat,omitempty"`
}

// ExtImpAppnexusKeyVal defines the contract for bidrequest.imp[i].ext.appnexus.keywords[i]
type ExtImpSpotXKeyVal struct {
Key string `json:"key,omitempty"`
Values []string `json:"value,omitempty"`
}

// NullBool represents a bool that may be null.
// NullBool implements the Scanner interface so
// it can be used as a scan destination, similar to NullString.
type ExtImpSpotXNullBool struct {
Bool bool
Valid bool // Valid is true if Bool is not NULL
}

// Scan implements the Scanner interface.
func (b *ExtImpSpotXNullBool) UnmarshalJSON(data []byte) error {
var err error
var v interface{}
if err = json.Unmarshal(data, &v); err != nil {
return err
}
switch x := v.(type) {
case bool:
b.Bool = x
case map[string]interface{}:
err = json.Unmarshal(data, &b.Bool)
case nil:
b.Valid = false
return nil
default:
err = fmt.Errorf("json: cannot unmarshal %v into Go value of type null.Bool", reflect.TypeOf(v).Name())
}
b.Valid = err == nil
return err
}

func (b ExtImpSpotXNullBool) MarshalJSON() ([]byte, error) {
if !b.Valid {
return []byte("null"), nil
}
if !b.Bool {
return []byte("false"), nil
}
return []byte("true"), nil
}
2 changes: 2 additions & 0 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/prebid/prebid-server/adapters/pulsepoint"
"github.com/prebid/prebid-server/adapters/rubicon"
"github.com/prebid/prebid-server/adapters/sovrn"
"github.com/prebid/prebid-server/adapters/spotx"
analyticsConf "github.com/prebid/prebid-server/analytics/config"
"github.com/prebid/prebid-server/cache"
"github.com/prebid/prebid-server/cache/dummycache"
Expand Down Expand Up @@ -158,6 +159,7 @@ func newExchangeMap(cfg *config.Configuration) map[string]adapters.Adapter {
"conversant": conversant.NewConversantAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderConversant)].Endpoint),
"adform": adform.NewAdformAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderAdform)].Endpoint),
"sovrn": sovrn.NewSovrnAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderSovrn)].Endpoint),
"spotx": spotx.NewAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderSpotx)].Endpoint),
}
}

Expand Down
14 changes: 14 additions & 0 deletions static/bidder-info/spotx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# prebid-server//spotx
maintainer:
email: "[email protected]"
capabilities:
app:
mediaTypes:
- banner
- video
- native
site:
mediaTypes:
- banner
- video
- native
92 changes: 92 additions & 0 deletions static/bidder-params/spotx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Spotx Adapter Params",
"description": "A schema which validates params accepted by the SpotX adapter",
"type": "object",
"properties": {
"boxing": {
"type": "boolean",
"description": "Allow boxing"
},
"channel_id": {
"type": "integer",
"description": "Identifies the publisher channel to retrieve ads from"
},
"ortb_version": {
"type": "string",
"enum": ["2.3", "2.5"],
"description": "Identifies the schema version of Open RTB used"
},
"price_floor": {
"type": "number",
"description": "Indicates the price floor"
},
"currency": {
"type": "string",
"description": "Identifies the currency of the price floor"
},
"white_list": {
"type": "object",
"description": "Item lists to force",
"properties": {
"lang": {
"type": "array",
"items": {
"type": "string"
}
},
"seat": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"black_list": {
"type": "object",
"description": "Item lists to not use",
"properties": {
"advertiser": {
"type": "array",
"items": {
"type": "string"
}
},
"cat": {
"type": "array",
"items": {
"type": "string"
}
},
"seat": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"kvp": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"description": "A key with one or more values associated with it. These are used in buy-side segment targeting.",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
}
},
"required": ["key"]
}
}
}
}
17 changes: 2 additions & 15 deletions usersync/usersyncers/syncer.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package usersyncers

import (
<<<<<<< HEAD
=======
"github.com/prebid/prebid-server/adapters/gamoshi"
"github.com/prebid/prebid-server/adapters/spotx"

>>>>>>> Updated package and branding name
"strings"
"text/template"

Expand Down Expand Up @@ -42,7 +36,7 @@ import (
"github.com/prebid/prebid-server/adapters/somoaudience"
"github.com/prebid/prebid-server/adapters/sonobi"
"github.com/prebid/prebid-server/adapters/sovrn"
"github.com/prebid/prebid-server/adapters/spotxchange"
"github.com/prebid/prebid-server/adapters/spotx"
"github.com/prebid/prebid-server/adapters/triplelift"
"github.com/prebid/prebid-server/adapters/unruly"
"github.com/prebid/prebid-server/adapters/verizonmedia"
Expand Down Expand Up @@ -89,16 +83,9 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync
insertIntoMap(cfg, syncers, openrtb_ext.BidderSomoaudience, somoaudience.NewSomoaudienceSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderSovrn, sovrn.NewSovrnSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderSonobi, sonobi.NewSonobiSyncer)
<<<<<<< HEAD
<<<<<<< HEAD
insertIntoMap(cfg, syncers, openrtb_ext.BidderSpotx, spotx.NewSpotxSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderTriplelift, triplelift.NewTripleliftSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderVrtcal, vrtcal.NewVrtcalSyncer)
=======
insertIntoMap(cfg, syncers, openrtb_ext.BidderSpotx, spotxchange.NewSpotxSyncer)
>>>>>>> Add new user syncer
=======
insertIntoMap(cfg, syncers, openrtb_ext.BidderSpotx, spotx.NewSpotxSyncer)
>>>>>>> Updated package and branding name
insertIntoMap(cfg, syncers, openrtb_ext.BidderYieldmo, yieldmo.NewYieldmoSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderVisx, visx.NewVisxSyncer)
insertIntoMap(cfg, syncers, openrtb_ext.BidderGamoshi, gamoshi.NewGamoshiSyncer)
Expand Down
1 change: 1 addition & 0 deletions usersync/usersyncers/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestNewSyncerMap(t *testing.T) {
string(openrtb_ext.BidderTriplelift): syncConfig,
string(openrtb_ext.Bidder33Across): syncConfig,
string(openrtb_ext.BidderSonobi): syncConfig,
string(openrtb_ext.BidderSpotx): syncConfig,
string(openrtb_ext.BidderVrtcal): syncConfig,
string(openrtb_ext.BidderYieldmo): syncConfig,
string(openrtb_ext.BidderVisx): syncConfig,
Expand Down