From 3668e66d4a1f1ff53e4b660c3dfe6ac9cf1dd9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Fri, 15 Nov 2024 17:45:05 +0100 Subject: [PATCH 01/11] update params --- adapters/missena/missena.go | 132 +++++++--- .../missenatest/exemplary/multiple-imps.json | 234 +++++++++--------- .../exemplary/simple-banner-ipv6.json | 188 +++++++------- .../missenatest/exemplary/simple-banner.json | 188 +++++++------- .../exemplary/valid-imp-error-imp.json | 234 +++++++++--------- .../missenatest/supplemental/status-204.json | 150 ++++++----- .../missenatest/supplemental/status-400.json | 154 ++++++------ .../supplemental/status-not-200.json | 162 ++++++------ openrtb_ext/imp_missena.go | 7 +- 9 files changed, 725 insertions(+), 724 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 6068cf21897..6e68c304278 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/v3/errortypes" "github.com/prebid/prebid-server/v3/openrtb_ext" "github.com/prebid/prebid-server/v3/util/jsonutil" + "github.com/prebid/prebid-server/v3/version" ) type adapter struct { @@ -19,33 +20,52 @@ type adapter struct { } type MissenaAdRequest struct { - RequestId string `json:"request_id"` - Timeout int `json:"timeout"` - Referer string `json:"referer"` - RefererCanonical string `json:"referer_canonical"` - GDPRConsent string `json:"consent_string"` - GDPR bool `json:"consent_required"` - Placement string `json:"placement"` - TestMode string `json:"test"` + Adunit string `json:"adunit,omitempty"` + COPPA int8 `json:"coppa,omitempty"` + Currency string `json:"currency,omitempty"` + EIDs []openrtb2.EID `json:"userEids,omitempty"` + Floor float64 `json:"floor,omitempty"` + FloorCurrency string `json:"floor_currency,omitempty"` + GDPR bool `json:"consent_required,omitempty"` + GDPRConsent string `json:"consent_string,omitempty"` + IdempotencyKey string `json:"ik,omitempty"` + Referer string `json:"referer,omitempty"` + RefererCanonical string `json:"referer_canonical,omitempty"` + RequestID string `json:"request_id,omitempty"` + SChain *openrtb2.SupplyChain `json:"schain,omitempty"` + Timeout int `json:"timeout,omitempty"` + URL string `json:"url,omitempty"` + UserParams MissenaUserParams `json:"params"` + USPrivacy string `json:"us_privacy,omitempty"` + Version string `json:"version,omitempty"` } type MissenaBidServerResponse struct { Ad string `json:"ad"` Cpm float64 `json:"cpm"` Currency string `json:"currency"` - RequestId string `json:"requestId"` + RequestID string `json:"requestId"` +} + +type MissenaUserParams struct { + Formats []string `json:"formats,omitempty"` + Placement string `json:"placement,omitempty" default:"sticky"` + Sample string `json:"sample,omitempty"` + Settings map[string]any `json:"settings,omitempty"` } type MissenaInternalParams struct { ApiKey string - RequestId string - Timeout int - Referer string - RefererCanonical string - GDPRConsent string + Formats []string GDPR bool + GDPRConsent string Placement string - TestMode string + Referer string + RefererCanonical string + RequestId string + Sample string + Settings map[string]any + Timeout int } type MissenaAdapter struct { @@ -60,23 +80,61 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return bidder, nil } -func (a *adapter) makeRequest(missenaParams MissenaInternalParams, reqInfo *adapters.ExtraRequestInfo, impID string, request *openrtb2.BidRequest) (*adapters.RequestData, error) { +func getCurrency(currencies []string) (string, error) { + eurAvailable := false + for _, cur := range currencies { + if cur == "USD" { + return "USD", nil + } + if cur == "EUR" { + eurAvailable = true + } + } + if eurAvailable { + return "EUR", nil + } + return "", fmt.Errorf("no currency supported %v", currencies) +} + +func (a *adapter) makeRequest(missenaParams MissenaInternalParams, _ *adapters.ExtraRequestInfo, imp openrtb2.Imp, request *openrtb2.BidRequest) (*adapters.RequestData, error) { url := a.endpoint + "?t=" + missenaParams.ApiKey + currency, err := getCurrency(request.Cur) + if err != nil { + // TODO: convert unsupported currency on response + return nil, err + } + + var schain *openrtb2.SupplyChain + if request.Source != nil { + schain = request.Source.SChain + } missenaRequest := MissenaAdRequest{ - RequestId: request.ID, - Timeout: 2000, + Adunit: imp.ID, + COPPA: request.Regs.COPPA, + Currency: currency, + EIDs: request.User.EIDs, + Floor: imp.BidFloor, + FloorCurrency: imp.BidFloorCur, + GDPR: missenaParams.GDPR, + GDPRConsent: missenaParams.GDPRConsent, + IdempotencyKey: request.ID, Referer: request.Site.Page, RefererCanonical: request.Site.Domain, - GDPRConsent: missenaParams.GDPRConsent, - GDPR: missenaParams.GDPR, - Placement: missenaParams.Placement, - TestMode: missenaParams.TestMode, + RequestID: request.ID, + SChain: schain, + Timeout: 2000, + UserParams: MissenaUserParams{ + Formats: missenaParams.Formats, + Placement: missenaParams.Placement, + Settings: missenaParams.Settings, + }, + Version: version.Ver, } - body, errm := json.Marshal(missenaRequest) - if errm != nil { - return nil, errm + body, err := json.Marshal(missenaRequest) + if err != nil { + return nil, err } headers := http.Header{} @@ -100,7 +158,7 @@ func (a *adapter) makeRequest(missenaParams MissenaInternalParams, reqInfo *adap Uri: url, Headers: headers, Body: body, - ImpIDs: []string{impID}, + ImpIDs: []string{imp.ID}, }, nil } @@ -110,7 +168,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var errors []error gdprApplies, consentString := readGDPR(request) - missenaInternalParams := MissenaInternalParams{ + params := MissenaInternalParams{ GDPR: gdprApplies, GDPRConsent: consentString, } @@ -132,18 +190,16 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - missenaInternalParams.ApiKey = missenaExt.ApiKey - missenaInternalParams.Placement = missenaExt.Placement - missenaInternalParams.TestMode = missenaExt.TestMode + params.ApiKey = missenaExt.ApiKey + params.Placement = missenaExt.Placement + params.Sample = missenaExt.Sample - newHttpRequest, err := a.makeRequest(missenaInternalParams, requestInfo, imp.ID, request) + newHttpRequest, err := a.makeRequest(params, requestInfo, imp, request) if err != nil { errors = append(errors, err) continue } - httpRequests = append(httpRequests, newHttpRequest) - break } @@ -194,15 +250,15 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return nil, []error{err} } - bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) - bidResponse.Currency = missenaResponse.Currency + bidRes := adapters.NewBidderResponseWithBidsCapacity(1) + bidRes.Currency = missenaResponse.Currency responseBid := &openrtb2.Bid{ ID: request.ID, Price: float64(missenaResponse.Cpm), ImpID: request.Imp[0].ID, AdM: missenaResponse.Ad, - CrID: missenaResponse.RequestId, + CrID: missenaResponse.RequestID, } b := &adapters.TypedBid{ @@ -210,7 +266,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R BidType: openrtb_ext.BidTypeBanner, } - bidResponse.Bids = append(bidResponse.Bids, b) + bidRes.Bids = append(bidRes.Bids, b) - return bidResponse, nil + return bidRes, nil } diff --git a/adapters/missena/missenatest/exemplary/multiple-imps.json b/adapters/missena/missenatest/exemplary/multiple-imps.json index 5b83f19ccd0..d0dd1dca910 100644 --- a/adapters/missena/missenatest/exemplary/multiple-imps.json +++ b/adapters/missena/missenatest/exemplary/multiple-imps.json @@ -1,129 +1,121 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id-1", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement-1", + "test": "1" + } + } + }, + { + "id": "test-imp-id-2", + "banner": { + "h": 50, + "w": 320 }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement-2", + "test": "1" + } + } + }, + { + "id": "test-imp-id-3", + "banner": { + "h": 50, + "w": 320 }, - "device": { - "ip": "123.123.123.123", - "ua": "test-user-agent" + "ext": { + "bidder": "abc" + } + } + ] + }, + "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"] }, - "site": { - "page": "https://example.com/page", - "domain": "example.com" + "body": { + "adunit": "test-imp-id-1", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement-1" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 }, - "imp": [ - { - "id": "test-imp-id-1", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement-1", - "test": "1" - } - } - }, - { - "id": "test-imp-id-2", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement-2", - "test": "1" - } - } - }, - { - "id": "test-imp-id-3", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": "abc" - } - } - ] - }, - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement-1", - "test": "1" - }, - "impIDs":["test-imp-id-1"] - }, - "mockResponse": { - "status": 200, - "body": { - "ad": "
test ad
", - "cpm": 1.5, - "currency": "EUR", - "requestId": "test-request-id" - } - } + "impIDs": ["test-imp-id-1"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" } - ], - "expectedBidResponses": [ + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ { - "currency": "EUR", - "bids": [ - { - "bid": { - "id": "test-request-id", - "impid": "test-imp-id-1", - "price": 1.5, - "adm": "
test ad
", - "crid": "test-request-id" - }, - "type": "banner" - } - ] + "bid": { + "id": "test-request-id", + "impid": "test-imp-id-1", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" } - ] -} \ No newline at end of file + ] + } + ] +} diff --git a/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json b/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json index ea240f82e09..a4ec86959cd 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json +++ b/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json @@ -1,105 +1,97 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } - }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ipv6": "2001:0000:130F:0000:0000:09C0:876A:130B", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "h": 50, + "w": 320 }, - "device": { - "ipv6": "2001:0000:130F:0000:0000:09C0:876A:130B", - "ua": "test-user-agent" + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement", + "test": "1" + } + } + } + ] + }, + "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": ["2001:0000:130F:0000:0000:09C0:876A:130B"], + "Referer": ["https://example.com/page"] }, - "site": { - "page": "https://example.com/page", - "domain": "example.com" + "body": { + "adunit": "test-imp-id", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 }, - "imp": [ - { - "id": "test-imp-id", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement", - "test": "1" - } - } - } - ] - }, - "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": [ - "2001:0000:130F:0000:0000:09C0:876A:130B" - ], - "Referer": [ - "https://example.com/page" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement", - "test": "1" - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 200, - "body": { - "ad": "
test ad
", - "cpm": 1.5, - "currency": "EUR", - "requestId": "test-request-id" - } - } + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" } - ], - "expectedBidResponses": [ + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ { - "currency": "EUR", - "bids": [ - { - "bid": { - "id": "test-request-id", - "impid": "test-imp-id", - "price": 1.5, - "adm": "
test ad
", - "crid": "test-request-id" - }, - "type": "banner" - } - ] + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" } - ] -} \ No newline at end of file + ] + } + ] +} diff --git a/adapters/missena/missenatest/exemplary/simple-banner.json b/adapters/missena/missenatest/exemplary/simple-banner.json index 74ff3abfd57..352f92f313e 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner.json +++ b/adapters/missena/missenatest/exemplary/simple-banner.json @@ -1,105 +1,97 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } - }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "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 }, - "device": { - "ip": "123.123.123.123", - "ua": "test-user-agent" + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement", + "test": "1" + } + } + } + ] + }, + "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"] }, - "site": { - "page": "https://example.com/page", - "domain": "example.com" + "body": { + "adunit": "test-imp-id", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 }, - "imp": [ - { - "id": "test-imp-id", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement", - "test": "1" - } - } - } - ] - }, - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement", - "test": "1" - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 200, - "body": { - "ad": "
test ad
", - "cpm": 1.5, - "currency": "EUR", - "requestId": "test-request-id" - } - } + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" } - ], - "expectedBidResponses": [ + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ { - "currency": "EUR", - "bids": [ - { - "bid": { - "id": "test-request-id", - "impid": "test-imp-id", - "price": 1.5, - "adm": "
test ad
", - "crid": "test-request-id" - }, - "type": "banner" - } - ] + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" } - ] -} \ No newline at end of file + ] + } + ] +} diff --git a/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json b/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json index 61be3f78c4c..d0dd1dca910 100644 --- a/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json +++ b/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json @@ -1,129 +1,121 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ + { + "id": "test-imp-id-1", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement-1", + "test": "1" + } + } + }, + { + "id": "test-imp-id-2", + "banner": { + "h": 50, + "w": 320 }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement-2", + "test": "1" + } + } + }, + { + "id": "test-imp-id-3", + "banner": { + "h": 50, + "w": 320 }, - "device": { - "ip": "123.123.123.123", - "ua": "test-user-agent" + "ext": { + "bidder": "abc" + } + } + ] + }, + "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"] }, - "site": { - "page": "https://example.com/page", - "domain": "example.com" + "body": { + "adunit": "test-imp-id-1", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement-1" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 }, - "imp": [ - { - "id": "test-imp-id-1", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement-1", - "test": "1" - } - } - }, - { - "id": "test-imp-id-2", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement-2", - "test": "1" - } - } - }, - { - "id": "test-imp-id-3", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": "abc" - } - } - ] - }, - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement-1", - "test": "1" - }, - "impIDs": ["test-imp-id-1"] - }, - "mockResponse": { - "status": 200, - "body": { - "ad": "
test ad
", - "cpm": 1.5, - "currency": "EUR", - "requestId": "test-request-id" - } - } + "impIDs": ["test-imp-id-1"] + }, + "mockResponse": { + "status": 200, + "body": { + "ad": "
test ad
", + "cpm": 1.5, + "currency": "EUR", + "requestId": "test-request-id" } - ], - "expectedBidResponses": [ + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ { - "currency": "EUR", - "bids": [ - { - "bid": { - "id": "test-request-id", - "impid": "test-imp-id-1", - "price": 1.5, - "adm": "
test ad
", - "crid": "test-request-id" - }, - "type": "banner" - } - ] + "bid": { + "id": "test-request-id", + "impid": "test-imp-id-1", + "price": 1.5, + "adm": "
test ad
", + "crid": "test-request-id" + }, + "type": "banner" } - ] -} \ No newline at end of file + ] + } + ] +} diff --git a/adapters/missena/missenatest/supplemental/status-204.json b/adapters/missena/missenatest/supplemental/status-204.json index 59070ab4ecb..b883e9a5975 100644 --- a/adapters/missena/missenatest/supplemental/status-204.json +++ b/adapters/missena/missenatest/supplemental/status-204.json @@ -1,83 +1,75 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } - }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "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 }, - "device": { - "ip": "123.123.123.123", - "ua": "test-user-agent" + "ext": { + "bidder": { + "apiKey": "test-api-key", + "placement": "test-placement", + "test": "1" + } + } + } + ] + }, + "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"] }, - "site": { - "page": "https://example.com/page", - "domain": "example.com" + "body": { + "adunit": "test-imp-id", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 }, - "imp": [ - { - "id": "test-imp-id", - "banner": { - "h": 50, - "w": 320 - }, - "ext": { - "bidder": { - "apiKey": "test-api-key", - "placement": "test-placement", - "test": "1" - } - } - } - ] - }, - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement", - "test": "1" - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 204 - } - } - ], - "expectedBidResponses": [] -} \ No newline at end of file + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 204 + } + } + ], + "expectedBidResponses": [] +} diff --git a/adapters/missena/missenatest/supplemental/status-400.json b/adapters/missena/missenatest/supplemental/status-400.json index 23a153208e3..37f72a3bb5f 100644 --- a/adapters/missena/missenatest/supplemental/status-400.json +++ b/adapters/missena/missenatest/supplemental/status-400.json @@ -1,89 +1,81 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } - }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } - }, - "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", - "test": "1" - } - } - } - ] + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } + }, + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" }, - "httpCalls": [ + "site": { + "page": "https://example.com/page", + "domain": "example.com" + }, + "imp": [ { - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, + "id": "test-imp-id", + "banner": { + "h": 50, + "w": 320 + }, + "ext": { + "bidder": { + "apiKey": "test-api-key", "placement": "test-placement", "test": "1" - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 400, - "body": "Bad request from publisher." + } } } - ], - "expectedMakeBidsErrors": [ - { - "value": "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", - "comparison": "literal" - } ] - } \ No newline at end of file + }, + "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"] + }, + "body": { + "adunit": "test-imp-id", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 400, + "body": "Bad request from publisher." + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/adapters/missena/missenatest/supplemental/status-not-200.json b/adapters/missena/missenatest/supplemental/status-not-200.json index 8c913791fc3..f5900ad1480 100644 --- a/adapters/missena/missenatest/supplemental/status-not-200.json +++ b/adapters/missena/missenatest/supplemental/status-not-200.json @@ -1,89 +1,81 @@ { - "mockBidRequest": { - "id": "test-request-id", - "tmax": 500, - "at": 1, - "cur": [ - "EUR" - ], - "regs": { - "ext": { - "gdpr": 1 - } - }, - "user": { - "ext": { - "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" - } - }, - "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", - "test": "1" - } - } - } - ] + "mockBidRequest": { + "id": "test-request-id", + "tmax": 500, + "at": 1, + "cur": ["EUR"], + "regs": { + "ext": { + "gdpr": 1 + } }, - "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" - ] - }, - "body": { - "request_id": "test-request-id", - "timeout": 2000, - "referer": "https://example.com/page", - "referer_canonical": "example.com", - "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", - "consent_required": true, - "placement": "test-placement", - "test": "1" - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 404, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "Unexpected status code: 404. Run with request.debug = 1 for more info.", - "comparison": "literal" + "user": { + "ext": { + "consent": "CO-X2XiO_eyUoAsAxBFRBECsA" + } + }, + "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", + "test": "1" + } } + } ] -} \ No newline at end of file + }, + "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"] + }, + "body": { + "adunit": "test-imp-id", + "consent_required": true, + "consent_string": "CO-X2XiO_eyUoAsAxBFRBECsA", + "currency": "EUR", + "ik": "test-request-id", + "params": { + "placement": "test-placement" + }, + "referer": "https://example.com/page", + "referer_canonical": "example.com", + "request_id": "test-request-id", + "timeout": 2000 + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 404, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/openrtb_ext/imp_missena.go b/openrtb_ext/imp_missena.go index 3e341957123..58a53b8c27a 100644 --- a/openrtb_ext/imp_missena.go +++ b/openrtb_ext/imp_missena.go @@ -1,7 +1,8 @@ package openrtb_ext type ExtImpMissena struct { - ApiKey string `json:"apiKey"` - Placement string `json:"placement"` - TestMode string `json:"test"` + ApiKey string `json:"apiKey"` + Formats []string `json:"formats"` + Placement string `json:"placement"` + Sample string `json:"sample"` } From 817c72b4e3269703db7386937d7f5a8695a9cb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 19 Nov 2024 09:24:55 +0100 Subject: [PATCH 02/11] add APIKey --- adapters/missena/missena.go | 2 +- openrtb_ext/imp_missena.go | 2 +- static/bidder-info/missena.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 6e68c304278..529232132ac 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -190,7 +190,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - params.ApiKey = missenaExt.ApiKey + params.ApiKey = missenaExt.APIKey params.Placement = missenaExt.Placement params.Sample = missenaExt.Sample diff --git a/openrtb_ext/imp_missena.go b/openrtb_ext/imp_missena.go index 58a53b8c27a..21954e87e7e 100644 --- a/openrtb_ext/imp_missena.go +++ b/openrtb_ext/imp_missena.go @@ -1,7 +1,7 @@ package openrtb_ext type ExtImpMissena struct { - ApiKey string `json:"apiKey"` + APIKey string `json:"apiKey"` Formats []string `json:"formats"` Placement string `json:"placement"` Sample string `json:"sample"` diff --git a/static/bidder-info/missena.yaml b/static/bidder-info/missena.yaml index 47f089b9c5a..0778395e8a6 100644 --- a/static/bidder-info/missena.yaml +++ b/static/bidder-info/missena.yaml @@ -12,5 +12,5 @@ capabilities: - banner userSync: iframe: - url: https://sync.missena.io/iframe?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}} - userMacro: $UID \ No newline at end of file + url: https://sync.missena.io/iframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&t={{.APIKey}}&redirect={{.RedirectURL}} + userMacro: $UID From 27983c0a91fdf659c792332f60af5dfdaf241b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 19 Nov 2024 15:36:13 +0100 Subject: [PATCH 03/11] fix APIKey not present in macro --- adapters/missena/missena.go | 1 - static/bidder-info/missena.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 529232132ac..a034ff05b01 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -163,7 +163,6 @@ func (a *adapter) makeRequest(missenaParams MissenaInternalParams, _ *adapters.E } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var httpRequests []*adapters.RequestData var errors []error gdprApplies, consentString := readGDPR(request) diff --git a/static/bidder-info/missena.yaml b/static/bidder-info/missena.yaml index 0778395e8a6..d8cc96f5e42 100644 --- a/static/bidder-info/missena.yaml +++ b/static/bidder-info/missena.yaml @@ -12,5 +12,5 @@ capabilities: - banner userSync: iframe: - url: https://sync.missena.io/iframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&t={{.APIKey}}&redirect={{.RedirectURL}} + url: https://sync.missena.io/iframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&t=YOUR_API_KEY&redirect={{.RedirectURL}} userMacro: $UID From a8ee396beaa15f29fce0dc4385f760de0425c7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 19 Nov 2024 15:44:48 +0100 Subject: [PATCH 04/11] follow go naming convention --- adapters/missena/missena.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index a034ff05b01..344243504a4 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -35,34 +35,34 @@ type MissenaAdRequest struct { SChain *openrtb2.SupplyChain `json:"schain,omitempty"` Timeout int `json:"timeout,omitempty"` URL string `json:"url,omitempty"` - UserParams MissenaUserParams `json:"params"` + UserParams UserParams `json:"params"` USPrivacy string `json:"us_privacy,omitempty"` Version string `json:"version,omitempty"` } -type MissenaBidServerResponse struct { +type BidServerResponse struct { Ad string `json:"ad"` Cpm float64 `json:"cpm"` Currency string `json:"currency"` RequestID string `json:"requestId"` } -type MissenaUserParams struct { +type UserParams struct { Formats []string `json:"formats,omitempty"` Placement string `json:"placement,omitempty" default:"sticky"` Sample string `json:"sample,omitempty"` Settings map[string]any `json:"settings,omitempty"` } -type MissenaInternalParams struct { - ApiKey string +type InternalParams struct { + APIKey string Formats []string GDPR bool GDPRConsent string Placement string Referer string RefererCanonical string - RequestId string + RequestID string Sample string Settings map[string]any Timeout int @@ -96,8 +96,8 @@ func getCurrency(currencies []string) (string, error) { return "", fmt.Errorf("no currency supported %v", currencies) } -func (a *adapter) makeRequest(missenaParams MissenaInternalParams, _ *adapters.ExtraRequestInfo, imp openrtb2.Imp, request *openrtb2.BidRequest) (*adapters.RequestData, error) { - url := a.endpoint + "?t=" + missenaParams.ApiKey +func (a *adapter) makeRequest(missenaParams InternalParams, _ *adapters.ExtraRequestInfo, imp openrtb2.Imp, request *openrtb2.BidRequest) (*adapters.RequestData, error) { + url := a.endpoint + "?t=" + missenaParams.APIKey currency, err := getCurrency(request.Cur) if err != nil { // TODO: convert unsupported currency on response @@ -124,7 +124,7 @@ func (a *adapter) makeRequest(missenaParams MissenaInternalParams, _ *adapters.E RequestID: request.ID, SChain: schain, Timeout: 2000, - UserParams: MissenaUserParams{ + UserParams: UserParams{ Formats: missenaParams.Formats, Placement: missenaParams.Placement, Settings: missenaParams.Settings, @@ -167,7 +167,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var errors []error gdprApplies, consentString := readGDPR(request) - params := MissenaInternalParams{ + params := InternalParams{ GDPR: gdprApplies, GDPRConsent: consentString, } @@ -189,7 +189,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - params.ApiKey = missenaExt.APIKey + params.APIKey = missenaExt.APIKey params.Placement = missenaExt.Placement params.Sample = missenaExt.Sample @@ -244,7 +244,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return nil, []error{err} } - var missenaResponse MissenaBidServerResponse + var missenaResponse BidServerResponse if err := jsonutil.Unmarshal(responseData.Body, &missenaResponse); err != nil { return nil, []error{err} } From 84ba7db612679d74f7a54be49c0ee2c3a40d00fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 19 Nov 2024 16:04:49 +0100 Subject: [PATCH 05/11] simpler --- adapters/missena/missena.go | 61 ++++++++++++++------------------ adapters/missena/missena_test.go | 2 +- openrtb_ext/imp_missena.go | 9 ++--- static/bidder-info/missena.yaml | 2 +- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 344243504a4..152e3274fc4 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -4,19 +4,21 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" "text/template" "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v3/adapters" "github.com/prebid/prebid-server/v3/config" "github.com/prebid/prebid-server/v3/errortypes" + "github.com/prebid/prebid-server/v3/macros" "github.com/prebid/prebid-server/v3/openrtb_ext" "github.com/prebid/prebid-server/v3/util/jsonutil" "github.com/prebid/prebid-server/v3/version" ) type adapter struct { - endpoint string + EndpointTemplate *template.Template } type MissenaAdRequest struct { @@ -54,28 +56,18 @@ type UserParams struct { Settings map[string]any `json:"settings,omitempty"` } -type InternalParams struct { - APIKey string - Formats []string - GDPR bool - GDPRConsent string - Placement string - Referer string - RefererCanonical string - RequestID string - Sample string - Settings map[string]any - Timeout int -} - type MissenaAdapter struct { EndpointTemplate *template.Template } // Builder builds a new instance of the Foo 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 { + return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) + } bidder := &adapter{ - endpoint: config.Endpoint, + EndpointTemplate: endpoint, } return bidder, nil } @@ -96,8 +88,18 @@ func getCurrency(currencies []string) (string, error) { return "", fmt.Errorf("no currency supported %v", currencies) } -func (a *adapter) makeRequest(missenaParams InternalParams, _ *adapters.ExtraRequestInfo, imp openrtb2.Imp, request *openrtb2.BidRequest) (*adapters.RequestData, error) { - url := a.endpoint + "?t=" + missenaParams.APIKey +func (a *adapter) getEndPoint(ext *openrtb_ext.ExtImpMissena) (string, error) { + endPointParams := macros.EndpointTemplateParams{ + PublisherID: url.PathEscape(ext.APIKey), + } + return macros.ResolveMacros(a.EndpointTemplate, endPointParams) +} + +func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, params *openrtb_ext.ExtImpMissena, gdprApplies bool, consentString string) (*adapters.RequestData, error) { + url, err := a.getEndPoint(params) + if err != nil { + return nil, err + } currency, err := getCurrency(request.Cur) if err != nil { // TODO: convert unsupported currency on response @@ -116,8 +118,8 @@ func (a *adapter) makeRequest(missenaParams InternalParams, _ *adapters.ExtraReq EIDs: request.User.EIDs, Floor: imp.BidFloor, FloorCurrency: imp.BidFloorCur, - GDPR: missenaParams.GDPR, - GDPRConsent: missenaParams.GDPRConsent, + GDPR: gdprApplies, + GDPRConsent: consentString, IdempotencyKey: request.ID, Referer: request.Site.Page, RefererCanonical: request.Site.Domain, @@ -125,9 +127,9 @@ func (a *adapter) makeRequest(missenaParams InternalParams, _ *adapters.ExtraReq SChain: schain, Timeout: 2000, UserParams: UserParams{ - Formats: missenaParams.Formats, - Placement: missenaParams.Placement, - Settings: missenaParams.Settings, + Formats: params.Formats, + Placement: params.Placement, + Settings: params.Settings, }, Version: version.Ver, } @@ -167,11 +169,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var errors []error gdprApplies, consentString := readGDPR(request) - params := InternalParams{ - GDPR: gdprApplies, - GDPRConsent: consentString, - } - for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { @@ -181,7 +178,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - var missenaExt openrtb_ext.ExtImpMissena + var missenaExt *openrtb_ext.ExtImpMissena if err := jsonutil.Unmarshal(bidderExt.Bidder, &missenaExt); err != nil { errors = append(errors, &errortypes.BadInput{ Message: "Error parsing missenaExt parameters", @@ -189,11 +186,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - params.APIKey = missenaExt.APIKey - params.Placement = missenaExt.Placement - params.Sample = missenaExt.Sample - - newHttpRequest, err := a.makeRequest(params, requestInfo, imp, request) + newHttpRequest, err := a.makeRequest(imp, request, missenaExt, gdprApplies, consentString) if err != nil { errors = append(errors, err) continue diff --git a/adapters/missena/missena_test.go b/adapters/missena/missena_test.go index e388eb357cd..7f4e0f280f8 100644 --- a/adapters/missena/missena_test.go +++ b/adapters/missena/missena_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderMissena, config.Adapter{ - Endpoint: "http://example.com/"}, + Endpoint: "http://example.com/?t=test-api-key"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { diff --git a/openrtb_ext/imp_missena.go b/openrtb_ext/imp_missena.go index 21954e87e7e..ac4a7223418 100644 --- a/openrtb_ext/imp_missena.go +++ b/openrtb_ext/imp_missena.go @@ -1,8 +1,9 @@ package openrtb_ext type ExtImpMissena struct { - APIKey string `json:"apiKey"` - Formats []string `json:"formats"` - Placement string `json:"placement"` - Sample string `json:"sample"` + APIKey string `json:"apiKey"` + Formats []string `json:"formats"` + Placement string `json:"placement"` + Sample string `json:"sample"` + Settings map[string]any `json:"settings,omitempty"` } diff --git a/static/bidder-info/missena.yaml b/static/bidder-info/missena.yaml index d8cc96f5e42..83499ce664d 100644 --- a/static/bidder-info/missena.yaml +++ b/static/bidder-info/missena.yaml @@ -1,4 +1,4 @@ -endpoint: https://bid.missena.io/ +endpoint: https://bid.missena.io/?t={{.PublisherID}} maintainer: email: prebid@missena.com gvlVendorID: 687 From 7184d909ebb3b0e8c696229c21adb8459de8413c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 19 Nov 2024 16:06:41 +0100 Subject: [PATCH 06/11] better --- adapters/missena/missena_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/missena/missena_test.go b/adapters/missena/missena_test.go index 7f4e0f280f8..4a858d27c11 100644 --- a/adapters/missena/missena_test.go +++ b/adapters/missena/missena_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderMissena, config.Adapter{ - Endpoint: "http://example.com/?t=test-api-key"}, + Endpoint: "http://example.com/?t={{.PublisherID}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { From 11e555426fccb70d851519d54d69a37e21351604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Tue, 26 Nov 2024 15:19:56 +0100 Subject: [PATCH 07/11] handle floor currency --- adapters/missena/missena.go | 39 +++++++++++++------ .../missenatest/exemplary/multiple-imps.json | 2 +- .../exemplary/simple-banner-ipv6.json | 2 +- .../missenatest/exemplary/simple-banner.json | 2 +- .../exemplary/valid-imp-error-imp.json | 2 +- .../missenatest/supplemental/status-204.json | 2 +- .../missenatest/supplemental/status-400.json | 2 +- .../supplemental/status-not-200.json | 2 +- 8 files changed, 34 insertions(+), 19 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 152e3274fc4..ee6ca98a523 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -35,7 +35,7 @@ type MissenaAdRequest struct { RefererCanonical string `json:"referer_canonical,omitempty"` RequestID string `json:"request_id,omitempty"` SChain *openrtb2.SupplyChain `json:"schain,omitempty"` - Timeout int `json:"timeout,omitempty"` + Timeout int64 `json:"timeout,omitempty"` URL string `json:"url,omitempty"` UserParams UserParams `json:"params"` USPrivacy string `json:"us_privacy,omitempty"` @@ -60,6 +60,8 @@ type MissenaAdapter struct { EndpointTemplate *template.Template } +var defaultCur = "USD" + // Builder builds a new instance of the Foo 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) @@ -75,8 +77,8 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getCurrency(currencies []string) (string, error) { eurAvailable := false for _, cur := range currencies { - if cur == "USD" { - return "USD", nil + if cur == defaultCur { + return defaultCur, nil } if cur == "EUR" { eurAvailable = true @@ -95,15 +97,28 @@ func (a *adapter) getEndPoint(ext *openrtb_ext.ExtImpMissena) (string, error) { return macros.ResolveMacros(a.EndpointTemplate, endPointParams) } -func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, params *openrtb_ext.ExtImpMissena, gdprApplies bool, consentString string) (*adapters.RequestData, error) { +func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo, params *openrtb_ext.ExtImpMissena, gdprApplies bool, consentString string) (*adapters.RequestData, error) { url, err := a.getEndPoint(params) if err != nil { return nil, err } - currency, err := getCurrency(request.Cur) + cur, err := getCurrency(request.Cur) if err != nil { - // TODO: convert unsupported currency on response - return nil, err + cur = defaultCur + } + + var floor float64 + var floorCur string + if imp.BidFloor != 0 { + floor = imp.BidFloor + floorCur, err = getCurrency(request.Cur) + if err != nil { + floorCur = defaultCur + floor, err = requestInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, floorCur) + if err != nil { + return nil, err + } + } } var schain *openrtb2.SupplyChain @@ -114,10 +129,10 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, pa missenaRequest := MissenaAdRequest{ Adunit: imp.ID, COPPA: request.Regs.COPPA, - Currency: currency, + Currency: cur, EIDs: request.User.EIDs, - Floor: imp.BidFloor, - FloorCurrency: imp.BidFloorCur, + Floor: floor, + FloorCurrency: floorCur, GDPR: gdprApplies, GDPRConsent: consentString, IdempotencyKey: request.ID, @@ -125,7 +140,7 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, pa RefererCanonical: request.Site.Domain, RequestID: request.ID, SChain: schain, - Timeout: 2000, + Timeout: request.TMax, UserParams: UserParams{ Formats: params.Formats, Placement: params.Placement, @@ -186,7 +201,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } - newHttpRequest, err := a.makeRequest(imp, request, missenaExt, gdprApplies, consentString) + newHttpRequest, err := a.makeRequest(imp, request, requestInfo, missenaExt, gdprApplies, consentString) if err != nil { errors = append(errors, err) continue diff --git a/adapters/missena/missenatest/exemplary/multiple-imps.json b/adapters/missena/missenatest/exemplary/multiple-imps.json index d0dd1dca910..882746c9534 100644 --- a/adapters/missena/missenatest/exemplary/multiple-imps.json +++ b/adapters/missena/missenatest/exemplary/multiple-imps.json @@ -86,7 +86,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "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 a4ec86959cd..f63c32b8938 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json +++ b/adapters/missena/missenatest/exemplary/simple-banner-ipv6.json @@ -62,7 +62,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/exemplary/simple-banner.json b/adapters/missena/missenatest/exemplary/simple-banner.json index 352f92f313e..cb72faec466 100644 --- a/adapters/missena/missenatest/exemplary/simple-banner.json +++ b/adapters/missena/missenatest/exemplary/simple-banner.json @@ -62,7 +62,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json b/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json index d0dd1dca910..882746c9534 100644 --- a/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json +++ b/adapters/missena/missenatest/exemplary/valid-imp-error-imp.json @@ -86,7 +86,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id-1"] }, diff --git a/adapters/missena/missenatest/supplemental/status-204.json b/adapters/missena/missenatest/supplemental/status-204.json index b883e9a5975..bdfd4f58131 100644 --- a/adapters/missena/missenatest/supplemental/status-204.json +++ b/adapters/missena/missenatest/supplemental/status-204.json @@ -62,7 +62,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/supplemental/status-400.json b/adapters/missena/missenatest/supplemental/status-400.json index 37f72a3bb5f..8676a84863c 100644 --- a/adapters/missena/missenatest/supplemental/status-400.json +++ b/adapters/missena/missenatest/supplemental/status-400.json @@ -62,7 +62,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id"] }, diff --git a/adapters/missena/missenatest/supplemental/status-not-200.json b/adapters/missena/missenatest/supplemental/status-not-200.json index f5900ad1480..479690d7958 100644 --- a/adapters/missena/missenatest/supplemental/status-not-200.json +++ b/adapters/missena/missenatest/supplemental/status-not-200.json @@ -62,7 +62,7 @@ "referer": "https://example.com/page", "referer_canonical": "example.com", "request_id": "test-request-id", - "timeout": 2000 + "timeout": 500 }, "impIDs": ["test-imp-id"] }, From 94483f476c365b661b807682fd88cba65d8cc536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Wed, 15 Jan 2025 16:19:27 +0100 Subject: [PATCH 08/11] use jsonutil.Marshal --- adapters/missena/missena.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index ee6ca98a523..a709eb95ae7 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -1,7 +1,6 @@ package missena import ( - "encoding/json" "fmt" "net/http" "net/url" @@ -149,7 +148,7 @@ func (a *adapter) makeRequest(imp openrtb2.Imp, request *openrtb2.BidRequest, re Version: version.Ver, } - body, err := json.Marshal(missenaRequest) + body, err := jsonutil.Marshal(missenaRequest) if err != nil { return nil, err } From 77c1437549f382cd752374516a223609002470f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Wed, 15 Jan 2025 16:26:12 +0100 Subject: [PATCH 09/11] update message according to @przemkaczmarek proposal --- adapters/missena/missena.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index a709eb95ae7..31f4fb4d6b5 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -187,7 +187,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte var bidderExt adapters.ExtImpBidder if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { errors = append(errors, &errortypes.BadInput{ - Message: "Error parsing bidderExt object", + Message: fmt.Sprintf("Error parsing bidderExt object: %v, input: %s", err, string(imp.Ext)), }) continue } From bfe14573e4927f636deef504b4c78f2499128224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Ney?= Date: Wed, 15 Jan 2025 16:28:59 +0100 Subject: [PATCH 10/11] add comment to explicit after imp --- adapters/missena/missena.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adapters/missena/missena.go b/adapters/missena/missena.go index 31f4fb4d6b5..d3b5886d613 100644 --- a/adapters/missena/missena.go +++ b/adapters/missena/missena.go @@ -206,6 +206,8 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte continue } httpRequests = append(httpRequests, newHttpRequest) + // We only support one impression per request + // So return on the first working one break } From bdf8b0990febb6ef76dbfedcab1aa2459c84ec20 Mon Sep 17 00:00:00 2001 From: youssef Date: Thu, 16 Jan 2025 14:11:47 +0100 Subject: [PATCH 11/11] Update error message in error-imp-ext.json --- adapters/missena/missenatest/supplemental/error-imp-ext.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/missena/missenatest/supplemental/error-imp-ext.json b/adapters/missena/missenatest/supplemental/error-imp-ext.json index 3905efa6bab..d642ba91cd8 100644 --- a/adapters/missena/missenatest/supplemental/error-imp-ext.json +++ b/adapters/missena/missenatest/supplemental/error-imp-ext.json @@ -16,7 +16,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Error parsing bidderExt object", + "value": "Error parsing bidderExt object: expect { or n, but found \", input: \"error\"", "comparison": "literal" } ]