Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
21 changes: 14 additions & 7 deletions adapters/taboola/taboola.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope
}

if taboolaExt.PageType != "" {
requestExt, requestExtErr := makeRequestExt(taboolaExt.PageType)
requestExt, requestExtErr := makeRequestExt(taboolaExt.PageType, modifiedRequest.Ext)
if requestExtErr == nil {
modifiedRequest.Ext = requestExt
} else {
Expand All @@ -253,17 +253,23 @@ func createTaboolaRequests(request *openrtb2.BidRequest) (taboolaRequests []*ope
return taboolaRequests, errs
}

func makeRequestExt(pageType string) (json.RawMessage, error) {
requestExt := &RequestExt{
PageType: pageType,
func makeRequestExt(pageType string, existingExt json.RawMessage) (json.RawMessage, error) {
var extMap map[string]interface{}
if len(existingExt) > 0 {
if err := jsonutil.Unmarshal(existingExt, &extMap); err != nil {
extMap = make(map[string]interface{})
}
} else {
extMap = make(map[string]interface{})
}

requestExtJson, err := json.Marshal(requestExt)
extMap["pageType"] = pageType

requestExtJson, err := json.Marshal(extMap)
if err != nil {
return nil, fmt.Errorf("could not marshal %s, err: %s", requestExt, err)
return nil, fmt.Errorf("could not marshal request ext, err: %s", err)
}
return requestExtJson, nil

}

func getMediaType(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
Expand Down Expand Up @@ -303,5 +309,6 @@ func resolveMacros(bid *openrtb2.Bid) {
price := strconv.FormatFloat(bid.Price, 'f', -1, 64)
bid.NURL = strings.Replace(bid.NURL, "${AUCTION_PRICE}", price, -1)
bid.AdM = strings.Replace(bid.AdM, "${AUCTION_PRICE}", price, -1)
bid.BURL = strings.Replace(bid.BURL, "${AUCTION_PRICE}", price, -1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"w": 300,
"h": 250,
"exp": 60,
"lurl": "https://lurl.domain.com/"
"lurl": "https://lurl.domain.com/",
"burl": "https://burl.domain.com/?wp=${AUCTION_PRICE}"
}
],
"seat": "1111"
Expand Down Expand Up @@ -145,7 +146,8 @@
"w": 300,
"h": 250,
"exp": 60,
"lurl": "https://lurl.domain.com/"
"lurl": "https://lurl.domain.com/",
"burl": "https://burl.domain.com/?wp=2.1"
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"cid": "cid",
"crid": "crid",
"lurl": "https://lurl.domain.com/",
"nurl": "nurl.com&wp=${AUCTION_PRICE}"
"nurl": "nurl.com&wp=${AUCTION_PRICE}",
"burl": "https://burl.domain.com/?wp=${AUCTION_PRICE}"
}
],
"seat": "1111"
Expand Down Expand Up @@ -116,7 +117,8 @@
"cid": "cid",
"crid": "crid",
"lurl": "https://lurl.domain.com/",
"nurl": "nurl.com&wp=2.1"
"nurl": "nurl.com&wp=2.1",
"burl": "https://burl.domain.com/?wp=2.1"
},
"type": "native"
}
Expand Down
176 changes: 176 additions & 0 deletions adapters/taboola/taboolatest/exemplary/withPageTypeAndPrebidExt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"mockBidRequest": {
"id": "request-id",
"imp": [
{
"id": "impression-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"publisherId": "publisher-id",
"tagid": "tag-id",
"pageType": "article"
}
}
}
],
"site": {
"domain": "http://domain.com",
"page": "http://page-domain.com"
},
"device": {
"ua": "Mozilla/5.0",
"h": 300,
"w": 300
},
"ext": {
"prebid": {
"channel": {
"name": "web",
"version": "1.0"
},
"integration": "pbjs",
"server": {
"externalurl": "https://pbs.example.com",
"gvlid": 42,
"datacenter": "us-east-1"
},
"sdk": {
"renderers": [
{
"name": "test-renderer",
"version": "1.0.0"
}
]
}
}
}
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://display.whatever.com/12/publisher-id",
"body": {
"id": "request-id",
"imp": [
{
"id": "impression-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"tagid": "tag-id",
"ext": {
"bidder": {
"publisherId": "publisher-id",
"tagid": "tag-id",
"pageType": "article"
}
}
}
],
"site": {
"id": "publisher-id",
"name": "publisher-id",
"domain": "http://domain.com",
"page": "http://page-domain.com",
"publisher": {
"id": "publisher-id"
}
},
"device": {
"ua": "Mozilla/5.0",
"h": 300,
"w": 300
},
"ext": {
"pageType": "article",
"prebid": {
"channel": {
"name": "web",
"version": "1.0"
},
"integration": "pbjs",
"server": {
"externalurl": "https://pbs.example.com",
"gvlid": 42,
"datacenter": "us-east-1"
},
"sdk": {
"renderers": [
{
"name": "test-renderer",
"version": "1.0.0"
}
]
}
}
}
},
"impIDs": ["impression-id"]
},
"mockResponse": {
"status": 200,
"body": {
"id": "123",
"seatbid": [
{
"bid": [
{
"id": "request-id",
"impid": "impression-id",
"price": 2.1,
"adid": "1",
"adm": "<html></html>",
"adomain": ["adomain.com"],
"cid": "cid",
"crid": "crid",
"w": 300,
"h": 250,
"exp": 60
}
],
"seat": "1111"
}
],
"bidid": "123",
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "request-id",
"impid": "impression-id",
"price": 2.1,
"adid": "1",
"adm": "<html></html>",
"adomain": ["adomain.com"],
"cid": "cid",
"crid": "crid",
"w": 300,
"h": 250,
"exp": 60
},
"type": "banner"
}
]
}
]
}
4 changes: 0 additions & 4 deletions adapters/taboola/utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
package taboola

type RequestExt struct {
PageType string `json:"pageType,omitempty"`
}
Loading