diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 401f11d1599..ae51ec62740 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -24,6 +24,7 @@ type MissenaAdRequest struct { Adunit string `json:"adunit,omitempty"` BuyerUID string `json:"buyeruid,omitempty"` Currency string `json:"currency,omitempty"` + Debug bool `json:"debug,omitempty"` EIDs []openrtb2.EID `json:"userEids,omitempty"` Floor float64 `json:"floor,omitempty"` FloorCurrency string `json:"floor_currency,omitempty"` @@ -43,19 +44,19 @@ type BidServerResponse struct { } type UserParams struct { + APIKey string `json:"apiKey,omitempty"` Formats []string `json:"formats,omitempty"` Placement string `json:"placement,omitempty" default:"sticky"` - TestMode string `json:"test,omitempty"` + Sample string `json:"sample,omitempty"` Settings map[string]any `json:"settings,omitempty"` } -type MissenaAdapter struct { - EndpointTemplate *template.Template -} - -var defaultCur = "USD" +const ( + currencyUSD = "USD" + currencyEUR = "EUR" +) -// Builder builds a new instance of the Foo adapter for the given bidder with the given config. +// Builder builds a new instance of the Missena adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { endpoint, err := template.New("endpointTemplate").Parse(config.Endpoint) if err != nil { @@ -67,18 +68,25 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return bidder, nil } +func getVersionString() string { + if version.Ver == "" { + return version.VerUnknown + } + return version.Ver +} + func getCurrency(currencies []string) (string, error) { eurAvailable := false for _, cur := range currencies { - if cur == defaultCur { - return defaultCur, nil + if cur == currencyUSD { + return currencyUSD, nil } - if cur == "EUR" { + if cur == currencyEUR { eurAvailable = true } } if eurAvailable { - return "EUR", nil + return currencyEUR, nil } return "", fmt.Errorf("no currency supported %v", currencies) } @@ -97,7 +105,7 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, re } cur, err := getCurrency(request.Cur) if err != nil { - cur = defaultCur + cur = currencyUSD } var floor float64 @@ -106,7 +114,7 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, re floor = imp.BidFloor floorCur, err = getCurrency(request.Cur) if err != nil { - floorCur = defaultCur + floorCur = currencyUSD floor, err = requestInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, floorCur) if err != nil { return nil, err @@ -114,9 +122,20 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, re } } + // Extract EIDs from user.ext. Unmarshal errors are intentionally ignored + // to allow requests to proceed without EIDs, as they are optional. + var eids []openrtb2.EID + if request.User != nil && request.User.Ext != nil { + var extUser openrtb_ext.ExtUser + if err := jsonutil.Unmarshal(request.User.Ext, &extUser); err == nil { + eids = extUser.Eids + } + } + missenaRequest := MissenaAdRequest{ Adunit: imp.ID, Currency: cur, + Debug: request.Test == 1, Floor: floor, FloorCurrency: floorCur, IdempotencyKey: request.ID, @@ -124,12 +143,14 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, re RequestID: request.ID, Timeout: request.TMax, UserParams: UserParams{ + APIKey: params.APIKey, Formats: params.Formats, Placement: params.Placement, - TestMode: params.TestMode, + Sample: params.Sample, Settings: params.Settings, }, - Version: version.Ver, + EIDs: eids, + Version: fmt.Sprintf("prebid-server@%s", getVersionString()), } body, err := jsonutil.Marshal(missenaRequest) diff --git a/adapters/missena/missenatest/exemplary/bid-floor-currency.json b/adapters/missena/missenatest/exemplary/bid-floor-currency.json index 940a2451d88..a2601c35bfc 100644 --- a/adapters/missena/missenatest/exemplary/bid-floor-currency.json +++ b/adapters/missena/missenatest/exemplary/bid-floor-currency.json @@ -88,9 +88,11 @@ "request_id": "test-request-id", "timeout": 500, "params": { + "apiKey": "test-api-key", "formats": ["banner"], "placement": "sticky" - } + }, + "version": "prebid-server@unknown" }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/exemplary/multiple-imps.json b/adapters/missena/missenatest/exemplary/multiple-imps.json index 9f0ea74ce30..2dadd0fee07 100644 --- a/adapters/missena/missenatest/exemplary/multiple-imps.json +++ b/adapters/missena/missenatest/exemplary/multiple-imps.json @@ -144,11 +144,12 @@ } }, "params": { - "placement": "test-placement-1", - "test": "1" + "apiKey": "test-api-key", + "placement": "test-placement-1" }, "request_id": "test-request-id", - "timeout": 500 + "timeout": 500, + "version": "prebid-server@unknown" }, "impIDs": ["test-imp-id-1"] }, diff --git a/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json b/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json index ab279f26b77..3d04e6738a6 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json +++ b/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json @@ -96,11 +96,12 @@ } }, "params": { - "placement": "test-placement", - "test": "1" + "apiKey": "test-api-key", + "placement": "test-placement" }, "request_id": "test-request-id", - "timeout": 500 + "timeout": 500, + "version": "prebid-server@unknown" }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/exemplary/simple-banner-with-eids.json b/adapters/missena/missenatest/exemplary/simple-banner-with-eids.json new file mode 100644 index 00000000000..ef3495317fe --- /dev/null +++ b/adapters/missena/missenatest/exemplary/simple-banner-with-eids.json @@ -0,0 +1,194 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA", + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "111111111111", + "atype": 1 + } + ] + }, + { + "source": "liveramp.com", + "uids": [ + { + "id": "AjfowMv4ZHZQME1RWTn", + "atype": 3 + } + ] + } + ] + } + }, + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?t=test-api-key", + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"], + "User-Agent": ["test-user-agent"], + "X-Forwarded-For": ["123.123.123.123"], + "Referer": ["https://example.com/page"], + "Origin": ["https://example.com"] + }, + "body": { + "adunit": "test-imp-id", + "currency": "EUR", + "ik": "test-request-id", + "ortb2": { + "at": 1, + "cur": ["EUR"], + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "id": "test-request-id", + "imp": [ + { + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement" + } + }, + "id": "test-imp-id" + } + ], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "site": { + "domain": "example.com", + "page": "https://example.com/page" + }, + "tmax": 500, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA", + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "111111111111", + "atype": 1 + } + ] + }, + { + "source": "liveramp.com", + "uids": [ + { + "id": "AjfowMv4ZHZQME1RWTn", + "atype": 3 + } + ] + } + ] + } + } + }, + "params": { + "apiKey": "test-api-key", + "placement": "test-placement" + }, + "request_id": "test-request-id", + "timeout": 500, + "userEids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "111111111111", + "atype": 1 + } + ] + }, + { + "source": "liveramp.com", + "uids": [ + { + "id": "AjfowMv4ZHZQME1RWTn", + "atype": 3 + } + ] + } + ], + "version": "prebid-server@unknown" + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "