Skip to content

Commit

Permalink
Tappx: new bidder params (prebid#1931)
Browse files Browse the repository at this point in the history
Co-authored-by: Albert Grandes <agrandes@tappx.com>
  • Loading branch information
2 people authored and shunj-nb committed Nov 8, 2022
1 parent 95603a8 commit 8a95011
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 17 deletions.
15 changes: 15 additions & 0 deletions adapters/tappx/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func TestInvalidParams(t *testing.T) {
var validParams = []string{
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com"}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5, "mktag":"txmk-xxxxx-xxx-xxxx"}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5, "bcid":["123"]}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5, "bcrid":["245"]}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5, "bcrid":["245", "321"]}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint":"ZZ1INTERNALTEST149147915", "host":"test.tappx.com", "bidfloor":0.5, "bcid":["123", "654"], "bcrid":["245", "321"]}`,
}

var invalidParams = []string{
Expand All @@ -60,4 +65,14 @@ var invalidParams = []string{
`{"tappxkey": 1, "endpoint":"ZZ1INTERNALTEST149147915", "host":""}`,
`{"tappxkey":"pub-12345-android-9876", "endpoint": 1, "host":""}`,
`{"tappxkey": 1, "endpoint": 1, "host": 123}`,
`{"tappxkey": "1", "endpoint": 1}`,
`{"tappxkey": "1", "endpoint": "ZZ1INTERNALTEST149147915", "host":[]]}`,
`{"tappxkey": "1", "endpoint": 1, "host":"host"}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "mktag":1}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "mktag":[1,2]}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "bcid":""}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "bcid":"123", bcrid: ["123"]}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "bcid":["123"], bcrid: 123}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "bcid":["123"], bcrid: [123]}`,
`{"tappxkey": "1", "endpoint": "1", "host":"host", "bcid":[123], bcrid: ["123"]}`,
}
31 changes: 29 additions & 2 deletions adapters/tappx/tappx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,24 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

const TAPPX_BIDDER_VERSION = "1.2"
const TAPPX_BIDDER_VERSION = "1.3"
const TYPE_CNN = "prebid"

type TappxAdapter struct {
endpointTemplate template.Template
}

type Bidder struct {
Tappxkey string `json:"tappxkey"`
Mktag string `json:"mktag,omitempty"`
Bcid []string `json:"bcid,omitempty"`
Bcrid []string `json:"bcrid,omitempty"`
}

type Ext struct {
Bidder `json:"bidder"`
}

// Builder builds a new instance of the Tappx adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) {
template, err := template.New("endpointTemplate").Parse(config.Endpoint)
Expand All @@ -51,14 +62,30 @@ func (a *TappxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt
Message: "Error parsing bidderExt object",
}}
}

var tappxExt openrtb_ext.ExtImpTappx
if err := json.Unmarshal(bidderExt.Bidder, &tappxExt); err != nil {
return nil, []error{&errortypes.BadInput{
Message: "Error parsing tappxExt parameters",
}}
}

ext := Ext{
Bidder: Bidder{
Tappxkey: tappxExt.TappxKey,
Mktag: tappxExt.Mktag,
Bcid: tappxExt.Bcid,
Bcrid: tappxExt.Bcrid,
},
}

if jsonext, err := json.Marshal(ext); err == nil {
request.Ext = jsonext
} else {
return nil, []error{&errortypes.FailedToRequestBids{
Message: "Error marshaling tappxExt parameters",
}}
}

var test int
test = int(request.Test)

Expand Down
2 changes: 1 addition & 1 deletion adapters/tappx/tappx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestTsValue(t *testing.T) {

url, err := bidderTappx.buildEndpointURL(&tappxExt, test)

match, err := regexp.MatchString(`http://example\.host\.tappx\.com/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.2`, url)
match, err := regexp.MatchString(`http://example\.host\.tappx\.com/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.3`, url)
if err != nil {
t.Errorf("Error while running regex validation: %s", err.Error())
return
Expand Down
130 changes: 130 additions & 0 deletions adapters/tappx/tappxtest/exemplary/single-banner-impression-extra.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"mockBidRequest": {
"id": "0000000000001",
"test": 1,
"imp": [
{
"id": "adunit-1",
"banner": {
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876",
"endpoint": "ZZ123456PS",
"host": "testing.ssp.tappx.com/rtb/v2/",
"mktag": "mktag-12345-android-9876",
"bcid": ["1","2","3"],
"bcrid": ["4","5","6"]
}
}
}
],
"app": {
"id": "app_001",
"bundle": "com.rovio.angrybirds",
"publisher": {
"id": "2"
}
},
"user": {
"buyeruid": "A-38327932832"
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
"imp": [
{
"id": "adunit-1",
"banner": {
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876",
"endpoint": "ZZ123456PS",
"host": "testing.ssp.tappx.com/rtb/v2/",
"mktag": "mktag-12345-android-9876",
"bcid": ["1","2","3"],
"bcrid": ["4","5","6"]
}
}
}
],
"app": {
"bundle": "com.rovio.angrybirds",
"id": "app_001",
"publisher": {
"id": "2"
}
},
"user": {
"buyeruid": "A-38327932832"
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876",
"mktag": "mktag-12345-android-9876",
"bcid": ["1","2","3"],
"bcrid": ["4","5","6"]
}
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "75472df2-1cb3-4f8e-9a28-10cb95fe05a4",
"seatbid": [{
"bid": [{
"id": "wehM-93KGr0_0_0",
"impid": "adunit-1",
"price": 0.5,
"cid": "3706",
"crid": "19005",
"adid": "19005",
"adm": "<!-- admarkup -->",
"cat": ["IAB2"],
"adomain": ["test.com"],
"h": 250,
"w": 300
}]
}],
"bidid": "wehM-93KGr0"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "wehM-93KGr0_0_0",
"impid": "adunit-1",
"price": 0.5,
"adm": "<!-- admarkup -->",
"adid": "19005",
"adomain": ["test.com"],
"cid": "3706",
"crid": "19005",
"w": 300,
"h": 250,
"cat": ["IAB2"]
},
"type": "banner"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ZZ123456PS.ssp.tappx.com/rtb/?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2",
"uri": "http://ZZ123456PS.ssp.tappx.com/rtb/?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand All @@ -48,7 +48,7 @@
"bidder": {
"tappxkey": "pub-12345-android-9876",
"endpoint": "ZZ123456PS",
"host": "ZZ123456PS.ssp.tappx.com/rtb/"
"host": "ZZ123456PS.ssp.tappx.com/rtb/"
}
}
}
Expand All @@ -62,6 +62,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand Down Expand Up @@ -62,6 +62,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext":{
"bidder": {
"tappxkey": "pub-12345-android-9876"
}
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion adapters/tappx/tappxtest/exemplary/single-banner-site.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand Down Expand Up @@ -70,6 +70,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext":{
"bidder": {
"tappxkey": "pub-12345-site-9876"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand Down Expand Up @@ -67,6 +67,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext":{
"bidder": {
"tappxkey": "pub-12345-android-9876"
}
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion adapters/tappx/tappxtest/exemplary/single-video-site.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand Down Expand Up @@ -75,6 +75,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext":{
"bidder": {
"tappxkey": "pub-12345-site-9876"
}
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion adapters/tappx/tappxtest/supplemental/204status.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand All @@ -56,6 +56,11 @@
"publisher": {
"id": "2"
}
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876"
}
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion adapters/tappx/tappxtest/supplemental/bidfloor.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2",
"uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.3",
"body": {
"id": "0000000000001",
"test": 1,
Expand Down Expand Up @@ -65,6 +65,11 @@
},
"user": {
"buyeruid": "A-38327932832"
},
"ext": {
"bidder": {
"tappxkey": "pub-12345-android-9876"
}
}
}
},
Expand Down
Loading

0 comments on commit 8a95011

Please sign in to comment.