From ff253aedd966a8de42ce81588c5e6669912ef20a Mon Sep 17 00:00:00 2001 From: nico piderman Date: Wed, 22 Apr 2026 14:15:24 +0200 Subject: [PATCH 1/2] Handle AMX currency normalization --- adapters/amx/amx.go | 36 +++- .../supplemental/currency-conversion.json | 155 ++++++++++++++++++ 2 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 adapters/amx/amxtest/supplemental/currency-conversion.json diff --git a/adapters/amx/amx.go b/adapters/amx/amx.go index e133b16cc2c..be5df72888d 100644 --- a/adapters/amx/amx.go +++ b/adapters/amx/amx.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "net/url" + "strings" "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v4/adapters" @@ -16,6 +17,7 @@ import ( const nbrHeaderName = "x-nbr" const adapterVersion = "pbs1.2" +const bidderCurrency = "USD" // AMXAdapter is the AMX bid adapter type AMXAdapter struct { @@ -57,12 +59,36 @@ func ensurePublisherWithID(pub *openrtb2.Publisher, publisherID string) openrtb2 return pubCopy } +func resolveBidFloor(imp *openrtb2.Imp, reqInfo *adapters.ExtraRequestInfo) error { + if reqInfo == nil || imp.BidFloor <= 0 || imp.BidFloorCur == "" || strings.EqualFold(imp.BidFloorCur, bidderCurrency) { + return nil + } + + convertedValue, err := reqInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, bidderCurrency) + if err != nil { + return err + } + + imp.BidFloor = convertedValue + imp.BidFloorCur = bidderCurrency + return nil +} + // MakeRequests creates AMX adapter requests func (adapter *AMXAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { reqCopy := *request var publisherID string + hasBidFloor := false for idx, imp := range reqCopy.Imp { + if err := resolveBidFloor(&imp, req); err != nil { + errs = append(errs, err) + return nil, errs + } + if imp.BidFloor > 0 { + hasBidFloor = true + } + var params amxExt if err := jsonutil.Unmarshal(imp.Ext, ¶ms); err == nil { if params.Bidder.TagID != "" { @@ -72,9 +98,14 @@ func (adapter *AMXAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt // if it has an adUnitId, set as the tagid if params.Bidder.AdUnitID != "" { imp.TagID = params.Bidder.AdUnitID - reqCopy.Imp[idx] = imp } } + + reqCopy.Imp[idx] = imp + } + + if hasBidFloor && len(reqCopy.Cur) > 0 { + reqCopy.Cur = []string{bidderCurrency} } if publisherID != "" { @@ -147,6 +178,9 @@ func (adapter *AMXAdapter) MakeBids(request *openrtb2.BidRequest, externalReques } bidResponse := adapters.NewBidderResponseWithBidsCapacity(5) + if bidResp.Cur != "" { + bidResponse.Currency = bidResp.Cur + } for _, sb := range bidResp.SeatBid { for _, bid := range sb.Bid { diff --git a/adapters/amx/amxtest/supplemental/currency-conversion.json b/adapters/amx/amxtest/supplemental/currency-conversion.json new file mode 100644 index 00000000000..a8d6ec82912 --- /dev/null +++ b/adapters/amx/amxtest/supplemental/currency-conversion.json @@ -0,0 +1,155 @@ +{ + "mockBidRequest": { + "id": "currency-request-id", + "cur": [ + "EUR" + ], + "imp": [ + { + "id": "1", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "bidfloor": 1, + "bidfloorcur": "GBP", + "ext": { + "bidder": { + "tagId": "cHJlYmlkLm9yZw" + } + } + } + ], + "site": { + "domain": "www.example.com", + "publisher": { + "id": "unused_publisher_id" + } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "GBP": { + "USD": 2 + } + }, + "usepbsrates": false + } + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "body": { + "id": "currency-request-id", + "cur": [ + "USD" + ], + "imp": [ + { + "id": "1", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "bidfloor": 2, + "bidfloorcur": "USD", + "ext": { + "bidder": { + "tagId": "cHJlYmlkLm9yZw" + } + } + } + ], + "site": { + "domain": "www.example.com", + "publisher": { + "id": "cHJlYmlkLm9yZw" + } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "GBP": { + "USD": 2 + } + }, + "usepbsrates": false + } + } + } + }, + "impIDs": [ + "1" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "currency-response-id", + "cur": "USD", + "seatbid": [ + { + "bid": [ + { + "id": "TEST", + "impid": "1", + "price": 10, + "adid": "1", + "adm": "", + "adomain": [ + "amxrtb.com" + ], + "cid": "1", + "crid": "1", + "h": 250, + "w": 300 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "TEST", + "impid": "1", + "price": 10, + "adid": "1", + "adm": "", + "adomain": [ + "amxrtb.com" + ], + "cid": "1", + "crid": "1", + "h": 250, + "w": 300 + }, + "type": "banner" + } + ] + } + ] +} From 92930a1a991ab110a423dfb6b14ccfa311e9f177 Mon Sep 17 00:00:00 2001 From: nico piderman Date: Tue, 28 Apr 2026 18:23:59 +0200 Subject: [PATCH 2/2] bump amx adapter version --- adapters/amx/amx.go | 2 +- adapters/amx/amxtest/exemplary/app-simple.json | 2 +- adapters/amx/amxtest/exemplary/display-multiple.json | 4 ++-- adapters/amx/amxtest/exemplary/simple-native.json | 2 +- adapters/amx/amxtest/exemplary/video-simple.json | 2 +- adapters/amx/amxtest/exemplary/web-simple.json | 4 ++-- adapters/amx/amxtest/supplemental/204-response.json | 2 +- adapters/amx/amxtest/supplemental/400-response.json | 2 +- adapters/amx/amxtest/supplemental/500-response.json | 2 +- adapters/amx/amxtest/supplemental/currency-conversion.json | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/adapters/amx/amx.go b/adapters/amx/amx.go index be5df72888d..d58d5bfe218 100644 --- a/adapters/amx/amx.go +++ b/adapters/amx/amx.go @@ -16,7 +16,7 @@ import ( ) const nbrHeaderName = "x-nbr" -const adapterVersion = "pbs1.2" +const adapterVersion = "pbs1.3" const bidderCurrency = "USD" // AMXAdapter is the AMX bid adapter diff --git a/adapters/amx/amxtest/exemplary/app-simple.json b/adapters/amx/amxtest/exemplary/app-simple.json index 1bc205e5109..ae440359d68 100644 --- a/adapters/amx/amxtest/exemplary/app-simple.json +++ b/adapters/amx/amxtest/exemplary/app-simple.json @@ -64,7 +64,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "app": { "bundle": "639881495", diff --git a/adapters/amx/amxtest/exemplary/display-multiple.json b/adapters/amx/amxtest/exemplary/display-multiple.json index 76d97b17042..a14cfcb45c6 100644 --- a/adapters/amx/amxtest/exemplary/display-multiple.json +++ b/adapters/amx/amxtest/exemplary/display-multiple.json @@ -98,7 +98,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, @@ -294,4 +294,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/adapters/amx/amxtest/exemplary/simple-native.json b/adapters/amx/amxtest/exemplary/simple-native.json index dc158c1a748..a9b23519faa 100644 --- a/adapters/amx/amxtest/exemplary/simple-native.json +++ b/adapters/amx/amxtest/exemplary/simple-native.json @@ -19,7 +19,7 @@ "httpcalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "id": "req_id", "imp": [ diff --git a/adapters/amx/amxtest/exemplary/video-simple.json b/adapters/amx/amxtest/exemplary/video-simple.json index 45e57bf39bc..e19a1df15c4 100644 --- a/adapters/amx/amxtest/exemplary/video-simple.json +++ b/adapters/amx/amxtest/exemplary/video-simple.json @@ -94,7 +94,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, diff --git a/adapters/amx/amxtest/exemplary/web-simple.json b/adapters/amx/amxtest/exemplary/web-simple.json index 6067243f12e..23d5ccc2146 100644 --- a/adapters/amx/amxtest/exemplary/web-simple.json +++ b/adapters/amx/amxtest/exemplary/web-simple.json @@ -98,7 +98,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, @@ -244,4 +244,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/adapters/amx/amxtest/supplemental/204-response.json b/adapters/amx/amxtest/supplemental/204-response.json index cc5eea2416a..bdf0d48472f 100644 --- a/adapters/amx/amxtest/supplemental/204-response.json +++ b/adapters/amx/amxtest/supplemental/204-response.json @@ -48,7 +48,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, diff --git a/adapters/amx/amxtest/supplemental/400-response.json b/adapters/amx/amxtest/supplemental/400-response.json index 683bdb8c060..25695233fe0 100644 --- a/adapters/amx/amxtest/supplemental/400-response.json +++ b/adapters/amx/amxtest/supplemental/400-response.json @@ -48,7 +48,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, diff --git a/adapters/amx/amxtest/supplemental/500-response.json b/adapters/amx/amxtest/supplemental/500-response.json index 6beefe80b73..d66466de8df 100644 --- a/adapters/amx/amxtest/supplemental/500-response.json +++ b/adapters/amx/amxtest/supplemental/500-response.json @@ -47,7 +47,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "device": { "dnt": 0, diff --git a/adapters/amx/amxtest/supplemental/currency-conversion.json b/adapters/amx/amxtest/supplemental/currency-conversion.json index a8d6ec82912..2bb59ca9636 100644 --- a/adapters/amx/amxtest/supplemental/currency-conversion.json +++ b/adapters/amx/amxtest/supplemental/currency-conversion.json @@ -48,7 +48,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.2", + "uri": "http://pbs-dev.amxrtb.com/auction/openrtb?v=pbs1.3", "body": { "id": "currency-request-id", "cur": [