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

RTB House: Resolve AUCTION_PRICE macro #3901

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions adapters/rtbhouse/rtbhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
"strings"

"github.com/buger/jsonparser"
Expand Down Expand Up @@ -163,6 +164,7 @@ func (adapter *RTBHouseAdapter) MakeBids(
for _, bid := range seatBid.Bid {
bid := bid // pin! -> https://github.com/kyoh86/scopelint#whats-this
piotrj-rtbh marked this conversation as resolved.
Show resolved Hide resolved
bidType, err := getMediaTypeForBid(bid)
resolveMacros(&bid)
if err != nil {
errs = append(errs, err)
continue
Expand Down Expand Up @@ -222,3 +224,11 @@ func getNativeAdm(adm string) (string, error) {

return adm, nil
}

func resolveMacros(bid *openrtb2.Bid) {
if bid != nil {
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"mockBidRequest": {
"id": "test-request-id",
"site": {
"page": "https://good.site/url"
},
"imp": [{
"id": "test-imp-id",
"banner": {
"format": [{
"w": 300,
"h": 250
}]
},
"ext": {
"bidder": {}
}
}]
},

"httpCalls": [{
"expectedRequest": {
"uri": "http://localhost/prebid_server",
"body": {
"id": "test-request-id",
"cur": ["USD"],
"site": {
"page": "https://good.site/url"
},
"imp": [{
"id": "test-imp-id",
"banner": {
"format": [{
"w": 300,
"h": 250
}]
},
"ext": {
"bidder": {}
}
}]
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [{
"seat": "rtbhouse",
"bid": [{
"id": "randomid",
"impid": "test-imp-id",
"price": 0.500000,
"adid": "12345678",
"adm": "<iframe src=\"https://endpoint.url/banner1234567890.html\"></iframe><img src=\"https://endpoint.url/win-notify?a=xyz&price=${AUCTION_PRICE}\">",
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300,
"mtype": 1
}]
}],
"cur": "USD"
}
}
}],

"expectedBidResponses": [{
"currency": "USD",
"bids": [{
"bid": {
"id": "randomid",
"impid": "test-imp-id",
"price": 0.5,
"adm": "<iframe src=\"https://endpoint.url/banner1234567890.html\"></iframe><img src=\"https://endpoint.url/win-notify?a=xyz&price=0.5\">",
"adid": "12345678",
"cid": "987",
"crid": "12345678",
"w": 300,
"h": 250,
"mtype": 1
},
"type": "banner"
}]
}]
}
Loading